summaryrefslogtreecommitdiff
path: root/ishtar_common/forms_common.py
diff options
context:
space:
mode:
Diffstat (limited to 'ishtar_common/forms_common.py')
-rw-r--r--ishtar_common/forms_common.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index dd55f95b4..486d25fcf 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -1425,6 +1425,15 @@ class AuthorForm(ManageOldType, NewItemForm):
initial=self.init_data.get('author_type'))
self.limit_fields()
+ def clean(self):
+ person_id = self.cleaned_data.get("person", None)
+ author_type_id = self.cleaned_data.get("author_type", None)
+ if not person_id or not author_type_id:
+ return self.cleaned_data
+ if models.Author.objects.filter(author_type_id=author_type_id,
+ person_id=person_id).count():
+ raise forms.ValidationError(_("This author already exist."))
+
def save(self, user):
dct = self.cleaned_data
dct['author_type'] = models.AuthorType.objects.get(