diff --git a/sapl/base/forms.py b/sapl/base/forms.py index f8667a5c4..9abd4ee47 100644 --- a/sapl/base/forms.py +++ b/sapl/base/forms.py @@ -6,10 +6,10 @@ from crispy_forms.bootstrap import FieldWithButtons, InlineRadios, StrictButton, from crispy_forms.layout import HTML, Button, Div, Field, Fieldset, Layout, Row, Submit from django import forms from django.conf import settings -from django.contrib.auth import get_user_model +from django.contrib.auth import get_user_model, password_validation from django.contrib.auth.forms import (AuthenticationForm, PasswordResetForm, SetPasswordForm) -from django.contrib.auth.models import Group, User +from django.contrib.auth.models import Group, User, Permission from django.core.exceptions import ValidationError from django.db import models, transaction from django.db.models import Q @@ -57,206 +57,160 @@ STATUS_USER_CHOICE = [ ] -def get_roles(): - roles = [(g.id, g.name) for g in Group.objects.all().order_by('name') - if g.name != 'Votante'] - return roles +class UserAdminForm(ModelForm): + is_active = forms.TypedChoiceField(label=_('Usuário Ativo'), + choices=YES_NO_CHOICES, + coerce=lambda x: x == 'True') -class UsuarioCreateForm(ModelForm): - logger = logging.getLogger(__name__) - firstname = forms.CharField( - required=True, - label="Nome", - max_length=30 - ) - lastname = forms.CharField( - required=True, - label="Sobrenome", - max_length=30 - ) - password1 = forms.CharField( - required=True, - widget=forms.PasswordInput, - label='Senha', - min_length=6, - max_length=128 - ) - password2 = forms.CharField( - required=True, - widget=forms.PasswordInput, - label='Confirmar senha', - min_length=6, - max_length=128 - ) - user_active = forms.ChoiceField( - required=True, - choices=YES_NO_CHOICES, - label="Usuário ativo?", - initial='True' - ) - roles = forms.MultipleChoiceField( - required=True, - widget=forms.CheckboxSelectMultiple(), - choices=get_roles - ) - - class Meta: - model = get_user_model() - fields = [ - get_user_model().USERNAME_FIELD, 'firstname', 'lastname', - 'password1', 'password2', 'user_active', 'roles' - ] + (['email'] - if get_user_model().USERNAME_FIELD != 'email' else []) - - def clean(self): - super().clean() - - if not self.is_valid(): - return self.cleaned_data - - data = self.cleaned_data - if data['password1'] != data['password2']: - self.logger.warning( - 'Erro de validação. Senhas informadas são diferentes.') - raise ValidationError('Senhas informadas são diferentes') - - return data - - def __init__(self, *args, **kwargs): - - super().__init__(*args, **kwargs) - - row0 = to_row([('username', 12)]) - - row1 = to_row([('firstname', 6), - ('lastname', 6)]) - - row2 = to_row([('email', 6), - ('user_active', 6)]) - row3 = to_row( - [('password1', 6), - ('password2', 6)]) - - self.helper = SaplFormHelper() - self.helper.layout = Layout( - row0, - row1, - row3, - row2, - 'roles', - form_actions(label='Confirmar')) - - -class UsuarioFilterSet(django_filters.FilterSet): - - username = django_filters.CharFilter( - label=_('Nome de Usuário'), - lookup_expr='icontains') - - class Meta: - model = User - fields = ['username'] - - def __init__(self, *args, **kwargs): - super(UsuarioFilterSet, self).__init__(*args, **kwargs) - - row0 = to_row([('username', 12)]) - - self.form.helper = SaplFormHelper() - self.form.helper.form_method = 'GET' - self.form.helper.layout = Layout( - Fieldset(_('Pesquisa de Usuário'), - row0, - form_actions(label='Pesquisar')) - ) + new_password1 = forms.CharField( + label='Nova senha', + max_length=50, + strip=False, + required=False, + widget=forms.PasswordInput(), + help_text='Deixe os campos em branco para não fazer alteração de senha') + new_password2 = forms.CharField( + label='Confirmar senha', + max_length=50, + strip=False, + required=False, + widget=forms.PasswordInput(), + help_text='Deixe os campos em branco para não fazer alteração de senha') -class UsuarioEditForm(ModelForm): - logger = logging.getLogger(__name__) - # ROLES = [(g.id, g.name) for g in Group.objects.all().order_by('name')] - ROLES = [] + autor = forms.ModelChoiceField( + label=_('Operador de Autor'), + queryset=Autor.objects.all(), + required=False) token = forms.CharField( required=False, label="Token", max_length=40, widget=forms.TextInput(attrs={'readonly': 'readonly'})) - first_name = forms.CharField( - required=False, - label="Nome", - max_length=30) - last_name = forms.CharField( - required=False, - label="Sobrenome", - max_length=30) - password1 = forms.CharField( - required=False, - widget=forms.PasswordInput, - label='Senha') - password2 = forms.CharField( - required=False, widget=forms.PasswordInput, - label='Confirmar senha') - user_active = forms.ChoiceField( - choices=YES_NO_CHOICES, - required=True, - label="Usuário ativo?", - initial='True') - roles = forms.MultipleChoiceField( - required=True, - widget=forms.CheckboxSelectMultiple(), - choices=get_roles) class Meta: model = get_user_model() fields = [ get_user_model().USERNAME_FIELD, - "token", - "first_name", - "last_name", - 'password1', - 'password2', - 'user_active', - 'roles'] + 'first_name', + 'last_name', + 'is_active', + + 'token', + + 'new_password1', + 'new_password2', + 'groups', + 'user_permissions' + ] if get_user_model().USERNAME_FIELD != 'email': fields.extend(['email']) def __init__(self, *args, **kwargs): - super(UsuarioEditForm, self).__init__(*args, **kwargs) - rows = to_row(( - ('first_name', 6), - ('last_name', 6), - ('email', 6), - ('user_active', 6), - ('password1', 6), - ('password2', 6), - ('roles', 12))) + self.user_session = kwargs.pop('user_session', None) + self.granular = kwargs.pop('granular', None) + + row_pwd = to_row( + [ + ('username', 4), + ('email', 6), + ('is_active', 2), + ('first_name', 6), + ('last_name', 6), + ('new_password1', 3), + ('new_password2', 3), + ( + FieldWithButtons( + 'token', + StrictButton( + 'Renovar', + id="renovar-token", + css_class="btn-outline-primary") + ), + 6 + ), + ('groups', 12), + + ] + ([('user_permissions', 12)] if not self.granular is None else []) + ) self.helper = SaplFormHelper() - self.helper.layout = Layout( - 'username', - FieldWithButtons('token', StrictButton( - 'Renovar', id="renovar-token", css_class="btn-outline-primary")), - rows, - form_actions( - more=[ - HTML("Cancelar")], - label='Salvar Alterações')) + self.helper.layout = SaplFormLayout(row_pwd) + super(UserAdminForm, self).__init__(*args, **kwargs) + + if self.instance.pk: + + self.fields['token'].initial = self.instance.auth_token.key + + self.fields[ + 'groups'].widget = forms.CheckboxSelectMultiple() + self.fields['groups'].choices = [ + (g.id, g) for g in self.instance.groups.exclude(name='Votante').order_by('name') + ] + [ + (g.id, g) for g in Group.objects.exclude( + user=self.instance).exclude(name='Votante').order_by('name') + ] + + self.fields[ + 'user_permissions'].widget = forms.CheckboxSelectMultiple() + + if not self.granular is None: + self.fields['user_permissions'].choices = [ + (p.id, p) for p in self.instance.user_permissions.all( + ).order_by('content_type__app_label', + 'content_type__model', + 'codename') + ] + [ + (p.id, p) for p in Permission.objects.filter( + content_type__app_label__in=list( + map(lambda x: x.split('.')[-1], settings.SAPL_APPS)) + ).exclude( + user=self.instance + ).order_by('content_type__app_label', + 'content_type__model', + 'codename') + ] + + # self.fields['user_permissions'].queryset = self.fields[ + # 'user_permissions'].queryset.all().order_by('name') + + def save(self, commit=True): + if self.cleaned_data['new_password1']: + self.instance.set_password(self.cleaned_data['new_password1']) + + votante = None + if self.instance.id: + inst_old = get_user_model().objects.get(pk=self.instance.pk) + votante = inst_old.groups.filter(name='Votante').first() + + inst_new = super().save(commit) + + if votante: + inst_new.groups.add(votante) + + return inst_new def clean(self): - super().clean() - if not self.is_valid(): - return self.cleaned_data + data = super().clean() - data = self.cleaned_data - if data['password1'] and data['password1'] != data['password2']: - self.logger.warning( - "Erro de validação. Senhas informadas são diferentes.") - raise ValidationError('Senhas informadas são diferentes') + if self.errors: + return data + + new_password1 = data.get('new_password1', '') + new_password2 = data.get('new_password2', '') + if new_password1 != new_password2: + raise forms.ValidationError( + _("As senhas informadas são diferentes"), + ) + else: + if new_password1 and new_password2: + password_validation.validate_password( + new_password2, self.instance) return data diff --git a/sapl/base/urls.py b/sapl/base/urls.py index d311acbb5..992b0d05b 100644 --- a/sapl/base/urls.py +++ b/sapl/base/urls.py @@ -3,22 +3,19 @@ import os from django.conf.urls import include, url from django.contrib.auth import views from django.contrib.auth.decorators import permission_required -from django.contrib.auth.views import (PasswordResetView, PasswordResetCompleteView, PasswordResetConfirmView, - PasswordResetDoneView) -from django.urls.base import reverse_lazy from django.views.generic.base import RedirectView, TemplateView -from sapl.base.views import (AutorCrud, ConfirmarEmailView, TipoAutorCrud, get_estatistica, DetailUsuarioView, +from sapl.base.views import (AutorCrud, ConfirmarEmailView, TipoAutorCrud, get_estatistica, PesquisarAutorView, RecuperarSenhaEmailView, RecuperarSenhaFinalizadoView, RecuperarSenhaConfirmaView, RecuperarSenhaCompletoView, RelatorioMateriaAnoAssuntoView, - IndexView) -from sapl.settings import EMAIL_SEND_USER, MEDIA_URL, LOGOUT_REDIRECT_URL + IndexView, UserCrud) +from sapl.settings import MEDIA_URL, LOGOUT_REDIRECT_URL from .apps import AppConfig -from .forms import LoginForm, NovaSenhaForm, RecuperarSenhaForm -from .views import (AlterarSenha, AppConfigCrud, CasaLegislativaCrud, CreateUsuarioView, DeleteUsuarioView, - EditUsuarioView, HelpTopicView, PesquisarUsuarioView, LogotipoView, RelatorioAtasView, +from .forms import LoginForm +from .views import (AlterarSenha, AppConfigCrud, CasaLegislativaCrud, + HelpTopicView, LogotipoView, RelatorioAtasView, RelatorioAudienciaView, RelatorioDataFimPrazoTramitacaoView, RelatorioHistoricoTramitacaoView, RelatorioMateriasPorAnoAutorTipoView, RelatorioMateriasPorAutorView, RelatorioMateriasTramitacaoView, RelatorioPresencaSessaoView, RelatorioReuniaoView, SaplSearchView, @@ -35,15 +32,8 @@ from .views import (AlterarSenha, AppConfigCrud, CasaLegislativaCrud, CreateUsua app_name = AppConfig.name admin_user = [ - url(r'^sistema/usuario/$', PesquisarUsuarioView.as_view(), name='usuario'), - url(r'^sistema/usuario/create$', - CreateUsuarioView.as_view(), name='user_create'), - url(r'^sistema/usuario/(?P\d+)$', - DetailUsuarioView.as_view(), name='user_detail'), - url(r'^sistema/usuario/(?P\d+)/edit$', - EditUsuarioView.as_view(), name='user_edit'), - url(r'^sistema/usuario/(?P\d+)/delete$', - DeleteUsuarioView.as_view(), name='user_delete') + url(r'^sistema/usuario/', include(UserCrud.get_urls())), + ] alterar_senha = [ diff --git a/sapl/base/views.py b/sapl/base/views.py index a2f1613a6..a85d8370f 100644 --- a/sapl/base/views.py +++ b/sapl/base/views.py @@ -36,13 +36,14 @@ from rest_framework.authtoken.models import Token from sapl import settings from sapl.audiencia.models import AudienciaPublica, TipoAudienciaPublica from sapl.base.forms import (AutorForm, AutorFormForAdmin, TipoAutorForm, AutorFilterSet, RecuperarSenhaForm, - NovaSenhaForm) + NovaSenhaForm, UserAdminForm) from sapl.base.models import Autor, TipoAutor from sapl.comissoes.models import Comissao, Reuniao -from sapl.crud.base import CrudAux, make_pagination +from sapl.crud.base import CrudAux, make_pagination, Crud,\ + ListWithSearchForm from sapl.materia.models import (Anexada, Autoria, DocumentoAcessorio, MateriaEmTramitacao, MateriaLegislativa, Proposicao, StatusTramitacao, TipoDocumento, TipoMateriaLegislativa, UnidadeTramitacao, - MateriaAssunto, Tramitacao) + MateriaAssunto) from sapl.norma.models import NormaJuridica, TipoNormaJuridica from sapl.parlamentares.models import ( Filiacao, Legislatura, Mandato, Parlamentar, SessaoLegislativa) @@ -66,9 +67,9 @@ from .forms import (AlterarSenhaForm, CasaLegislativaForm, ConfiguracoesAppForm, RelatorioAudienciaFilterSet, RelatorioDataFimPrazoTramitacaoFilterSet, RelatorioHistoricoTramitacaoFilterSet, RelatorioMateriasPorAnoAutorTipoFilterSet, RelatorioMateriasPorAutorFilterSet, RelatorioMateriasTramitacaoFilterSet, - RelatorioPresencaSessaoFilterSet, RelatorioReuniaoFilterSet, UsuarioCreateForm, UsuarioEditForm, + RelatorioPresencaSessaoFilterSet, RelatorioReuniaoFilterSet, RelatorioNormasMesFilterSet, RelatorioNormasVigenciaFilterSet, EstatisticasAcessoNormasForm, - UsuarioFilterSet, RelatorioHistoricoTramitacaoAdmFilterSet, RelatorioDocumentosAcessoriosFilterSet, + RelatorioHistoricoTramitacaoAdmFilterSet, RelatorioDocumentosAcessoriosFilterSet, RelatorioNormasPorAutorFilterSet) from .models import AppConfig, CasaLegislativa @@ -1936,208 +1937,118 @@ class ListarProtocolosDuplicadosView(PermissionRequiredMixin, ListView): return context -class PesquisarUsuarioView(PermissionRequiredMixin, FilterView): +class UserCrud(Crud): model = get_user_model() - filterset_class = UsuarioFilterSet - permission_required = ('base.list_appconfig',) - paginate_by = 10 - - def get_filterset_kwargs(self, filterset_class): - super(PesquisarUsuarioView, - self).get_filterset_kwargs(filterset_class) - - kwargs = {'data': self.request.GET or None} - - qs = self.get_queryset().order_by('username').distinct() - - kwargs.update({ - 'queryset': qs, - }) - return kwargs - - def get_context_data(self, **kwargs): - context = super(PesquisarUsuarioView, self).get_context_data(**kwargs) - - paginator = context['paginator'] - page_obj = context['page_obj'] - - context.update({ - "page_range": make_pagination(page_obj.number, paginator.num_pages), - "NO_ENTRIES_MSG": "Nenhum usuário encontrado!", - "title": _("Usuários") - }) - - return context - - def get(self, request, *args, **kwargs): - super(PesquisarUsuarioView, self).get(request) - - data = self.filterset.data - url = '' - if data: - url = "&" + str(self.request.META['QUERY_STRING']) - if url.startswith("&page"): - ponto_comeco = url.find('username=') - 1 - url = url[ponto_comeco:] - - context = self.get_context_data(filter=self.filterset, - object_list=self.object_list, - filter_url=url, - numero_res=len(self.object_list) - ) - - context['show_results'] = show_results_filter_set( - self.request.GET.copy()) - - return self.render_to_response(context) + class BaseMixin(Crud.BaseMixin): + list_field_names = [ + 'usuario', 'groups', 'is_active' + ] -class DetailUsuarioView(PermissionRequiredMixin, DetailView): - model = get_user_model() - template_name = "base/usuario_detail.html" - permission_required = ('base.detail_appconfig',) - - def get_context_data(self, **kwargs): - context = super().get_context_data(**kwargs) - user = get_user_model().objects.get(id=self.kwargs['pk']) - - context.update({ - "user": user, - "token": Token.objects.filter(user=user)[0], - "roles": [ - { - "checked": "checked" if g in user.groups.all() else "unchecked", - "group": g.name - } for g in Group.objects.all().order_by("name") if g.name != 'Votante'] - }) + def resolve_url(self, suffix, args=None): + return reverse('sapl.base:%s' % self.url_name(suffix), + args=args) - return context - - -class CreateUsuarioView(PermissionRequiredMixin, CreateView): - model = get_user_model() - form_class = UsuarioCreateForm - success_message = 'Usuário criado com sucesso!' - fail_message = 'Usuário não criado!' - permission_required = ('base.add_appconfig',) + def get_layout(self): + return super().get_layout( + 'base/layouts.yaml' + ) - def get_success_url(self, pk): - return reverse('sapl.base:user_detail', kwargs={"pk": pk}) + def get_context_object_name(self, *args, **kwargs): + return None - def form_valid(self, form): - data = form.cleaned_data - - new_user = get_user_model().objects.create( - username=data['username'], - email=data['email'], - first_name=data['firstname'], - last_name=data['lastname'], - is_superuser=False, - is_staff=False - ) - new_user.set_password(data['password1']) - new_user.save() + class CreateView(Crud.CreateView): + form_class = UserAdminForm - groups = Group.objects.filter(id__in=data['roles']) - for g in groups: - g.user_set.add(new_user) + class UpdateView(Crud.UpdateView): + form_class = UserAdminForm + layout_key = None - messages.success(self.request, self.success_message) - return HttpResponseRedirect(self.get_success_url(new_user.pk)) + def get_form_kwargs(self): + kwargs = Crud.UpdateView.get_form_kwargs(self) + kwargs['user_session'] = self.request.user + granular = self.request.GET.get('granular', None) + if not granular is None: + kwargs['granular'] = granular + return kwargs + + class DetailView(Crud.DetailView): + layout_key = 'UserDetail' + + def hook_usuario(self, obj): + return 'Usuário', '{}
{}'.format( + obj.get_full_name() or '...', + obj.email + ) - def form_invalid(self, form): - messages.error(self.request, self.fail_message) - return super().form_invalid(form) + def hook_auth_token(self, obj): + return 'Token', str(obj.auth_token) + def hook_username(self, obj): + return 'username', obj.username -class DeleteUsuarioView(PermissionRequiredMixin, DeleteView): - model = get_user_model() - template_name = "crud/confirm_delete.html" - permission_required = ('base.delete_appconfig',) - success_url = reverse_lazy('sapl.base:usuario') - success_message = "Usuário removido com sucesso!" + def get_context_data(self, **kwargs): + context = Crud.DetailView.get_context_data(self, **kwargs) + context['title'] = '{} ({})
{}'.format( + self.object.get_full_name() or '...', + self.object.username, + self.object.email + ) + return context - def delete(self, request, *args, **kwargs): - try: - super(DeleteUsuarioView, self).delete(request, *args, **kwargs) - except ProtectedError as exception: - error_url = reverse_lazy('sapl.base:user_delete', kwargs={ - 'pk': self.kwargs['pk']}) - error_message = "O usuário não pode ser removido, pois é referenciado por:
    " - - for e in exception.protected_objects: - error_message += '
  • {} - {}
  • '.format( - e._meta.verbose_name, e + @property + def extras_url(self): + btns = [ + ( + '{}?granular'.format(reverse('sapl.base:user_update', + kwargs={'pk': self.object.pk})), + 'btn-outline-primary', + _('Edição granular') ) - error_message += '
