def get(self, request, *args, **kwargs): self.votingId = kwargs.get('voting_id') try: self.voting = Voting.objects.get(pk=self.votingId) except ObjectDoesNotExist as n: return redirect('census_list') return ListView.get(self, request, *args, **kwargs)
def get(self, request, *args, **kwargs): """ Goes here when loading page """ self.object = None self.form = self.get_form(self.form_class) return ListView.get(self, request, *args, **kwargs)
def post(self, request, *args, **kwargs): self.object = None self.form = self.get_form(self.form_class) if self.form.is_valid(): self.form.save() return redirect('/register/success/') else: return ListView.get(self, request, *args, **kwargs)
def get(self, request, *args, **kwargs): self.lab = kwargs['lab_pk'] self.request_format = request.GET.get('format', 'html') if self.request_format=='html': return djListView.get(self, request, *args, **kwargs) if hasattr(self, 'get_'+self.request_format): return getattr(self, 'get_'+self.request_format)(request, *args, **kwargs) raise Http404()
def post(self, request, *args, **kwargs): self.object = None self.form = self.get_form(self.form_class) if self.form.is_valid(): postid = self.kwargs['postid'] postinstance = SDLPost.objects.get(postid=postid) user = self.request.user self.form.save(postinstance, user) url = '/selfdirected/view/' + postid return redirect(url) else: return ListView.get(self, request, *args, **kwargs)
def post(self, request, *args, **kwargs): """ Save form data if valid; return empty form if valid or old form with error if not """ self.object = None self.form = self.get_form(self.form_class) if self.form.is_valid(): self.form.save() self.form = NoteForm() return ListView.get(self, request, *args, **kwargs)
def post(self, request, *args, **kwargs): #We took the inputs of the form voter_id = kwargs.get('voter_id') datos = request.POST try: if(bool(datos['startDate'])): votingIds = Voting.objects.filter(start_date__gte=datos['startDate']).filter(end_date__lte=datos['endDate']).values('id') self.ids = Census.objects.filter(voting_id__in=votingIds).filter(voter_id=voter_id).values('voting_id') else: votingIds = Voting.objects.filter(name__iregex=datos['votingName']).values('id') self.ids = Census.objects.filter(voting_id__in=votingIds).filter(voter_id=voter_id).values('voting_id') except ObjectDoesNotExist as n: return redirect('census_list') self.objects = Voting.objects.filter(pk__in=self.ids) return ListView.get(self, request, *args, **kwargs)
def get(self, request, *args, **kwargs): voter_id = kwargs.get('voter_id') orden = kwargs.get('orden') ids = Census.objects.filter(voter_id=voter_id).values('voting_id') if(orden == 'name'): print('name') object_list = Voting.objects.filter(pk__in=ids).order_by('name') elif (orden == 'startDate'): print('start') object_list = Voting.objects.filter(pk__in=ids).order_by('start_date') else: print('end') object_list = Voting.objects.filter(pk__in=ids).order_by('end_date') self.objects = object_list return ListView.get(self, request, *args, **kwargs)
def get(self, request, *args, **kwargs): for partido in Partido.objects.all(): partido.escanyos = 0 partido.votos = 0 partido.save() for circunscripcion in Circunscripcion.objects.all(): for partido in Partido.objects.all(): partido.votosCircunscripcion = 0 partido.save() for mesa in Mesa.objects.filter(circunscripcion=circunscripcion): for resultado in Resultado.objects.filter(mesa=mesa): resultado.partido.votos += resultado.votos resultado.partido.votosCircunscripcion += resultado.votos resultado.partido.save() masVotados = Partido.objects.order_by('-votosCircunscripcion')[:2] ganador = Partido.objects.get(pk=masVotados[0].pk) ganador.escanyos += circunscripcion.escanyos - 1 ganador.save() perdedor = masVotados[1] perdedor.escanyos += 1 perdedor.save() return ListView.get(self, request, *args, **kwargs)
def get(self, request, *args, **kwargs): self.voter_id = kwargs.get('voter_id') ids = Census.objects.filter(voter_id=self.voter_id).values('voting_id') object_list = Voting.objects.filter(pk__in=ids) self.objects = object_list return ListView.get(self, request, *args, **kwargs)
def get(self, request, *args, **kwargs): self.voting_id = kwargs.get('voting_id') return ListView.get(self, request, *args, **kwargs)
def get(self, request, *args, **kwargs): if 'query' in request.GET: self.query = request.GET['query'] return ListView.get(self, request, *args, **kwargs)
def get(self, request, *args, **kwargs): self.lab = kwargs['lab_pk'] return djListView.get(self, request, *args, **kwargs)
def get(self, request, *args, **kwargs): request.breadcrumbs((('Home', reverse('index')), ('Profile list', ''))) return ListView.get(self, request, *args, **kwargs)
def get(self, request, *args, **kwargs): self.object = None self.form = self.get_form(self.form_class) return ListView.get(self, request, *args, **kwargs)
def get(self, request, *args, **kwargs): self.object = None self.form = CategoryForm(None) return ListView.get(self, request, *args, **kwargs)
def get(self, request, *args, **kwargs): return ListView.get(self, request, *args, **kwargs)