Skip to content

Instantly share code, notes, and snippets.

View sjzabel's full-sized avatar

Stephen Zabel sjzabel

View GitHub Profile
@sjzabel
sjzabel / gist:8167695
Created December 29, 2013 05:18
Creating a base route which will load the additional controller to the route.
"use strict";
App.BaseRoute = Ember.Route.extend({
renderTemplate: function () {
this._super();
this.loadAdditionalControllers();
}
,loadAdditionalControllers: function(){
this.render('flash',{
controller: 'flash'
@sjzabel
sjzabel / gist:8167645
Created December 29, 2013 05:09
Finally the model, which uses its didLoad event to place its self into the proxy.
"use strict";
App.Flash = DS.Model.extend({
msg: DS.attr('string')
,flashType: DS.attr('string')
,didLoad: function(){
this._super();
App.flashProxy.pushObject(this);
}
});
@sjzabel
sjzabel / gist:8167592
Last active January 1, 2016 15:59
Using an Ember Array to proxy to an ArrayController
"use strict";
App.set('flashProxy', Ember.A());
App.FlashController = Ember.ArrayController.extend({
itemController: 'flashObject'
,contentBinding: 'App.flashProxy'
});
App.FlashObjectController = Ember.ObjectController.extend({
@sjzabel
sjzabel / gist:8167480
Created December 29, 2013 04:34
JSON shape of returned flash object
{
flash:{
msg: 'You do not have permission to that user'
,flashType: 'warn'
}
...
}
// or
@sjzabel
sjzabel / urls.py
Created November 18, 2011 22:41
django: adding required decorators to entire urlpatterns
'''
Author: Stephen J. Zabel
License: BSD
This module exposed a helper function for
wrapping views at the urls.py/resolver level
My personal little itch as an example...
urlpatterns += required(
@sjzabel
sjzabel / django_login_required_mixin.py
Created December 3, 2010 18:52
Adding a Mixin to all Django class based Generic Views
from django.contrib.auth.decorators import login_required
from django.utils.decorators import method_decorator
from django.views import generic
from new import classobj
import re
class LoginRequiredMixin(object):
@method_decorator(login_required)
def dispatch(self,request, *args, **kwargs ):
return super(LoginRequiredMixin, self).dispatch(request, *args, **kwargs)