예제 #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
예제 #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
예제 #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'))
예제 #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
예제 #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'))
예제 #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'))
예제 #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'))