' - messages.error(self.request, error_message) - return HttpResponseRedirect(error_url) + ] - messages.success(self.request, self.success_message) - return HttpResponseRedirect(self.success_url) + return btns - @property - def cancel_url(self): - return reverse('sapl.base:user_edit', - kwargs={'pk': self.kwargs['pk']}) + class ListView(Crud.ListView): + form_search_class = ListWithSearchForm + ordered_list = None + paginate_by = 300 + def get_context_data(self, **kwargs): + context = Crud.ListView.get_context_data(self, **kwargs) + context['subnav_template_name'] = None + return context -class EditUsuarioView(PermissionRequiredMixin, UpdateView): - model = get_user_model() - form_class = UsuarioEditForm - template_name = "base/usuario_edit.html" - success_message = 'Usuário editado com sucesso!' - permission_required = ('base.change_appconfig',) - - def get_success_url(self): - return reverse('sapl.base:user_detail', kwargs={"pk": self.kwargs['pk']}) - - def get_initial(self): - initial = super().get_initial() - - user = get_user_model().objects.get(id=self.kwargs['pk']) - roles = [str(g.id) for g in user.groups.all()] - - initial.update({ - "token": Token.objects.filter(user=user)[0], - "first_name": user.first_name, - "last_name": user.last_name, - "roles": roles, - "user_active": user.is_active - }) - - return initial - - def form_valid(self, form): - - user = form.save(commit=False) - data = form.cleaned_data - - if 'first_name' in data and data['first_name'] != user.first_name: - user.first_name = data['first_name'] - - if 'last_name' in data and data['last_name'] != user.last_name: - user.last_name = data['last_name'] + def hook_header_usuario(self, *args, **kwargs): + return 'Usuário' - if data['password1']: - user.set_password(data['password1']) + def hook_header_groups(self, *args, **kwargs): + return 'Grupos' - if data['user_active'] == 'True' and not user.is_active: - user.is_active = True - elif data['user_active'] == 'False' and user.is_active: - user.is_active = False + def hook_header_active(self, *args, **kwargs): + return 'is_active' - user.save() + def hook_usuario(self, *args, **kwargs): + return '{} ({})
{}'.format( + args[0].get_full_name() or '...', + args[0].username, + args[0].email + ), args[2] - for g in user.groups.all().exclude(name='Votante'): - g.user_set.remove(user) + def get_queryset(self): + qs = self.model.objects.all() + q_param = self.request.GET.get('q', '') + if q_param: + q = Q(first_name__icontains=q_param) + q |= Q(last_name__icontains=q_param) + q |= Q(email__icontains=q_param) + q |= Q(username__icontains=q_param) + qs = qs.filter(q) - groups = Group.objects.filter(id__in=data['roles']) - for g in groups: - g.user_set.add(user) + return qs - messages.success(self.request, self.success_message) - return super(EditUsuarioView, self).form_valid(form) + def dispatch(self, request, *args, **kwargs): + return Crud.ListView.dispatch(self, request, *args, **kwargs) class CasaLegislativaCrud(CrudAux): diff --git a/sapl/crud/base.py b/sapl/crud/base.py index 008266f2f..389161f12 100644 --- a/sapl/crud/base.py +++ b/sapl/crud/base.py @@ -157,7 +157,7 @@ class ListWithSearchForm(forms.Form): FieldWithButtons( Field('q', placeholder=_('Filtrar Lista'), - css_class='input-lg'), + css_class='form-control-lg'), StrictButton( _('Filtrar'), css_class='btn-outline-primary btn-lg', type='submit')) diff --git a/sapl/templates/auth/user_filter.html b/sapl/templates/auth/user_filter.html deleted file mode 100644 index 5426cab0b..000000000 --- a/sapl/templates/auth/user_filter.html +++ /dev/null @@ -1,51 +0,0 @@ -{% extends "crud/list.html" %} -{% load i18n %} -{% load crispy_forms_tags staticfiles %} - -{% block base_content %} - {% if not show_results %} - {% crispy filter.form %} - {% trans 'Criar usuário' %} - {% endif %} - - {% if show_results %} - -

