daily pastebin goal
82%
SHARE
TWEET

Untitled

a guest Mar 30th, 2014 4 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class UserCreateView(CreateView):
  2.     model = User
  3.  
  4.     def dispatch(self, request, *args, **kwargs):
  5.         self.platform = get_object_or_404(Platform, pk=self.kwargs.get("platform_id"))
  6.         return super(UserCreateView, self).dispatch(request, *args, **kwargs)
  7.  
  8.     def get_initial(self):
  9.         return {
  10.             "platform_version": self.platform.current_version,
  11.         }
  12.  
  13.     def get_form(self, form_class):
  14.         form = super(UserCreateView, self).get_form(form_class)
  15.         form.fields["platform_version"].widget = forms.fields.HiddenInput()
  16.         form.fields["nodes"].widget = forms.CheckboxSelectMultiple()
  17.         return form
  18.  
  19.     def get_context_data(self, **kwargs):
  20.         context = super(UserCreateView, self).get_context_data(**kwargs)
  21.         context["platform"] = self.platform
  22.         return context
  23.  
  24.     def get_success_url(self):
  25.         return reverse("user:list_user", kwargs={"platform_id": self.object.platform_version.platform.id})
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top