From 23001d9c713ee2c8fe7722839e06d4e48c70429b Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Fri, 3 Feb 2017 09:17:56 -0200 Subject: [PATCH 1/5] Cria filterset para pesquisar autores --- sapl/materia/forms.py | 19 +++++++++ sapl/materia/views.py | 40 ++++++++++++++++++- .../materia/adicionar_varias_autorias.html | 0 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 sapl/templates/materia/adicionar_varias_autorias.html diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 258765a2a..38df0eec4 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -60,6 +60,25 @@ def em_tramitacao(): (False, 'Não')] +class AdicionarVariasAutoriasFilterSet(django_filters.FilterSet): + + class Meta: + model = Autor + fields = ['nome'] + + def __init__(self, *args, **kwargs): + super(AdicionarVariasAutoriasFilterSet, self).__init__(*args, **kwargs) + + row1 = to_row([('nome', 12)]) + + self.form.helper = FormHelper() + self.form.helper.form_method = 'GET' + self.form.helper.layout = Layout( + Fieldset(_('Pesquisar Autores'), + row1, form_actions(save_label='Pesquisar')) + ) + + class ReceberProposicaoForm(Form): cod_hash = forms.CharField(label='Código do Documento', required=True) diff --git a/sapl/materia/views.py b/sapl/materia/views.py index 404186591..eb1d6521c 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -43,7 +43,7 @@ from sapl.utils import (TURNO_TRAMITACAO_CHOICES, YES_NO_CHOICES, autor_label, montar_row_autor) from .forms import (AcessorioEmLoteFilterSet, AcompanhamentoMateriaForm, - DespachoInicialForm, + AdicionarVariasAutoriasFilterSet, DespachoInicialForm, DocumentoAcessorioForm, MateriaLegislativaFilterSet, MateriaSimplificadaForm, PrimeiraTramitacaoEmLoteFilterSet, ReceberProposicaoForm, TramitacaoEmLoteFilterSet, @@ -72,6 +72,44 @@ TipoFimRelatoriaCrud = CrudAux.build( TipoFimRelatoria, 'fim_relatoria') +def retira_autores_ja_adicionados(id): + return [] + + +class AdicionarVariasAutorias(PermissionRequiredForAppCrudMixin, FilterView): + filterset_class = AdicionarVariasAutoriasFilterSet + template_name = 'sessao/adicionar_varias_autorias.html' + + def get_filterset_kwargs(self, filterset_class): + super(AdicionarVariasAutorias, self).get_filterset_kwargs( + filterset_class) + + kwargs = {'data': self.request.GET or None} + + qs = self.get_queryset() + + autores_adicionadas = retira_autores_ja_adicionados(self.kwargs['pk']) + + qs = qs.exclude(id__in=autores_adicionadas).distinct() + + kwargs.update({'queryset': qs}) + return kwargs + + def get_context_data(self, **kwargs): + context = super(MateriaLegislativaPesquisaView, + self).get_context_data(**kwargs) + + context['title'] = _('Pesquisar Autores') + qr = self.request.GET.copy() + context['filter_url'] = ('&' + qr.urlencode()) if len(qr) > 0 else '' + context['pk_materia'] = self.kwargs['pk'] + return context + + def post(self, request, *args, **kwargs): + return HttpResponseRedirect( + reverse('sapl.materia:autoria_list', kwargs={'pk': pk})) + + class CriarProtocoloMateriaView(CreateView): template_name = "crud/form.html" form_class = MateriaSimplificadaForm diff --git a/sapl/templates/materia/adicionar_varias_autorias.html b/sapl/templates/materia/adicionar_varias_autorias.html new file mode 100644 index 000000000..e69de29bb From 40a4db6c13adbf37fc85a477c13684c64a0183a9 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Fri, 3 Feb 2017 10:44:12 -0200 Subject: [PATCH 2/5] Adiciona template para pesquisa --- .../migrations/0031_auto_20170203_1019.py | 19 +++++++ .../migrations/0075_auto_20170203_1019.py | 46 ++++++++++++++++ sapl/materia/models.py | 3 +- sapl/materia/urls.py | 7 ++- sapl/materia/views.py | 16 +++--- .../migrations/0033_auto_20170203_1019.py | 20 +++++++ .../migrations/0010_auto_20170203_1019.py | 25 +++++++++ .../materia/adicionar_varias_autorias.html | 54 +++++++++++++++++++ sapl/templates/materia/autoria_list.html | 14 +++++ 9 files changed, 195 insertions(+), 9 deletions(-) create mode 100644 sapl/base/migrations/0031_auto_20170203_1019.py create mode 100644 sapl/materia/migrations/0075_auto_20170203_1019.py create mode 100644 sapl/norma/migrations/0033_auto_20170203_1019.py create mode 100644 sapl/protocoloadm/migrations/0010_auto_20170203_1019.py create mode 100644 sapl/templates/materia/autoria_list.html diff --git a/sapl/base/migrations/0031_auto_20170203_1019.py b/sapl/base/migrations/0031_auto_20170203_1019.py new file mode 100644 index 000000000..b992ed44f --- /dev/null +++ b/sapl/base/migrations/0031_auto_20170203_1019.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2017-02-03 10:19 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('base', '0030_auto_20161021_2017'), + ] + + operations = [ + migrations.AlterModelOptions( + name='tipoautor', + options={'ordering': ['descricao'], 'verbose_name': 'Tipo de Autor', 'verbose_name_plural': 'Tipos de Autor'}, + ), + ] diff --git a/sapl/materia/migrations/0075_auto_20170203_1019.py b/sapl/materia/migrations/0075_auto_20170203_1019.py new file mode 100644 index 000000000..c8e5e5887 --- /dev/null +++ b/sapl/materia/migrations/0075_auto_20170203_1019.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2017-02-03 10:19 +from __future__ import unicode_literals + +from django.db import migrations, models +import sapl.utils + + +class Migration(migrations.Migration): + + dependencies = [ + ('materia', '0074_auto_20170102_0951'), + ] + + operations = [ + migrations.AlterField( + model_name='autoria', + name='primeiro_autor', + field=models.BooleanField(choices=[(True, 'Sim'), (False, 'Não')], default=False, verbose_name='Primeiro Autor'), + ), + migrations.AlterField( + model_name='materialegislativa', + name='ano', + field=models.PositiveSmallIntegerField(choices=[(2017, 2017), (2016, 2016), (2015, 2015), (2014, 2014), (2013, 2013), (2012, 2012), (2011, 2011), (2010, 2010), (2009, 2009), (2008, 2008), (2007, 2007), (2006, 2006), (2005, 2005), (2004, 2004), (2003, 2003), (2002, 2002), (2001, 2001), (2000, 2000), (1999, 1999), (1998, 1998), (1997, 1997), (1996, 1996), (1995, 1995), (1994, 1994), (1993, 1993), (1992, 1992), (1991, 1991), (1990, 1990), (1989, 1989), (1988, 1988), (1987, 1987), (1986, 1986), (1985, 1985), (1984, 1984), (1983, 1983), (1982, 1982), (1981, 1981), (1980, 1980), (1979, 1979), (1978, 1978), (1977, 1977), (1976, 1976), (1975, 1975), (1974, 1974), (1973, 1973), (1972, 1972), (1971, 1971), (1970, 1970), (1969, 1969), (1968, 1968), (1967, 1967), (1966, 1966), (1965, 1965), (1964, 1964), (1963, 1963), (1962, 1962), (1961, 1961), (1960, 1960), (1959, 1959), (1958, 1958), (1957, 1957), (1956, 1956), (1955, 1955), (1954, 1954), (1953, 1953), (1952, 1952), (1951, 1951), (1950, 1950), (1949, 1949), (1948, 1948), (1947, 1947), (1946, 1946), (1945, 1945), (1944, 1944), (1943, 1943), (1942, 1942), (1941, 1941), (1940, 1940), (1939, 1939), (1938, 1938), (1937, 1937), (1936, 1936), (1935, 1935), (1934, 1934), (1933, 1933), (1932, 1932), (1931, 1931), (1930, 1930), (1929, 1929), (1928, 1928), (1927, 1927), (1926, 1926), (1925, 1925), (1924, 1924), (1923, 1923), (1922, 1922), (1921, 1921), (1920, 1920), (1919, 1919), (1918, 1918), (1917, 1917), (1916, 1916), (1915, 1915), (1914, 1914), (1913, 1913), (1912, 1912), (1911, 1911), (1910, 1910), (1909, 1909), (1908, 1908), (1907, 1907), (1906, 1906), (1905, 1905), (1904, 1904), (1903, 1903), (1902, 1902), (1901, 1901), (1900, 1900), (1899, 1899), (1898, 1898), (1897, 1897), (1896, 1896), (1895, 1895), (1894, 1894), (1893, 1893), (1892, 1892), (1891, 1891), (1890, 1890)], verbose_name='Ano'), + ), + migrations.AlterField( + model_name='materialegislativa', + name='ano_origem_externa', + field=models.PositiveSmallIntegerField(blank=True, choices=[(2017, 2017), (2016, 2016), (2015, 2015), (2014, 2014), (2013, 2013), (2012, 2012), (2011, 2011), (2010, 2010), (2009, 2009), (2008, 2008), (2007, 2007), (2006, 2006), (2005, 2005), (2004, 2004), (2003, 2003), (2002, 2002), (2001, 2001), (2000, 2000), (1999, 1999), (1998, 1998), (1997, 1997), (1996, 1996), (1995, 1995), (1994, 1994), (1993, 1993), (1992, 1992), (1991, 1991), (1990, 1990), (1989, 1989), (1988, 1988), (1987, 1987), (1986, 1986), (1985, 1985), (1984, 1984), (1983, 1983), (1982, 1982), (1981, 1981), (1980, 1980), (1979, 1979), (1978, 1978), (1977, 1977), (1976, 1976), (1975, 1975), (1974, 1974), (1973, 1973), (1972, 1972), (1971, 1971), (1970, 1970), (1969, 1969), (1968, 1968), (1967, 1967), (1966, 1966), (1965, 1965), (1964, 1964), (1963, 1963), (1962, 1962), (1961, 1961), (1960, 1960), (1959, 1959), (1958, 1958), (1957, 1957), (1956, 1956), (1955, 1955), (1954, 1954), (1953, 1953), (1952, 1952), (1951, 1951), (1950, 1950), (1949, 1949), (1948, 1948), (1947, 1947), (1946, 1946), (1945, 1945), (1944, 1944), (1943, 1943), (1942, 1942), (1941, 1941), (1940, 1940), (1939, 1939), (1938, 1938), (1937, 1937), (1936, 1936), (1935, 1935), (1934, 1934), (1933, 1933), (1932, 1932), (1931, 1931), (1930, 1930), (1929, 1929), (1928, 1928), (1927, 1927), (1926, 1926), (1925, 1925), (1924, 1924), (1923, 1923), (1922, 1922), (1921, 1921), (1920, 1920), (1919, 1919), (1918, 1918), (1917, 1917), (1916, 1916), (1915, 1915), (1914, 1914), (1913, 1913), (1912, 1912), (1911, 1911), (1910, 1910), (1909, 1909), (1908, 1908), (1907, 1907), (1906, 1906), (1905, 1905), (1904, 1904), (1903, 1903), (1902, 1902), (1901, 1901), (1900, 1900), (1899, 1899), (1898, 1898), (1897, 1897), (1896, 1896), (1895, 1895), (1894, 1894), (1893, 1893), (1892, 1892), (1891, 1891), (1890, 1890)], null=True, verbose_name='Ano'), + ), + migrations.AlterField( + model_name='materialegislativa', + name='texto_original', + field=models.FileField(blank=True, null=True, upload_to=sapl.utils.texto_upload_path, validators=[sapl.utils.restringe_tipos_de_arquivo_txt], verbose_name='Texto Original'), + ), + migrations.AlterField( + model_name='numeracao', + name='ano_materia', + field=models.PositiveSmallIntegerField(choices=[(2017, 2017), (2016, 2016), (2015, 2015), (2014, 2014), (2013, 2013), (2012, 2012), (2011, 2011), (2010, 2010), (2009, 2009), (2008, 2008), (2007, 2007), (2006, 2006), (2005, 2005), (2004, 2004), (2003, 2003), (2002, 2002), (2001, 2001), (2000, 2000), (1999, 1999), (1998, 1998), (1997, 1997), (1996, 1996), (1995, 1995), (1994, 1994), (1993, 1993), (1992, 1992), (1991, 1991), (1990, 1990), (1989, 1989), (1988, 1988), (1987, 1987), (1986, 1986), (1985, 1985), (1984, 1984), (1983, 1983), (1982, 1982), (1981, 1981), (1980, 1980), (1979, 1979), (1978, 1978), (1977, 1977), (1976, 1976), (1975, 1975), (1974, 1974), (1973, 1973), (1972, 1972), (1971, 1971), (1970, 1970), (1969, 1969), (1968, 1968), (1967, 1967), (1966, 1966), (1965, 1965), (1964, 1964), (1963, 1963), (1962, 1962), (1961, 1961), (1960, 1960), (1959, 1959), (1958, 1958), (1957, 1957), (1956, 1956), (1955, 1955), (1954, 1954), (1953, 1953), (1952, 1952), (1951, 1951), (1950, 1950), (1949, 1949), (1948, 1948), (1947, 1947), (1946, 1946), (1945, 1945), (1944, 1944), (1943, 1943), (1942, 1942), (1941, 1941), (1940, 1940), (1939, 1939), (1938, 1938), (1937, 1937), (1936, 1936), (1935, 1935), (1934, 1934), (1933, 1933), (1932, 1932), (1931, 1931), (1930, 1930), (1929, 1929), (1928, 1928), (1927, 1927), (1926, 1926), (1925, 1925), (1924, 1924), (1923, 1923), (1922, 1922), (1921, 1921), (1920, 1920), (1919, 1919), (1918, 1918), (1917, 1917), (1916, 1916), (1915, 1915), (1914, 1914), (1913, 1913), (1912, 1912), (1911, 1911), (1910, 1910), (1909, 1909), (1908, 1908), (1907, 1907), (1906, 1906), (1905, 1905), (1904, 1904), (1903, 1903), (1902, 1902), (1901, 1901), (1900, 1900), (1899, 1899), (1898, 1898), (1897, 1897), (1896, 1896), (1895, 1895), (1894, 1894), (1893, 1893), (1892, 1892), (1891, 1891), (1890, 1890)], verbose_name='Ano'), + ), + migrations.AlterField( + model_name='proposicao', + name='ano', + field=models.PositiveSmallIntegerField(blank=True, choices=[(2017, 2017), (2016, 2016), (2015, 2015), (2014, 2014), (2013, 2013), (2012, 2012), (2011, 2011), (2010, 2010), (2009, 2009), (2008, 2008), (2007, 2007), (2006, 2006), (2005, 2005), (2004, 2004), (2003, 2003), (2002, 2002), (2001, 2001), (2000, 2000), (1999, 1999), (1998, 1998), (1997, 1997), (1996, 1996), (1995, 1995), (1994, 1994), (1993, 1993), (1992, 1992), (1991, 1991), (1990, 1990), (1989, 1989), (1988, 1988), (1987, 1987), (1986, 1986), (1985, 1985), (1984, 1984), (1983, 1983), (1982, 1982), (1981, 1981), (1980, 1980), (1979, 1979), (1978, 1978), (1977, 1977), (1976, 1976), (1975, 1975), (1974, 1974), (1973, 1973), (1972, 1972), (1971, 1971), (1970, 1970), (1969, 1969), (1968, 1968), (1967, 1967), (1966, 1966), (1965, 1965), (1964, 1964), (1963, 1963), (1962, 1962), (1961, 1961), (1960, 1960), (1959, 1959), (1958, 1958), (1957, 1957), (1956, 1956), (1955, 1955), (1954, 1954), (1953, 1953), (1952, 1952), (1951, 1951), (1950, 1950), (1949, 1949), (1948, 1948), (1947, 1947), (1946, 1946), (1945, 1945), (1944, 1944), (1943, 1943), (1942, 1942), (1941, 1941), (1940, 1940), (1939, 1939), (1938, 1938), (1937, 1937), (1936, 1936), (1935, 1935), (1934, 1934), (1933, 1933), (1932, 1932), (1931, 1931), (1930, 1930), (1929, 1929), (1928, 1928), (1927, 1927), (1926, 1926), (1925, 1925), (1924, 1924), (1923, 1923), (1922, 1922), (1921, 1921), (1920, 1920), (1919, 1919), (1918, 1918), (1917, 1917), (1916, 1916), (1915, 1915), (1914, 1914), (1913, 1913), (1912, 1912), (1911, 1911), (1910, 1910), (1909, 1909), (1908, 1908), (1907, 1907), (1906, 1906), (1905, 1905), (1904, 1904), (1903, 1903), (1902, 1902), (1901, 1901), (1900, 1900), (1899, 1899), (1898, 1898), (1897, 1897), (1896, 1896), (1895, 1895), (1894, 1894), (1893, 1893), (1892, 1892), (1891, 1891), (1890, 1890)], default=None, null=True, verbose_name='Ano'), + ), + ] diff --git a/sapl/materia/models.py b/sapl/materia/models.py index 64c1e9a16..ee453c020 100644 --- a/sapl/materia/models.py +++ b/sapl/materia/models.py @@ -234,7 +234,8 @@ class Autoria(models.Model): materia = models.ForeignKey( MateriaLegislativa, verbose_name=_('Matéria Legislativa')) primeiro_autor = models.BooleanField(verbose_name=_('Primeiro Autor'), - choices=YES_NO_CHOICES) + choices=YES_NO_CHOICES, + default=False) class Meta: verbose_name = _('Autoria') diff --git a/sapl/materia/urls.py b/sapl/materia/urls.py index 9bfe31c5c..9bd03278d 100644 --- a/sapl/materia/urls.py +++ b/sapl/materia/urls.py @@ -2,7 +2,8 @@ from django.conf.urls import include, url from sapl.materia.views import (AcompanhamentoConfirmarView, AcompanhamentoExcluirView, - AcompanhamentoMateriaView, AnexadaCrud, + AcompanhamentoMateriaView, + AdicionarVariasAutorias, AnexadaCrud, AutoriaCrud, ConfirmarProposicao, CriarProtocoloMateriaView, DespachoInicialCrud, DocumentoAcessorioCrud, @@ -55,6 +56,10 @@ urlpatterns_materia = [ AcompanhamentoExcluirView.as_view(), name='acompanhar_excluir'), + url(r'^materia/(?P\d+)/adicionar-varias-autorias/', + AdicionarVariasAutorias.as_view(), + name='adicionar_varias_autorias'), + url(r'^materia/acessorio-em-lote', DocumentoAcessorioEmLoteView.as_view(), name='acessorio_em_lote'), url(r'^materia/primeira-tramitacao-em-lote', diff --git a/sapl/materia/views.py b/sapl/materia/views.py index eb1d6521c..df2f1ef9c 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -72,18 +72,21 @@ TipoFimRelatoriaCrud = CrudAux.build( TipoFimRelatoria, 'fim_relatoria') -def retira_autores_ja_adicionados(id): - return [] +def retira_autores_ja_adicionados(materia_pk): + autorias = Autoria.objects.filter(materia_id=materia_pk) + pks = [a.pk for a in autorias] + return pks class AdicionarVariasAutorias(PermissionRequiredForAppCrudMixin, FilterView): + app_label = sapl.materia.apps.AppConfig.label filterset_class = AdicionarVariasAutoriasFilterSet - template_name = 'sessao/adicionar_varias_autorias.html' + template_name = 'materia/adicionar_varias_autorias.html' + model = Autor def get_filterset_kwargs(self, filterset_class): super(AdicionarVariasAutorias, self).get_filterset_kwargs( filterset_class) - kwargs = {'data': self.request.GET or None} qs = self.get_queryset() @@ -91,13 +94,12 @@ class AdicionarVariasAutorias(PermissionRequiredForAppCrudMixin, FilterView): autores_adicionadas = retira_autores_ja_adicionados(self.kwargs['pk']) qs = qs.exclude(id__in=autores_adicionadas).distinct() - kwargs.update({'queryset': qs}) return kwargs def get_context_data(self, **kwargs): - context = super(MateriaLegislativaPesquisaView, - self).get_context_data(**kwargs) + context = super(AdicionarVariasAutorias, self).get_context_data( + **kwargs) context['title'] = _('Pesquisar Autores') qr = self.request.GET.copy() diff --git a/sapl/norma/migrations/0033_auto_20170203_1019.py b/sapl/norma/migrations/0033_auto_20170203_1019.py new file mode 100644 index 000000000..22157ad6f --- /dev/null +++ b/sapl/norma/migrations/0033_auto_20170203_1019.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2017-02-03 10:19 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('norma', '0032_merge'), + ] + + operations = [ + migrations.AlterField( + model_name='normajuridica', + name='ano', + field=models.PositiveSmallIntegerField(choices=[(2017, 2017), (2016, 2016), (2015, 2015), (2014, 2014), (2013, 2013), (2012, 2012), (2011, 2011), (2010, 2010), (2009, 2009), (2008, 2008), (2007, 2007), (2006, 2006), (2005, 2005), (2004, 2004), (2003, 2003), (2002, 2002), (2001, 2001), (2000, 2000), (1999, 1999), (1998, 1998), (1997, 1997), (1996, 1996), (1995, 1995), (1994, 1994), (1993, 1993), (1992, 1992), (1991, 1991), (1990, 1990), (1989, 1989), (1988, 1988), (1987, 1987), (1986, 1986), (1985, 1985), (1984, 1984), (1983, 1983), (1982, 1982), (1981, 1981), (1980, 1980), (1979, 1979), (1978, 1978), (1977, 1977), (1976, 1976), (1975, 1975), (1974, 1974), (1973, 1973), (1972, 1972), (1971, 1971), (1970, 1970), (1969, 1969), (1968, 1968), (1967, 1967), (1966, 1966), (1965, 1965), (1964, 1964), (1963, 1963), (1962, 1962), (1961, 1961), (1960, 1960), (1959, 1959), (1958, 1958), (1957, 1957), (1956, 1956), (1955, 1955), (1954, 1954), (1953, 1953), (1952, 1952), (1951, 1951), (1950, 1950), (1949, 1949), (1948, 1948), (1947, 1947), (1946, 1946), (1945, 1945), (1944, 1944), (1943, 1943), (1942, 1942), (1941, 1941), (1940, 1940), (1939, 1939), (1938, 1938), (1937, 1937), (1936, 1936), (1935, 1935), (1934, 1934), (1933, 1933), (1932, 1932), (1931, 1931), (1930, 1930), (1929, 1929), (1928, 1928), (1927, 1927), (1926, 1926), (1925, 1925), (1924, 1924), (1923, 1923), (1922, 1922), (1921, 1921), (1920, 1920), (1919, 1919), (1918, 1918), (1917, 1917), (1916, 1916), (1915, 1915), (1914, 1914), (1913, 1913), (1912, 1912), (1911, 1911), (1910, 1910), (1909, 1909), (1908, 1908), (1907, 1907), (1906, 1906), (1905, 1905), (1904, 1904), (1903, 1903), (1902, 1902), (1901, 1901), (1900, 1900), (1899, 1899), (1898, 1898), (1897, 1897), (1896, 1896), (1895, 1895), (1894, 1894), (1893, 1893), (1892, 1892), (1891, 1891), (1890, 1890)], verbose_name='Ano'), + ), + ] diff --git a/sapl/protocoloadm/migrations/0010_auto_20170203_1019.py b/sapl/protocoloadm/migrations/0010_auto_20170203_1019.py new file mode 100644 index 000000000..dadc43244 --- /dev/null +++ b/sapl/protocoloadm/migrations/0010_auto_20170203_1019.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2017-02-03 10:19 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('protocoloadm', '0009_auto_20170102_0951'), + ] + + operations = [ + migrations.AlterField( + model_name='documentoadministrativo', + name='ano', + field=models.PositiveSmallIntegerField(choices=[(2017, 2017), (2016, 2016), (2015, 2015), (2014, 2014), (2013, 2013), (2012, 2012), (2011, 2011), (2010, 2010), (2009, 2009), (2008, 2008), (2007, 2007), (2006, 2006), (2005, 2005), (2004, 2004), (2003, 2003), (2002, 2002), (2001, 2001), (2000, 2000), (1999, 1999), (1998, 1998), (1997, 1997), (1996, 1996), (1995, 1995), (1994, 1994), (1993, 1993), (1992, 1992), (1991, 1991), (1990, 1990), (1989, 1989), (1988, 1988), (1987, 1987), (1986, 1986), (1985, 1985), (1984, 1984), (1983, 1983), (1982, 1982), (1981, 1981), (1980, 1980), (1979, 1979), (1978, 1978), (1977, 1977), (1976, 1976), (1975, 1975), (1974, 1974), (1973, 1973), (1972, 1972), (1971, 1971), (1970, 1970), (1969, 1969), (1968, 1968), (1967, 1967), (1966, 1966), (1965, 1965), (1964, 1964), (1963, 1963), (1962, 1962), (1961, 1961), (1960, 1960), (1959, 1959), (1958, 1958), (1957, 1957), (1956, 1956), (1955, 1955), (1954, 1954), (1953, 1953), (1952, 1952), (1951, 1951), (1950, 1950), (1949, 1949), (1948, 1948), (1947, 1947), (1946, 1946), (1945, 1945), (1944, 1944), (1943, 1943), (1942, 1942), (1941, 1941), (1940, 1940), (1939, 1939), (1938, 1938), (1937, 1937), (1936, 1936), (1935, 1935), (1934, 1934), (1933, 1933), (1932, 1932), (1931, 1931), (1930, 1930), (1929, 1929), (1928, 1928), (1927, 1927), (1926, 1926), (1925, 1925), (1924, 1924), (1923, 1923), (1922, 1922), (1921, 1921), (1920, 1920), (1919, 1919), (1918, 1918), (1917, 1917), (1916, 1916), (1915, 1915), (1914, 1914), (1913, 1913), (1912, 1912), (1911, 1911), (1910, 1910), (1909, 1909), (1908, 1908), (1907, 1907), (1906, 1906), (1905, 1905), (1904, 1904), (1903, 1903), (1902, 1902), (1901, 1901), (1900, 1900), (1899, 1899), (1898, 1898), (1897, 1897), (1896, 1896), (1895, 1895), (1894, 1894), (1893, 1893), (1892, 1892), (1891, 1891), (1890, 1890)], verbose_name='Ano'), + ), + migrations.AlterField( + model_name='protocolo', + name='ano', + field=models.PositiveSmallIntegerField(choices=[(2017, 2017), (2016, 2016), (2015, 2015), (2014, 2014), (2013, 2013), (2012, 2012), (2011, 2011), (2010, 2010), (2009, 2009), (2008, 2008), (2007, 2007), (2006, 2006), (2005, 2005), (2004, 2004), (2003, 2003), (2002, 2002), (2001, 2001), (2000, 2000), (1999, 1999), (1998, 1998), (1997, 1997), (1996, 1996), (1995, 1995), (1994, 1994), (1993, 1993), (1992, 1992), (1991, 1991), (1990, 1990), (1989, 1989), (1988, 1988), (1987, 1987), (1986, 1986), (1985, 1985), (1984, 1984), (1983, 1983), (1982, 1982), (1981, 1981), (1980, 1980), (1979, 1979), (1978, 1978), (1977, 1977), (1976, 1976), (1975, 1975), (1974, 1974), (1973, 1973), (1972, 1972), (1971, 1971), (1970, 1970), (1969, 1969), (1968, 1968), (1967, 1967), (1966, 1966), (1965, 1965), (1964, 1964), (1963, 1963), (1962, 1962), (1961, 1961), (1960, 1960), (1959, 1959), (1958, 1958), (1957, 1957), (1956, 1956), (1955, 1955), (1954, 1954), (1953, 1953), (1952, 1952), (1951, 1951), (1950, 1950), (1949, 1949), (1948, 1948), (1947, 1947), (1946, 1946), (1945, 1945), (1944, 1944), (1943, 1943), (1942, 1942), (1941, 1941), (1940, 1940), (1939, 1939), (1938, 1938), (1937, 1937), (1936, 1936), (1935, 1935), (1934, 1934), (1933, 1933), (1932, 1932), (1931, 1931), (1930, 1930), (1929, 1929), (1928, 1928), (1927, 1927), (1926, 1926), (1925, 1925), (1924, 1924), (1923, 1923), (1922, 1922), (1921, 1921), (1920, 1920), (1919, 1919), (1918, 1918), (1917, 1917), (1916, 1916), (1915, 1915), (1914, 1914), (1913, 1913), (1912, 1912), (1911, 1911), (1910, 1910), (1909, 1909), (1908, 1908), (1907, 1907), (1906, 1906), (1905, 1905), (1904, 1904), (1903, 1903), (1902, 1902), (1901, 1901), (1900, 1900), (1899, 1899), (1898, 1898), (1897, 1897), (1896, 1896), (1895, 1895), (1894, 1894), (1893, 1893), (1892, 1892), (1891, 1891), (1890, 1890)], verbose_name='Ano do Protocolo'), + ), + ] diff --git a/sapl/templates/materia/adicionar_varias_autorias.html b/sapl/templates/materia/adicionar_varias_autorias.html index e69de29bb..34bed6d42 100644 --- a/sapl/templates/materia/adicionar_varias_autorias.html +++ b/sapl/templates/materia/adicionar_varias_autorias.html @@ -0,0 +1,54 @@ +{% extends "crud/detail.html" %} +{% load i18n %} +{% load crispy_forms_tags %} +{% block actions %}{% endblock %} + +{% block detail_content %} + {% block buttons %} + {% if filter_url %} + +      + + {% endif %} + {% endblock buttons %} + + {% if not filter_url %} + {% crispy filter.form %} + {% endif %} + + {% if filter_url %} + + + + + {% if filter.qs|length > 1 %} +