- {% if numero_res > 0 %} - {% if numero_res == 1 %} -

Foi encontrado {{ numero_res }} resultado

- {% else %} -

Foram encontrados {{ numero_res }} resultados

- {% endif %} - - - - - - - - - - {% for usuario in page_obj %} - - - - - - {% endfor %} - -
Nome de UsuárioNomeE-mail do Usuário
- {{ usuario.username }} - {{ usuario.first_name }} {{ usuario.last_name }}{{ usuario.email }}
- {% else %} -

{{ NO_ENTRIES_MSG }}

- {% endif %} - {% endif %} - -
- {% include 'paginacao.html'%} -


-{% endblock base_content %} diff --git a/sapl/templates/auth/user_form.html b/sapl/templates/auth/user_form.html index 709b16cfe..7279f67ff 100644 --- a/sapl/templates/auth/user_form.html +++ b/sapl/templates/auth/user_form.html @@ -1,19 +1,20 @@ -{% extends "base.html" %} -{% load i18n crispy_forms_tags %} +{% extends "crud/form.html" %} +{% load i18n %} -{% block base_content %} +{% block extra_js %} + -
- {% csrf_token %} - {% if object.pk %} - - {% trans 'Remover usuário' %} -

- {% endif %} - {% crispy form %} -
-


