diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-03-31 12:37:41 +0200 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2026-03-31 15:17:12 +0200 |
| commit | 7038c8e42b3bffb2db21c08f303551d4fa9b1389 (patch) | |
| tree | 6844a3f18dd449cf115f0f21e19620e287cc9370 /archaeological_operations/forms.py | |
| parent | 43651f3fb7dd3a0c90132d90b6c04ac3aee3552c (diff) | |
| download | Ishtar-7038c8e42b3bffb2db21c08f303551d4fa9b1389.tar.bz2 Ishtar-7038c8e42b3bffb2db21c08f303551d4fa9b1389.zip | |
✨ sites - form: add heritage fields in edit forms
Diffstat (limited to 'archaeological_operations/forms.py')
| -rw-r--r-- | archaeological_operations/forms.py | 96 |
1 files changed, 71 insertions, 25 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index f25d9f2cc..82f41c089 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -1309,49 +1309,79 @@ class SiteForm(CustomForm, ManageOldType): form_admin_name = _("Archaeological site - 010 - General") form_slug = "archaeological_site-010-general" associated_models = { - 'period': models.Period, 'remain': models.RemainType, - 'spatial_reference_system': SpatialReferenceSystem, - 'cultural_attribution': models.CulturalAttributionType, - 'collaborator': Person, "actor": QualifiedBiographicalNote, - 'discoverer': Person, - "nature_of_site": models.NatureOfSiteType, - "interpretation_level": models.InterpretationLevelType, + "collaborator": Person, + "cultural_attribution": models.CulturalAttributionType, + "current_state": models.SiteCurrentStatusType, + "discoverer": Person, "discovery_status": models.SiteDiscoveryStatusType, - "current_status": models.SiteCurrentStatusType, + "editor": models.Author, + "heritage_interest": models.HeritageInterestType, + "heritage_environmental_protection": models.HeritageAndEnvironmentalProtectionType, + "interpretation_level": models.InterpretationLevelType, + "nature_of_site": models.NatureOfSiteType, + "period": models.Period, + "remain": models.RemainType, "town": Town, "type": models.SiteType, } - extra_form_modals = ["qualifiedbiographicalnote", "biographicalnote", "person", - "organization"] - base_models = ["period", "remain", "collaborator", "cultural_attribution", "town", - "type", "actor"] - + extra_form_modals = ["author", "qualifiedbiographicalnote", "biographicalnote", + "person", "organization"] + base_models = [ + "actor", "collaborator", "cultural_attribution", "current_state", "editor", + "heritage_interest", "heritage_environmental_protection", "period", "remain", + "town", "type" + ] pk = forms.IntegerField(required=False, widget=forms.HiddenInput) + HEADERS['reference'] = FormHeader(_("General")) reference = forms.CharField(label=_("Reference"), max_length=200) - name = forms.CharField(label=_("Name"), max_length=200, required=False) other_reference = forms.CharField(label=_("Other reference"), required=False) - collaborator = widgets.Select2MultipleField( - model=Person, label=_("Collaborators"), required=False, - remote=True, new=True) + name = forms.CharField(label=_("Name"), max_length=200, required=False) + heritage_interest = forms.MultipleChoiceField( + label=_("Heritage interest"), choices=[], widget=widgets.Select2Multiple, + required=False) actor = widgets.Select2MultipleField( model=QualifiedBiographicalNote, label=_("Actors"), required=False, remote=True, new=True) + collaborator = widgets.Select2MultipleField( + model=Person, label=_("Collaborators"), required=False, + remote=True, new=True) description = forms.CharField(label=_("Description"), widget=forms.Textarea, required=False) - public_description = forms.CharField(label=_("Public description"), widget=forms.Textarea, - required=False) + public_description = forms.CharField( + label=_("Public description"), widget=forms.Textarea, + required=False + ) comment = forms.CharField(label=_("Comment"), widget=forms.Textarea, required=False) + HEADERS['protection_id'] = FormHeader(_("Protection")) + protection_id = forms.CharField(label=_("Protection ID"), required=False) + protection_date = DateField(label=_("Protection date"), required=False) + heritage_environmental_protection = forms.MultipleChoiceField( + label=_("Heritage and environmental protections"), choices=[], + widget=widgets.Select2Multiple, required=False) + details_on_protection = forms.CharField( + label=_("Details on protection"), widget=forms.Textarea, + required=False + ) HEADERS['type'] = FormHeader(_("Scientific")) type = forms.MultipleChoiceField( label=_("Types"), choices=[], widget=widgets.Select2Multiple, required=False) - nature_of_site = forms.ChoiceField(choices=[], label=_("Nature of site"), required=False) - interpretation_level = forms.ChoiceField(choices=[], label=_("Interpretation level"), required=False) - discovery_status = forms.ChoiceField(choices=[], label=_("Discovery status"), required=False) - current_status = forms.ChoiceField(choices=[], label=_("Current status"), required=False) + nature_of_site = forms.ChoiceField( + choices=[], label=_("Nature of site"), required=False + ) + interpretation_level = forms.ChoiceField( + choices=[], label=_("Interpretation level"), required=False + ) + discovery_status = forms.ChoiceField( + choices=[], label=_("Discovery status"), required=False + ) + current_state = forms.MultipleChoiceField( + label=_("Current states"), choices=[], widget=widgets.Select2Multiple, + required=False + ) period = forms.MultipleChoiceField( label=_("Periods"), choices=[], widget=widgets.Select2Multiple, required=False) @@ -1364,7 +1394,8 @@ class SiteForm(CustomForm, ManageOldType): required=False) discoverer = forms.IntegerField( widget=widgets.JQueryAutoComplete( - reverse_lazy('autocomplete-person-permissive'), associated_model=Person), + reverse_lazy('autocomplete-person-permissive'), associated_model=Person, + new=True), label=_("Discoverer"), required=False) HEADERS['town'] = FormHeader(_("Localization")) town = widgets.Select2MultipleField( @@ -1383,17 +1414,32 @@ class SiteForm(CustomForm, ManageOldType): widget=forms.Textarea, required=False ) + HEADERS["editor"] = FormHeader(_("Sheet")) + editor = widgets.Select2MultipleField( + label=_("Editors"), required=False, + model=models.Author, remote=True, new=True + ) + TYPES = [ FieldType('type', models.SiteType, True), FieldType('period', models.Period, True), FieldType('remain', models.RemainType, True), FieldType('cultural_attribution', models.CulturalAttributionType, True), + FieldType('heritage_interest', models.HeritageInterestType, True), + FieldType('heritage_environmental_protection', + models.HeritageAndEnvironmentalProtectionType, True), FieldType('nature_of_site', models.NatureOfSiteType), FieldType('interpretation_level', models.InterpretationLevelType), - FieldType('current_status', models.SiteCurrentStatusType), + FieldType('current_state', models.SiteCurrentStatusType, True), FieldType('discovery_status', models.SiteDiscoveryStatusType), ] + OPTIONS_PERMISSIONS = [ + # field name, permission, options + ("actor", ("ishtar_common.add_qualifiedbiographicalnote",), {"new": True}), + ("discoverer", ("ishtar_common.add_person",), {"new": True}), + ("editor", ("ishtar_common.add_author",), {"new": True}), + ] def clean_reference(self): reference = self.cleaned_data['reference'] |
