Browse Source

Add reorder in oradores and explicações

pull/7/head
Eduardo Edson Batista Cordeiro Alves 9 years ago
parent
commit
4121e9db0f
  1. 22
      sessao/views.py
  2. 3
      templates/sessao/explicacao.html
  3. 3
      templates/sessao/orador_expediente.html

22
sessao/views.py

@ -778,6 +778,7 @@ class OradorExpedienteView(FormMixin, sessao_crud.CrudDetailView):
self.object = self.get_object()
form = OradorForm(request.POST)
if 'adicionar' in request.POST:
if form.is_valid():
orador = OradorExpediente()
orador.sessao_plenaria_id = self.object.id
@ -786,10 +787,18 @@ class OradorExpedienteView(FormMixin, sessao_crud.CrudDetailView):
id=request.POST['parlamentar'])
orador.url_discurso = request.POST['url_discurso']
orador.save()
return self.form_valid(form)
else:
return self.form_invalid(form)
elif 'reordenar' in request.POST:
orador = OradorExpediente.objects.filter(
sessao_plenaria_id=self.object.id)
ordem_num = 1
for o in orador:
o.numero_ordem = ordem_num
o.save()
ordem_num += 1
return self.get(self, request, args, kwargs)
def get_candidatos_orador(self):
self.object = self.get_object()
@ -1174,6 +1183,7 @@ class ExplicacaoView(FormMixin, sessao_crud.CrudDetailView):
self.object = self.get_object()
form = OradorForm(request.POST)
if 'adicionar' in request.POST:
if form.is_valid():
orador = Orador()
orador.sessao_plenaria_id = self.object.id
@ -1182,10 +1192,18 @@ class ExplicacaoView(FormMixin, sessao_crud.CrudDetailView):
id=request.POST['parlamentar'])
orador.url_discurso = request.POST['url_discurso']
orador.save()
return self.form_valid(form)
else:
return self.form_invalid(form)
elif 'reordenar' in request.POST:
orador = Orador.objects.filter(
sessao_plenaria_id=self.object.id)
ordem_num = 1
for o in orador:
o.numero_ordem = ordem_num
o.save()
ordem_num += 1
return self.get(self, request, args, kwargs)
def get_candidatos_orador(self):
self.object = self.get_object()

3
templates/sessao/explicacao.html

@ -58,7 +58,8 @@
</select></li>
<li><input type="text" id="url_discurso" name="url_discurso" /></li>
</ul>
<input type="submit" value="Adicionar Orador" />
<input type="submit" value="Adicionar Orador" name="adicionar" id="adicionar" />
<input type="submit" value="Reordenar Oradores" name="reordenar" id="reordenar" />
</form>
</fieldset>
{% endblock detail_content %}

3
templates/sessao/orador_expediente.html

@ -58,7 +58,8 @@
</select></li>
<li><input type="text" id="url_discurso" name="url_discurso" /></li>
</ul>
<input type="submit" value="Adicionar Orador" />
<input type="submit" value="Adicionar Orador" name="adicionar" id="adicionar" />
<input type="submit" value="Reordenar Oradores" name="reordenar" id="reordenar" />
</form>
</fieldset>
{% endblock detail_content %}

Loading…
Cancel
Save