Browse Source

Altera detalhes na relacao Autor e AuthUser

pull/534/head
Eduardo Calil 9 years ago
parent
commit
71c2600989
  1. 14
      sapl/materia/forms.py
  2. 22
      sapl/materia/migrations/0046_auto_20160825_1833.py
  3. 4
      sapl/materia/models.py

14
sapl/materia/forms.py

@ -669,10 +669,16 @@ class AutorForm(ModelForm):
autor = super(AutorForm, self).save(commit)
u = User.objects.get_or_create(
username=autor.username,
email=autor.email)
u = u[0]
try:
u = User.objects.get(
username=autor.username,
email=autor.email)
except ObjectDoesNotExist:
msg = _('Este nome de usuario não está cadastrado. ' +
'Por favor, cadastre-o no Administrador do ' +
'Sistema antes de adicioná-lo como Autor')
raise ValidationError(msg)
u.set_password(self.cleaned_data['senha'])
u.is_active = False
u.save()

22
sapl/materia/migrations/0046_auto_20160825_1833.py

@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.7 on 2016-08-25 21:33
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 = [
('materia', '0045_auto_20160823_1658'),
]
operations = [
migrations.AlterField(
model_name='autor',
name='user',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL),
),
]

4
sapl/materia/models.py

@ -208,7 +208,9 @@ class TipoAutor(models.Model):
class Autor(models.Model):
user = models.ForeignKey(User)
user = models.ForeignKey(User,
blank=True,
null=True)
partido = models.ForeignKey(Partido, blank=True, null=True)
comissao = models.ForeignKey(Comissao, blank=True, null=True)
parlamentar = models.ForeignKey(Parlamentar, blank=True, null=True)

Loading…
Cancel
Save