def dispatch(self, request, *args, **kwargs): if not request.user.is_superuser: return redirect('status') self.customization = Customization() return super(CustomizationView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): if not request.user.is_superuser: return redirect('dashboard') self.customization = Customization() self.switchboard = Switchboard() return super(CustomizationView, self).dispatch(request, *args, **kwargs)
def customization(request): if not request.user.is_superuser: return HttpResponseRedirect(reverse('dashboard')) customization = Customization() switchboard = Switchboard() if request.method == "POST": for group in (customization, switchboard): for s in group.props(): val = request.POST.get(s.name, '') s.set_value(val) return render_to_response('cpanel/customization.html', {'settings': (customization, switchboard), 'module': 'custom'}, context_instance=RequestContext(request))
class CustomizationView(TemplateView): template_name = 'cpanel/customization.html' def dispatch(self, request, *args, **kwargs): if not request.user.is_superuser: return redirect('status') self.customization = Customization() return super(CustomizationView, self).dispatch(request, *args, **kwargs) def post(self, request, *args, **kwargs): for s in self.customization.props(): val = request.POST.get(s.name, '') s.set_value(val) return redirect('customization') def get_context_data(self, **kwargs): context = super(CustomizationView, self).get_context_data(**kwargs) context.update(dict(settings=self.customization)) return context