-{% endblock base_content %} \ No newline at end of file +{% endblock %} \ No newline at end of file diff --git a/sapl/templates/base/layouts.yaml b/sapl/templates/base/layouts.yaml index 143e351e0..6d4b69c9f 100644 --- a/sapl/templates/base/layouts.yaml +++ b/sapl/templates/base/layouts.yaml @@ -10,6 +10,13 @@ CasaLegislativa: - email - informacao_geral +UserDetail: + {% trans 'Usuário' %}: + - usuario username:3 is_active:2 + - auth_token + - groups + - user_permissions + AppConfig: {% trans 'Configurações Gerais' %}: diff --git a/sapl/templates/base/usuario_detail.html b/sapl/templates/base/usuario_detail.html deleted file mode 100644 index d4d1863fc..000000000 --- a/sapl/templates/base/usuario_detail.html +++ /dev/null @@ -1,57 +0,0 @@ -{% extends "crud/detail.html" %} -{% load i18n %} -{% load crispy_forms_tags cropping %} - -{% block base_content %} - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Usuário{{ user.username }}
Token{{ token }}
Nome{% firstof user.first_name "-" %}
Sobrenome{% firstof user.last_name "-" %}
Endereço de e-mail{% firstof user.email "-" %}
Usuário ativo?{% if user.is_active %} Sim {% else %} Não {% endif %}
Último acesso{{ user.last_login }}
Roles
    - {% for r in roles %} -
  • {{r.group }}
  • - {% endfor %} -
