Exemple #1
0
 def success_url(self):
     if not UserProfile.objects.filter(user=self.user).exists():
         return reverse_lazy('users.profile.create')
     elif not UserProfile.objects.get(user=self.user).privacy_policy_accepted:
         return reverse_lazy('users.profile.update')
     else:
         return super(Verify, self).success_url
Exemple #2
0
 def success_url(self):
     if not UserProfile.objects.filter(user=self.user).exists():
         return reverse_lazy('users.profile.create')
     elif not UserProfile.objects.get(
             user=self.user).privacy_policy_accepted:
         return reverse_lazy('users.profile.update')
     else:
         return super(Verify, self).success_url
Exemple #3
0
 def test_success_url_no_profile(self):
     """
     If the user has no profile, return the url to create user profile.
     """
     user = UserFactory.create()
     self.view.user = user
     eq_(self.view.success_url, reverse_lazy('users.profile.create'))
Exemple #4
0
class DeleteProfileView(UserProfileRequiredMixin, generic.DeleteView):
    model = UserProfile
    success_url = reverse_lazy('base.home')
    template_name = 'users/profile/delete.html'

    def get_object(self):
        return self.request.user.profile
Exemple #5
0
 def test_success_url_no_profile(self):
     """
     If the user has no profile, return the url to create user profile.
     """
     user = UserFactory.create()
     self.view.user = user
     eq_(self.view.success_url, reverse_lazy('users.profile.create'))
Exemple #6
0
 def test_success_url_no_privacy_policy(self):
     """
     If the user has not accepted the privacy policy,
     return the url to edit user profile.
     """
     profile = UserProfileFactory.create(privacy_policy_accepted=False)
     self.view.user = profile.user
     eq_(self.view.success_url, reverse_lazy('users.profile.update'))
Exemple #7
0
 def test_success_url_no_privacy_policy(self):
     """
     If the user has not accepted the privacy policy,
     return the url to edit user profile.
     """
     profile = UserProfileFactory.create(privacy_policy_accepted=False)
     self.view.user = profile.user
     eq_(self.view.success_url, reverse_lazy('users.profile.update'))