def dispatch(self, request, *args, **kwargs): if not is_candidate(request.user): raise Http404 self.user = request.user self.election = get_object_or_404(Election, slug=self.kwargs['slug']) self.candidate = get_object_or_404(Candidate, id=self.kwargs['candidate_id']) return super(MyCommitments, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): if not is_candidate(request.user): raise Http404 self.user = request.user self.election = get_object_or_404(Election, slug=self.kwargs['slug']) self.candidate = get_object_or_404(Candidate, slug=self.kwargs['candidate_slug']) return super(ProposalsForMe, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): if is_candidate(request.user): return HttpResponseNotFound() if config.PROPOSALS_ENABLED: return super(ProposalWizardBase, self).dispatch(request, *args, **kwargs) else: return HttpResponseNotFound()
def dispatch(self, request, *args, **kwargs): if not is_candidate(request.user): raise Http404 self.user = request.user self.election = get_object_or_404(Election, slug=self.kwargs['slug']) self.candidate = get_object_or_404(Candidate, id=self.kwargs['candidate_id']) return super(ProfileView, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): if is_candidate(request.user): return HttpResponseNotFound() if config.PROPOSALS_ENABLED: return super(ProposalWizardBase, self).dispatch(request, *args, **kwargs) else: return HttpResponseNotFound()
def dispatch(self, request, *args, **kwargs): if not is_candidate(request.user): raise Http404 self.user = request.user self.election = get_object_or_404(Election, slug=self.kwargs['slug']) self.candidate = get_object_or_404(Candidate, slug=self.kwargs['candidate_slug']) return super(CompleteMediaNaranjaView, self).dispatch(request, *args, **kwargs)
def get_redirect_url(self, *args, **kwargs): if is_candidate(self.request.user): candidacy = self.request.user.candidacies.first() return reverse('backend_candidate:complete_profile', kwargs={'slug': candidacy.candidate.election.slug, 'candidate_slug': candidacy.candidate.slug}) if self.request.user.profile.is_organization: return reverse('organization_profiles:update') return reverse('backend_citizen:update_my_profile')
def get_redirect_url(self, *args, **kwargs): if is_candidate(self.request.user): candidacy = self.request.user.candidacies.first() return reverse('backend_candidate:complete_profile', kwargs={'slug': candidacy.candidate.election.slug, 'candidate_id': candidacy.candidate.id}) if self.request.user.profile.is_organization: return reverse('organization_profiles:update') return reverse('backend_citizen:update_my_profile')
def dispatch(self, request, *args, **kwargs): if not is_candidate(request.user): raise Http404 self.user = request.user self.election = get_object_or_404(Election, slug=self.kwargs['slug']) self.candidate = get_object_or_404(Candidate, id=self.kwargs['candidate_id']) if not Candidacy.objects.filter(user=self.request.user, candidate=self.candidate).exists(): raise Http404 return super(ProfileView, self).dispatch(request, *args, **kwargs)
def dispatch(self, *args, **kwargs): if self.request.user.is_staff: return HttpResponseNotFound() if is_candidate(self.request.user): user = self.request.user candidacy = user.candidacies.first() url = reverse_lazy('merepresenta_complete_profile', kwargs={'slug': candidacy.candidate.election.slug, 'candidate_slug': candidacy.candidate.slug}) return HttpResponseRedirect(url) return super(CPFAndDDNSelectView2, self).dispatch(*args, **kwargs)
def dispatch(self, *args, **kwargs): if self.request.user.is_staff: return HttpResponseNotFound() if is_candidate(self.request.user): user = self.request.user candidacy = user.candidacies.first() url = reverse_lazy('merepresenta_complete_profile', kwargs={ 'slug': candidacy.candidate.election.slug, 'candidate_slug': candidacy.candidate.slug }) return HttpResponseRedirect(url) return super(CPFAndDDNSelectView2, self).dispatch(*args, **kwargs)
def dispatch(self, request, *args, **kwargs): if not is_candidate(request.user): raise Http404 self.user = request.user candidacy_objects = CandidacyContact.objects.filter(candidacy__user=self.user) used_by_candidate = True for candidacy_object in candidacy_objects: if not candidacy_object.used_by_candidate: used_by_candidate = False candidacy_object.used_by_candidate = True candidacy_object.save() if not used_by_candidate: return HttpResponseRedirect(reverse('password_reset')) return super(BackendCandidateBase, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): if not is_candidate(request.user): raise Http404 self.user = request.user candidacy_objects = CandidacyContact.objects.filter( candidacy__user=self.user) used_by_candidate = True for candidacy_object in candidacy_objects: if not candidacy_object.used_by_candidate: used_by_candidate = False candidacy_object.used_by_candidate = True candidacy_object.save() if not used_by_candidate: return HttpResponseRedirect(reverse('password_reset')) return super(BackendCandidateBase, self).dispatch(request, *args, **kwargs)
def test_user_has_candidacy(self): self.assertFalse(is_candidate(self.feli)) candidacy = Candidacy.objects.create(user=self.feli, candidate=self.candidate ) self.assertTrue(is_candidate(self.feli))
def test_user_has_candidacy(self): self.assertFalse(is_candidate(self.feli)) candidacy = Candidacy.objects.create(user=self.feli, candidate=self.candidate ) self.assertTrue(is_candidate(self.feli))
def dispatch(self, request, *args, **kwargs): if is_candidate(request.user): return HttpResponseNotFound() return super(ProposalWizardFull, self).dispatch(request, *args, **kwargs)
def dispatch(self, request, *args, **kwargs): self.area = get_object_or_404(Area, id=self.kwargs['slug']) if is_candidate(request.user): return HttpResponseNotFound() return super(ProposalWizard, self).dispatch(request, *args, **kwargs)