Browse Source

customize unique message for Vide add

pull/98/head
LeandroRoberto 9 years ago
parent
commit
43f69f1a12
  1. 21
      compilacao/forms.py
  2. 3
      compilacao/models.py
  3. 6
      static/styles/compilacao.scss

21
compilacao/forms.py

@ -1,6 +1,7 @@
from crispy_forms.helper import FormHelper
from crispy_forms.layout import HTML, Button, Column, Div, Field, Layout, Row
from django import forms
from django.core.exceptions import NON_FIELD_ERRORS
from django.forms.models import ModelForm
from django.utils.translation import ugettext_lazy as _
@ -14,7 +15,7 @@ class UpLoadImportFileForm(forms.Form):
required=True,
label=_('Arquivo formato ODF para Importanção'))
error_messages = {
nota_error_messages = {
'required': _('Este campo é obrigatório'),
'invalid': _('URL inválida.')
}
@ -37,11 +38,11 @@ class NotaForm(ModelForm):
texto = forms.CharField(
label='',
widget=forms.Textarea,
error_messages=error_messages)
error_messages=nota_error_messages)
url_externa = forms.URLField(
label='',
required=False,
error_messages=error_messages)
error_messages=nota_error_messages)
publicidade = forms.ChoiceField(
required=True,
label=_('Publicidade'),
@ -60,7 +61,7 @@ class NotaForm(ModelForm):
required=True,
widget=forms.DateInput(
format='%d/%m/%Y'),
error_messages=error_messages
error_messages=nota_error_messages
)
efetividade = forms.DateField(
label=_('Efetividade'),
@ -68,7 +69,7 @@ class NotaForm(ModelForm):
required=True,
widget=forms.DateInput(
format='%d/%m/%Y'),
error_messages=error_messages)
error_messages=nota_error_messages)
dispositivo = forms.ModelChoiceField(queryset=Dispositivo.objects.all(),
widget=forms.HiddenInput())
pk = forms.IntegerField(widget=forms.HiddenInput(),
@ -137,12 +138,12 @@ class VideForm(ModelForm):
texto = forms.CharField(
label='',
widget=forms.Textarea,
error_messages=error_messages,
required=False)
tipo = forms.ModelChoiceField(
label=_('Tipo do Vide'),
queryset=TipoVide.objects.all(),
required=True)
required=True,
error_messages=nota_error_messages)
busca_dispositivo = forms.CharField(
label=_('Buscar Dispositivo a Referenciar'),
@ -157,6 +158,12 @@ class VideForm(ModelForm):
'texto',
'tipo',
'pk']
error_messages = {
NON_FIELD_ERRORS: {
'unique_together':
"Ja existe um Vide deste tipo para o Dispositivo Referido ",
}
}
def __init__(self, *args, **kwargs):

3
compilacao/models.py

@ -1,6 +1,7 @@
from datetime import datetime
from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models import F, Q
from django.db.models.aggregates import Max
@ -1048,7 +1049,7 @@ class Vide(TimestampedMixin):
class Meta:
verbose_name = _('Vide')
verbose_name_plural = _('Vides')
unique_together = ['dispositivo_base', 'dispositivo_ref']
unique_together = ['dispositivo_base', 'dispositivo_ref', 'tipo']
def __str__(self):
return _('Vide %s') % self.texto

6
static/styles/compilacao.scss

@ -447,7 +447,7 @@ a:link:after, a:visited:after {
}
.title_form {
font-size: 2.5em;
padding: 0.5em 0.3em 0.2em;
padding: 0.5em 0.3em 0.3em;
background: #e5e5e5;
color: #777;
margin-bottom: 0.4em;
@ -461,6 +461,9 @@ a:link:after, a:visited:after {
border: 0px;
outline:0px;
}
.alert-box {
margin-bottom: 0;
}
.row:first-of-type {
margin-top: 1em;
display: inline-block;
@ -1173,6 +1176,7 @@ a:link:after, a:visited:after {
cursor: pointer;
opacity: 0.7;
transform: rotate(45deg);
z-index: 98;
.icon-close{
background: #FFF;

Loading…
Cancel
Save