SHARE
TWEET
Untitled
a guest
Mar 30th, 2014
4
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- class UserCreateView(CreateView):
- model = User
- def dispatch(self, request, *args, **kwargs):
- self.platform = get_object_or_404(Platform, pk=self.kwargs.get("platform_id"))
- return super(UserCreateView, self).dispatch(request, *args, **kwargs)
- def get_initial(self):
- return {
- "platform_version": self.platform.current_version,
- }
- def get_form(self, form_class):
- form = super(UserCreateView, self).get_form(form_class)
- form.fields["platform_version"].widget = forms.fields.HiddenInput()
- form.fields["nodes"].widget = forms.CheckboxSelectMultiple()
- return form
- def get_context_data(self, **kwargs):
- context = super(UserCreateView, self).get_context_data(**kwargs)
- context["platform"] = self.platform
- return context
- def get_success_url(self):
- 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.
