diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-01-05 17:18:33 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2021-02-28 12:15:23 +0100 |
commit | 63a02ec952275c967ebd624ec07d6674a93aee81 (patch) | |
tree | 5e1a23b6caa2be94919010e68c130086231c8d6b /ishtar_common/forms_common.py | |
parent | 605b06762736e2dff6f6aa8e812862115bcfb0cf (diff) | |
download | Ishtar-63a02ec952275c967ebd624ec07d6674a93aee81.tar.bz2 Ishtar-63a02ec952275c967ebd624ec07d6674a93aee81.zip |
Document: add publishing year
Diffstat (limited to 'ishtar_common/forms_common.py')
-rw-r--r-- | ishtar_common/forms_common.py | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py index 127791dd1..e15a4ef23 100644 --- a/ishtar_common/forms_common.py +++ b/ishtar_common/forms_common.py @@ -35,6 +35,7 @@ from django.core import validators from django.core.cache import cache from django.core.exceptions import ObjectDoesNotExist from django.core.files import File +from django.core.validators import MaxValueValidator, MinValueValidator from django.forms.formsets import formset_factory from django.forms.models import BaseModelFormSet, BaseFormSet from django.shortcuts import reverse @@ -1266,6 +1267,10 @@ class AddDocumentTagForm(AddGenericForm): form_label = _("Document tag") +def max_value_current_year(value): + return MaxValueValidator(datetime.date.today().year)(value) + + class DocumentForm(forms.ModelForm, CustomForm, ManageOldType): form_label = _("Documentation") form_admin_name = _("Document - General") @@ -1319,6 +1324,10 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType): tips=models.get_publisher_label, associated_model=models.Organization), validators=[models.valid_id(models.Organization)], required=False) + publishing_year = forms.IntegerField( + label=_("Year of publication"), + validators=[MinValueValidator(1000), max_value_current_year], + required=False) licenses = widgets.Select2MultipleField( label=_("Licenses"), required=False, model=models.LicenseType) tags = widgets.Select2MultipleField( @@ -1401,7 +1410,8 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType): 'image', 'associated_file', 'associated_url', 'tags', 'authors', 'receipt_date', 'receipt_date_in_documentation', 'creation_date', - 'publisher', 'language', 'isbn', 'issn', 'licenses', + 'publisher', 'publishing_year', + 'language', 'isbn', 'issn', 'licenses', 'source', 'source_free_input', 'source_page_range', 'container_id', "container_ref_id", 'comment', 'description', 'additional_information', 'duplicate' @@ -1626,6 +1636,7 @@ class DocumentSelect(HistorySelect): tips=models.get_publisher_label, associated_model=models.Organization), validators=[models.valid_id(models.Organization)]) + publishing_year = forms.IntegerField(label=_("Year of publication")) language = forms.ChoiceField(label=_("Language"), choices=[]) isbn = forms.CharField(label=_("ISBN")) issn = forms.CharField(label=_("ISSN")) |