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
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
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'))
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
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'))