mirror of https://github.com/interlegis/sapl.git
11 changed files with 244 additions and 10 deletions
@ -0,0 +1,35 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.11.20 on 2019-09-10 14:09 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.conf import settings |
||||
|
from django.db import migrations, models |
||||
|
import django.db.models.deletion |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL), |
||||
|
('base', '0038_auto_20190604_1109'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.CreateModel( |
||||
|
name='AutorUser', |
||||
|
fields=[ |
||||
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), |
||||
|
('autor', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='base.Autor', verbose_name='Autor')), |
||||
|
('user', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL, verbose_name='Usuário')), |
||||
|
], |
||||
|
options={ |
||||
|
'verbose_name': 'Autor - Usuário', |
||||
|
'verbose_name_plural': 'Autores - Usuários', |
||||
|
'ordering': ('autor__nome',), |
||||
|
}, |
||||
|
), |
||||
|
migrations.AlterUniqueTogether( |
||||
|
name='autoruser', |
||||
|
unique_together=set([('autor', 'user')]), |
||||
|
), |
||||
|
] |
||||
@ -0,0 +1,24 @@ |
|||||
|
# -*- coding: utf-8 -*- |
||||
|
# Generated by Django 1.11.20 on 2019-09-10 14:13 |
||||
|
from __future__ import unicode_literals |
||||
|
|
||||
|
from django.db import migrations |
||||
|
from sapl.utils import get_settings_auth_user_model |
||||
|
|
||||
|
def migra_autores_usuarios(apps, schema_editor): |
||||
|
Autor = apps.get_model('base', 'Autor') |
||||
|
AutorUser = apps.get_model('base', 'AutorUser') |
||||
|
|
||||
|
for a in Autor.objects.filter(user__isnull=False): |
||||
|
AutorUser.objects.create(autor=a, user=a.user) |
||||
|
|
||||
|
|
||||
|
class Migration(migrations.Migration): |
||||
|
|
||||
|
dependencies = [ |
||||
|
('base', '0039_auto_20190910_1109'), |
||||
|
] |
||||
|
|
||||
|
operations = [ |
||||
|
migrations.RunPython(migra_autores_usuarios) |
||||
|
] |
||||
@ -0,0 +1,41 @@ |
|||||
|
{% extends "crud/detail.html" %} |
||||
|
{% load i18n %} |
||||
|
|
||||
|
{% block sub_actions %} |
||||
|
{{block.super}} |
||||
|
<div class="actions btn-group btn-group-sm" role="group"> |
||||
|
<a href="{% url 'sapl.base:vincular-usuario-autor' object.pk %}" class="btn btn-outline-primary">Vincular Usuário</a> |
||||
|
</div> |
||||
|
{% endblock sub_actions %} |
||||
|
|
||||
|
{% block detail_content %} |
||||
|
{{block.super}} |
||||
|
{% if autor_user %} |
||||
|
<h2 class="legend">Usuários vinculados</h2> |
||||
|
<table class="table table-striped table-hover table-link-ordering"> |
||||
|
<thead> |
||||
|
<tr> |
||||
|
<th>Usuário</th> |
||||
|
</tr> |
||||
|
</thead> |
||||
|
<tbody> |
||||
|
{% for au in autor_user %} |
||||
|
<tr> |
||||
|
<td><a href="{% url 'sapl.base:user_edit' au.user.pk %}">{{au.user}}</a></td> |
||||
|
</tr> |
||||
|
{% endfor %} |
||||
|
</tbody> |
||||
|
</table> |
||||
|
{% endif %} |
||||
|
{% endblock %} |
||||
|
|
||||
|
{% block extra_js %} |
||||
|
|
||||
|
<script type="text/javascript"> |
||||
|
|
||||
|
$(document).ready(function(){ |
||||
|
}); |
||||
|
|
||||
|
</script> |
||||
|
|
||||
|
{% endblock %} |
||||
@ -0,0 +1,13 @@ |
|||||
|
{% extends "crud/form.html" %} |
||||
|
{% load i18n %} |
||||
|
|
||||
|
{% block extra_js %} |
||||
|
|
||||
|
<script type="text/javascript"> |
||||
|
|
||||
|
$(document).ready(function(){ |
||||
|
}); |
||||
|
|
||||
|
</script> |
||||
|
|
||||
|
{% endblock %} |
||||
Loading…
Reference in new issue