Beispiel #1
0
 def dispatch(self, request, *args, **kwargs):
     user = request.user
     
     if not hasattr(user, 'profile'):
         profile = Profile(user = user, institution = '')
         profile.save()
     else:
         profile = user.profile
         
     self.initial['email_address'] = user.email
     self.initial['institution'] = profile.institution
     self.initial['send_pool_emails'] = profile.pool_emails
     self.initial['send_task_emails'] = profile.task_emails
     
     return super(AccountProfileView, self).dispatch(request, *args, **kwargs)
Beispiel #2
0
 def dispatch(self, request, *args, **kwargs):
     user = request.user
     
     if not hasattr(user, 'profile'):
         profile = Profile(user = user, institution = '')
         profile.save()
     else:
         profile = user.profile
         
     self.initial['email_address'] = user.email
     self.initial['institution'] = profile.institution
     self.initial['send_pool_emails'] = profile.pool_emails
     self.initial['send_task_emails'] = profile.task_emails
     
     return super(AccountProfileView, self).dispatch(request, *args, **kwargs)
Beispiel #3
0
 def form_valid(self, form, *args, **kwargs):
     
     assert settings.ALLOW_NEW_REGISTRATIONS
     
     #Firstly, save and authenticate the user
     form.save()
     username = form.cleaned_data['username']
     password = form.cleaned_data['password2']
     
     user = authenticate(username=username,
                         password=password)
     
     #And log in the user
     login(self.request, user)
     
     user.email = form.cleaned_data['email_address']
     profile = Profile(user=user, institution=form.cleaned_data['institution'])
     profile.save()
     user.save()
     
     
     return super(AccountRegisterView, self).form_valid(form, *args, **kwargs)
Beispiel #4
0
 def form_valid(self, form, *args, **kwargs):
     
     assert settings.ALLOW_NEW_REGISTRATIONS
     
     #Firstly, save and authenticate the user
     form.save()
     username = form.cleaned_data['username']
     password = form.cleaned_data['password2']
     
     user = authenticate(username=username,
                         password=password)
     
     #And log in the user
     login(self.request, user)
     
     user.email = form.cleaned_data['email_address']
     profile = Profile(user=user, institution=form.cleaned_data['institution'])
     profile.save()
     user.save()
     
     
     return super(AccountRegisterView, self).form_valid(form, *args, **kwargs)