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 | |
| parent | 605b06762736e2dff6f6aa8e812862115bcfb0cf (diff) | |
| download | Ishtar-63a02ec952275c967ebd624ec07d6674a93aee81.tar.bz2 Ishtar-63a02ec952275c967ebd624ec07d6674a93aee81.zip | |
Document: add publishing year
| -rw-r--r-- | ishtar_common/forms_common.py | 13 | ||||
| -rw-r--r-- | ishtar_common/migrations/0209_auto_20210105_1712.py | 60 | ||||
| -rw-r--r-- | ishtar_common/models.py | 6 | ||||
| -rw-r--r-- | ishtar_common/templates/ishtar/sheet_document.html | 3 | 
4 files changed, 80 insertions, 2 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")) diff --git a/ishtar_common/migrations/0209_auto_20210105_1712.py b/ishtar_common/migrations/0209_auto_20210105_1712.py new file mode 100644 index 000000000..1e5cd54a1 --- /dev/null +++ b/ishtar_common/migrations/0209_auto_20210105_1712.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.27 on 2021-01-05 17:12 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + +    dependencies = [ +        ('ishtar_common', '0208_unaccent'), +    ] + +    operations = [ +        migrations.AddField( +            model_name='document', +            name='publishing_year', +            field=models.PositiveIntegerField(blank=True, null=True, verbose_name='Year of publication'), +        ), +        migrations.AlterField( +            model_name='ishtarsiteprofile', +            name='basefind_custom_index', +            field=models.TextField(blank=True, default='', help_text='Keys to be used to manage base find custom index. Separate keys with a semicolon.', verbose_name='Base find custom index key'), +        ), +        migrations.AlterField( +            model_name='ishtarsiteprofile', +            name='container_custom_index', +            field=models.TextField(blank=True, default='', help_text='Keys to be used to manage container custom index. Separate keys with a semicolon.', verbose_name='Container custom index key'), +        ), +        migrations.AlterField( +            model_name='ishtarsiteprofile', +            name='contextrecord_custom_index', +            field=models.TextField(blank=True, default='', help_text='Keys to be used to manage context record custom index. Separate keys with a semicolon.', verbose_name='Context record custom index key'), +        ), +        migrations.AlterField( +            model_name='ishtarsiteprofile', +            name='document_custom_index', +            field=models.TextField(blank=True, default='', help_text='Keys to be used to manage document custom index. Separate keys with a semicolon.', verbose_name='Document custom index key'), +        ), +        migrations.AlterField( +            model_name='ishtarsiteprofile', +            name='file_custom_index', +            field=models.TextField(blank=True, default='', help_text='Keys to be used to manage archaeological file custom index. Separate keys with a semicolon.', verbose_name='Archaeological file custom index key'), +        ), +        migrations.AlterField( +            model_name='ishtarsiteprofile', +            name='find_custom_index', +            field=models.TextField(blank=True, default='', help_text='Keys to be used to manage find custom index. Separate keys with a semicolon.', verbose_name='Find custom index key'), +        ), +        migrations.AlterField( +            model_name='ishtarsiteprofile', +            name='site_custom_index', +            field=models.TextField(blank=True, default='', help_text='Keys to be used to manage archaeological site custom index. Separate keys with a semicolon.', verbose_name='Archaeological site custom index key'), +        ), +        migrations.AlterField( +            model_name='ishtarsiteprofile', +            name='warehouse_custom_index', +            field=models.TextField(blank=True, default='', help_text='Keys to be used to manage warehouse custom index. Separate keys with a semicolon.', verbose_name='Warehouse custom index key'), +        ), +    ] diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 9adba889b..23416d406 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -2864,6 +2864,10 @@ class Document(BaseHistorizedItem, CompleteIdentifierItem, OwnPerms, ImageModel,              pgettext_lazy("key for text search", "publisher"),              'publisher__name__iexact'          ), +        'publishing_year': SearchAltName( +            pgettext_lazy("key for text search", "publishing-year"), +            'publishing_year' +        ),          'title': SearchAltName(              pgettext_lazy("key for text search", "title"),              'title__iexact' @@ -3097,6 +3101,8 @@ class Document(BaseHistorizedItem, CompleteIdentifierItem, OwnPerms, ImageModel,      publisher = models.ForeignKey(          Organization, verbose_name=_("Publisher"), blank=True, null=True,          related_name='publish') +    publishing_year = models.PositiveIntegerField( +        _("Year of publication"), blank=True, null=True)      licenses = models.ManyToManyField(LicenseType, verbose_name=_("License"),                                        blank=True)      tags = models.ManyToManyField(DocumentTag, verbose_name=_("Tags"), diff --git a/ishtar_common/templates/ishtar/sheet_document.html b/ishtar_common/templates/ishtar/sheet_document.html index 5e74abe1c..5ce51003c 100644 --- a/ishtar_common/templates/ishtar/sheet_document.html +++ b/ishtar_common/templates/ishtar/sheet_document.html @@ -79,9 +79,10 @@      {% field_flex "Receipt date in documentation" item.receipt_date_in_documentation|date:"DATE_FORMAT" %}      {% endif %} -    {% if item.publisher or item.language or item.isbn or item.issn or item.licenses.count %} +    {% if item.publisher or item.publishing_year or item.language or item.isbn or item.issn or item.licenses.count %}      <h4 class="col-12">{% trans "Publishing" %}</h4>      {% field_flex_detail "Publisher" item.publisher %} +    {% field_flex "Year of publication" item.publishing_year %}      {% field_flex "Language" item.language %}      {% field_flex "ISBN" item.isbn %}      {% field_flex "ISSN" item.issn %} | 