{% blocktrans with filter.qs|length as total_autores %}Pesquisa concluída com sucesso! Foram encontrados {{total_autores}} autores.{% endblocktrans %}

+ {% elif filter.qs|length == 1 %} +

{% trans 'Pesquisa concluída com sucesso! Foi encontrado 1 autor.'%}

+ {% else %} + + {% endif %} + + + {% csrf_token %} + {% for m in filter.qs %} + + + + {% endfor %} + +

{% trans "Autor" %}

Nenhum autor encontrado.

+ +    + {{m}}
+
+
+ +
+ + {% endif %} +{% endblock detail_content %} diff --git a/sapl/templates/materia/autoria_list.html b/sapl/templates/materia/autoria_list.html new file mode 100644 index 000000000..44b59c849 --- /dev/null +++ b/sapl/templates/materia/autoria_list.html @@ -0,0 +1,14 @@ +{% extends "crud/list.html" %} +{% load i18n %} +{% load common_tags %} + + +{% block more_buttons %} + +{% if perms|get_add_perm:view %} + + {% blocktrans with verbose_name=view.verbose_name %} Adicionar Várias Autorias {% endblocktrans %} + +{% endif %} + +{% endblock more_buttons %} From 4403a2b25aacccb158d215b15ee61d34d520c6ad Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Fri, 3 Feb 2017 10:52:05 -0200 Subject: [PATCH 3/5] =?UTF-8?q?Remove=20autores=20j=C3=A1=20adicionados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/materia/views.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/sapl/materia/views.py b/sapl/materia/views.py index df2f1ef9c..aac383fd8 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -72,9 +72,9 @@ TipoFimRelatoriaCrud = CrudAux.build( TipoFimRelatoria, 'fim_relatoria') -def retira_autores_ja_adicionados(materia_pk): +def autores_ja_adicionados(materia_pk): autorias = Autoria.objects.filter(materia_id=materia_pk) - pks = [a.pk for a in autorias] + pks = [a.autor.pk for a in autorias] return pks @@ -90,10 +90,9 @@ class AdicionarVariasAutorias(PermissionRequiredForAppCrudMixin, FilterView): kwargs = {'data': self.request.GET or None} qs = self.get_queryset() + qs = qs.exclude( + id__in=autores_ja_adicionados(self.kwargs['pk'])).distinct() - autores_adicionadas = retira_autores_ja_adicionados(self.kwargs['pk']) - - qs = qs.exclude(id__in=autores_adicionadas).distinct() kwargs.update({'queryset': qs}) return kwargs From 502004d23046c8586d7e55d0a980157719257222 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Fri, 3 Feb 2017 10:56:57 -0200 Subject: [PATCH 4/5] Implementa post --- sapl/materia/views.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sapl/materia/views.py b/sapl/materia/views.py index aac383fd8..619c1dde2 100644 --- a/sapl/materia/views.py +++ b/sapl/materia/views.py @@ -107,8 +107,17 @@ class AdicionarVariasAutorias(PermissionRequiredForAppCrudMixin, FilterView): return context def post(self, request, *args, **kwargs): + marcados = request.POST.getlist('autor_id') + + for m in marcados: + Autoria.objects.create( + materia_id=self.kwargs['pk'], + autor_id=m + ) + return HttpResponseRedirect( - reverse('sapl.materia:autoria_list', kwargs={'pk': pk})) + reverse('sapl.materia:autoria_list', + kwargs={'pk': self.kwargs['pk']})) class CriarProtocoloMateriaView(CreateView): From 81d33fd2383642b6463ef318f3b2d78dcb992af4 Mon Sep 17 00:00:00 2001 From: Eduardo Edson Batista Cordeiro Alves Date: Fri, 3 Feb 2017 11:14:13 -0200 Subject: [PATCH 5/5] =?UTF-8?q?Muda=20forma=20como=20=C3=A9=20mostrado=20o?= =?UTF-8?q?s=20autores=20que=20podem=20ser=20selecionados'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sapl/materia/forms.py | 4 +- .../materia/adicionar_varias_autorias.html | 55 ++++++++----------- 2 files changed, 24 insertions(+), 35 deletions(-) diff --git a/sapl/materia/forms.py b/sapl/materia/forms.py index 38df0eec4..19f3dac0c 100644 --- a/sapl/materia/forms.py +++ b/sapl/materia/forms.py @@ -74,8 +74,8 @@ class AdicionarVariasAutoriasFilterSet(django_filters.FilterSet): self.form.helper = FormHelper() self.form.helper.form_method = 'GET' self.form.helper.layout = Layout( - Fieldset(_('Pesquisar Autores'), - row1, form_actions(save_label='Pesquisar')) + Fieldset(_('Filtrar Autores'), + row1, form_actions(save_label='Filtrar')) ) diff --git a/sapl/templates/materia/adicionar_varias_autorias.html b/sapl/templates/materia/adicionar_varias_autorias.html index 34bed6d42..90b4302f5 100644 --- a/sapl/templates/materia/adicionar_varias_autorias.html +++ b/sapl/templates/materia/adicionar_varias_autorias.html @@ -16,39 +16,28 @@ {% endif %} {% endblock buttons %} - {% if not filter_url %} - {% crispy filter.form %} - {% endif %} + {% crispy filter.form %} - {% if filter_url %} - - - - - {% if filter.qs|length > 1 %} -

{% blocktrans with filter.qs|length as total_autores %}Pesquisa concluída com sucesso! Foram encontrados {{total_autores}} autores.{% endblocktrans %}

- {% elif filter.qs|length == 1 %} -

{% trans 'Pesquisa concluída com sucesso! Foi encontrado 1 autor.'%}

- {% else %} - - {% endif %} +

{% trans "Autor" %}

Nenhum autor encontrado.

+ + + +
+ + {% csrf_token %} + {% for m in filter.qs %} + + + + {% endfor %} - - {% csrf_token %} - {% for m in filter.qs %} - - - - {% endfor %} - -

{% trans "Autor" %}

+ +    + {{m}}
+
- -    - {{m}}
-
-
- -
- - {% endif %} + +
+ +
+ {% endblock detail_content %}