コード例 #1
0
ファイル: views.py プロジェクト: CSRedRat/electroochered
 def post(self, request, *args, **kwargs):
     registration_form = RegistrationForm(request.POST)
     profile_form = ProfileRegistrationForm(request.POST)
     personal_data_approve_form = PersonalDataApproveForm(request.POST)
     if (registration_form.is_valid() and profile_form.is_valid() and
             personal_data_approve_form.is_valid()):
         user = registration_form.save()
         #        задаем права
         permission = Permission.objects.get(codename=u'is_requester')
         user.user_permissions.add(permission)
         profile = profile_form.save(user=user)
         user = authenticate(username=user.username,
                 password=registration_form.cleaned_data['password1'])
         if user is not None:
             if user.is_active:
                 login(request, user)
         verification_key_object = VerificationKey.objects.create_key(user)
         verification_key_object.send_email_verification()
         Logger.objects.create_for_action(CREATE_PROFILE,
             context_dict={'user': user, 'profile': profile},
             extra={'user': request.user, 'obj': profile})
         return HttpResponseRedirect(reverse('frontpage'))
     else:
         context = {'registration_form': registration_form,
             'profile_form': profile_form,
             'personal_data_approve_form': personal_data_approve_form}
         return self.render_to_response(context)
コード例 #2
0
ファイル: views.py プロジェクト: redsolution/electroochered
 def post(self, request, *args, **kwargs):
     registration_form = RegistrationForm(request.POST)
     if registration_form.is_valid():
         user = registration_form.save()
         #        задаем права
         permission = Permission.objects.get(codename=u"is_requester")
         user.user_permissions.add(permission)
         profile = Profile.objects.create(user=user, pd_processing_permit=timezone.now())
         user.set_username_by_id()
         user.save()
         user = authenticate(username=user.username, password=registration_form.cleaned_data["password1"])
         if user is not None:
             if user.is_active:
                 login(request, user)
         Logger.objects.create_for_action(
             CREATE_PROFILE,
             context_dict={"user": user, "profile": profile},
             extra={"user": request.user, "obj": profile},
         )
         return HttpResponseRedirect(reverse("frontpage"))
     else:
         context = {"registration_form": registration_form}
         return self.render_to_response(context)