From 2cb2d16191fea9cfe4afeb995b9475da6ba8c585 Mon Sep 17 00:00:00 2001 From: Ulysses Lara Date: Wed, 9 Oct 2019 11:52:57 -0300 Subject: [PATCH] 2924 ordernar cronometro arrastando (#2930) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add ordenação do cronometro arrastando Fix #2924 * Add informação de sucesso para o usuario * Arrumando recomendações relatadas no PR * Arrumando js relatado no PR --- sapl/painel/urls.py | 3 +- sapl/painel/views.py | 11 +++ sapl/templates/painel/cronometro_list.html | 99 ++++++++++++++++++++++ 3 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 sapl/templates/painel/cronometro_list.html diff --git a/sapl/painel/urls.py b/sapl/painel/urls.py index e24e94bae..3186e16e6 100644 --- a/sapl/painel/urls.py +++ b/sapl/painel/urls.py @@ -4,7 +4,7 @@ from .apps import AppConfig from .views import (cronometro_painel, get_dados_painel, painel_mensagem_view, painel_parlamentar_view, painel_view, painel_votacao_view, switch_painel, verifica_painel, votante_view, CronometroPainelCrud, - PainelConfigCrud, painel_parcial_view) + PainelConfigCrud,ordena_cronometro, painel_parcial_view) app_name = AppConfig.name @@ -23,6 +23,7 @@ urlpatterns = [ url(r'^painel/cronometro$', cronometro_painel, name='cronometro_painel'), url(r'^sistema/cronometro/', include(CronometroPainelCrud.get_urls())), + url(r'^sistema/ordena_cronometro/', ordena_cronometro, name='ordena_cronometro'), url(r'^sistema/painel-config/', include(PainelConfigCrud.get_urls())), url(r'^voto-individual/$', votante_view, diff --git a/sapl/painel/views.py b/sapl/painel/views.py index 78409006b..7ad244914 100644 --- a/sapl/painel/views.py +++ b/sapl/painel/views.py @@ -32,9 +32,19 @@ VOTACAO_NOMINAL = 2 class CronometroPainelCrud(CrudAux): model = Cronometro + class ListView(CrudAux.ListView): + template_name = "painel/cronometro_list.html" + class BaseMixin(CrudAux.BaseMixin): form_class = CronometroForm +def ordena_cronometro(request): + ordem = request.POST.getlist("ordem", []) + for index, o in enumerate(ordem, 1): + c = Cronometro.objects.get(id=o) + c.ordenacao = index + c.save() + return JsonResponse({'type':'success','msg':'Ordem alterada com sucesso.'}) class PainelConfigCrud(CrudAux): model = PainelConfig @@ -715,3 +725,4 @@ def get_dados_painel(request, pk): # Retorna que não há nenhuma matéria já votada ou aberta return response_nenhuma_materia(get_presentes(pk, response, None)) + diff --git a/sapl/templates/painel/cronometro_list.html b/sapl/templates/painel/cronometro_list.html new file mode 100644 index 000000000..7450f516d --- /dev/null +++ b/sapl/templates/painel/cronometro_list.html @@ -0,0 +1,99 @@ +{% extends "crud/list_tabaux.html" %} +{% load i18n %} +{% load i18n common_tags crispy_forms_tags%} + +{% block container_table_list %} + + {% if not rows %} +

{{ NO_ENTRIES_MSG }}

+ {% else %} +
+
{% blocktrans with verbose_name_plural=view.verbose_name_plural %}Total de {{ verbose_name_plural }}: {{count}}{% endblocktrans %}
+ + + + {% for name in headers %} + + {% endfor %} + + + + + {% for o in object_list %} + + + + + + + + + {% endfor %} + + + +
+ {% endif %} + +{% endblock container_table_list %} + + +{% block extra_js %} + + + +{% endblock %}