-
-{% endblock base_content %} diff --git a/sapl/templates/base/usuario_edit.html b/sapl/templates/base/usuario_edit.html deleted file mode 100644 index d922e68d4..000000000 --- a/sapl/templates/base/usuario_edit.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "crud/form.html" %} -{% load i18n %} - -{% block extra_js %} - - -{% endblock %} \ No newline at end of file diff --git a/sapl/templates/crud/detail.html b/sapl/templates/crud/detail.html index 7406b5e44..001784c34 100644 --- a/sapl/templates/crud/detail.html +++ b/sapl/templates/crud/detail.html @@ -3,11 +3,9 @@ {% block base_content %} -
+
{% block actions %} - {% block sub_actions %} -
{% if view.list_url %} {% trans 'Listar' %} {{view.verbose_name_plural}} @@ -23,10 +21,10 @@
{% if view.extras_url %}
- {% for href, css_class, text in view.extras_url %} - - {{text}} - + {% for href, css_class, text in view.extras_url %} + + {{text}} + {% endfor %}
{% endif %} @@ -35,7 +33,7 @@ {% block extra_actions %} {% endblock extra_actions %} -
+
{% block editions %} {% if view.update_url or view.delete_url %}
diff --git a/sapl/templates/crud/list.html b/sapl/templates/crud/list.html index 51f0f5223..44b394337 100644 --- a/sapl/templates/crud/list.html +++ b/sapl/templates/crud/list.html @@ -3,16 +3,14 @@ {% block base_content %} -
- -