diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-23 15:37:41 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-23 15:43:41 +0200 |
commit | 9467239aa0276462e6a55b9b85d2f342780dfee3 (patch) | |
tree | 855bfac09cba06f88a9313a71337da0ed91e064e /archaeological_finds/forms.py | |
parent | f5fc6f23f5369df98fb0fdb061bfbac3c9662677 (diff) | |
download | Ishtar-9467239aa0276462e6a55b9b85d2f342780dfee3.tar.bz2 Ishtar-9467239aa0276462e6a55b9b85d2f342780dfee3.zip |
Finds: add cultural attributions
Diffstat (limited to 'archaeological_finds/forms.py')
-rw-r--r-- | archaeological_finds/forms.py | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index 929f1bade..156132c27 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -31,6 +31,7 @@ from django.forms.formsets import formset_factory from django.utils.translation import ugettext_lazy as _ from . import models +from archaeological_operations.models import CulturalAttributionType from archaeological_context_records.models import DatingType, DatingQuality, \ ContextRecord, RelationType as CRRelationType, Dating from archaeological_finds.forms_treatments import TreatmentSelect, \ @@ -127,17 +128,19 @@ class RecordFormSelection(CustomForm, forms.Form): cr.operation.pk) -class BaseFindForm(CustomForm, ManageOldType): +class BasicFindForm(CustomForm, ManageOldType): """ - Base find form with no field related to base_find + Basic find form with no field related to base_find """ file_upload = True form_label = _("Find") form_admin_name = _(u"Simple find - 020 - General") form_slug = "simplefind-020-general" - base_models = ['object_type', 'material_type', 'communicabilitie'] + base_models = ['object_type', 'material_type', 'communicabilitie', + 'cultural_attribution'] associated_models = { 'material_type': models.MaterialType, + 'cultural_attribution': CulturalAttributionType, 'object_type': models.ObjectType, 'communicabilitie': models.CommunicabilityType, 'material_type_quality': models.MaterialTypeQualityType, @@ -150,7 +153,8 @@ class BaseFindForm(CustomForm, ManageOldType): 'material_type', 'material_type_quality', 'material_comment', 'object_type', 'object_type_quality', 'find_number', 'min_number_of_individuals', 'inscription', 'decoration', - 'manufacturing_place', 'communicabilitie', 'comment', 'dating_comment', + 'manufacturing_place', 'communicabilitie', 'comment', + 'cultural_attribution', 'dating_comment', 'length', 'width', 'height', 'thickness', 'diameter', 'circumference', 'volume', 'weight', 'clutter_long_side', 'clutter_short_side', 'clutter_height', 'dimensions_comment', 'checked_type', 'check_date' @@ -202,6 +206,9 @@ class BaseFindForm(CustomForm, ManageOldType): ) comment = forms.CharField(label=_(u"Comment"), required=False, widget=forms.Textarea) + cultural_attribution = widgets.Select2MultipleField( + label=_("Cultural attribution"), required=False, + ) dating_comment = forms.CharField( label=_(u"Comment on dating"), required=False, widget=forms.Textarea) @@ -242,6 +249,8 @@ class BaseFindForm(CustomForm, ManageOldType): TYPES = [ FieldType('material_type', models.MaterialType, is_multiple=True, extra_args={"full_hierarchy": True}), + FieldType('cultural_attribution', CulturalAttributionType, + is_multiple=True), FieldType('material_type_quality', models.MaterialTypeQualityType), FieldType('object_type', models.ObjectType, is_multiple=True, extra_args={"full_hierarchy": True}), @@ -253,7 +262,7 @@ class BaseFindForm(CustomForm, ManageOldType): def __init__(self, *args, **kwargs): context_record = kwargs.pop('context_record') - super(BaseFindForm, self).__init__(*args, **kwargs) + super(BasicFindForm, self).__init__(*args, **kwargs) if not context_record or \ not context_record.operation.operation_type.judiciary: self.fields.pop('seal_number') @@ -272,13 +281,13 @@ class BaseFindForm(CustomForm, ManageOldType): return self.cleaned_data -class FindForm(BaseFindForm): +class FindForm(BasicFindForm): file_upload = True form_label = _("Find") form_admin_name = _(u"Find - 020 - General") form_slug = "find-020-general" - base_models = ['get_first_base_find'] + BaseFindForm.base_models - associated_models = BaseFindForm.associated_models.copy() + base_models = ['get_first_base_find'] + BasicFindForm.base_models + associated_models = BasicFindForm.associated_models.copy() associated_models.update({ 'get_first_base_find__batch': models.BatchType, 'get_first_base_find__spatial_reference_system': SpatialReferenceSystem, @@ -293,6 +302,7 @@ class FindForm(BaseFindForm): 'material_comment', 'object_type', 'object_type_quality', 'find_number', 'min_number_of_individuals', 'inscription', 'manufacturing_place', 'communicabilitie', 'comment', + 'cultural_attribution', 'dating_comment', 'length', 'width', 'height', 'thickness', 'diameter', 'circumference', 'volume', 'weight', 'clutter_long_side', 'clutter_short_side', @@ -305,7 +315,7 @@ class FindForm(BaseFindForm): 'check_date', ] - HEADERS = BaseFindForm.HEADERS.copy() + HEADERS = BasicFindForm.HEADERS.copy() get_first_base_find__excavation_id = forms.CharField( label=_(u"Excavation ID"), required=False) @@ -336,7 +346,7 @@ class FindForm(BaseFindForm): required=False, max_length=120 ) - TYPES = BaseFindForm.TYPES + [ + TYPES = BasicFindForm.TYPES + [ FieldType('get_first_base_find__batch', models.BatchType), FieldType('get_first_base_find__spatial_reference_system', SpatialReferenceSystem), @@ -395,7 +405,7 @@ class FindForm(BaseFindForm): return self.cleaned_data -class SimpleFindForm(BaseFindForm): +class SimpleFindForm(BasicFindForm): def __init__(self, *args, **kwargs): self.base_finds = kwargs.pop('base_finds') super(SimpleFindForm, self).__init__(*args, **kwargs) @@ -454,7 +464,7 @@ class ResultingFindForm(CustomForm, ManageOldType): label=_(u"Communicability"), required=False ) resulting_comment = forms.CharField(label=_(u"Comment"), required=False, - widget=forms.Textarea) + widget=forms.Textarea) resulting_dating_comment = forms.CharField( label=_(u"Comment on dating"), required=False, widget=forms.Textarea) @@ -463,8 +473,8 @@ class ResultingFindForm(CustomForm, ManageOldType): resulting_width = FloatField(label=_(u"Width (cm)"), required=False) resulting_height = FloatField(label=_(u"Height (cm)"), required=False) resulting_diameter = FloatField(label=_(u"Diameter (cm)"), required=False) - resulting_circumference = FloatField(label=_(u"Circumference (cm)"), - required=False) + resulting_circumference = FloatField(label=_(u"Circumference (cm)"), + required=False) resulting_thickness = FloatField(label=_(u"Thickness (cm)"), required=False) resulting_volume = FloatField(label=_(u"Volume (l)"), required=False) resulting_weight = FloatField(label=_(u"Weight (g)"), required=False) @@ -1042,6 +1052,8 @@ class FindSelect(HistorySelect): communicabilities = forms.ChoiceField(label=_(u"Communicability")) comment = forms.CharField(label=_(u"Comment")) + cultural_attributions = forms.ChoiceField( + label=_("Cultural attribution"), choices=[], required=False) datings__period = forms.ChoiceField(label=_(u"Period"), choices=[]) dating_comment = forms.CharField(label=_(u"Comment on dating")) @@ -1147,8 +1159,6 @@ class FindSelect(HistorySelect): label=_(u"Appraisal date after"), widget=DatePicker) appraisal_date__before = forms.DateField( label=_(u"Appraisal date before"), widget=DatePicker) - conservatory_comment = forms.CharField( - label=_(u"Conservatory comment")) documents__image__isnull = forms.NullBooleanField(label=_(u"Has an image?")) loan = forms.NullBooleanField(label=_(u"Loan?")) @@ -1173,6 +1183,7 @@ class FindSelect(HistorySelect): FieldType('alterations', models.AlterationType), FieldType('alteration_causes', models.AlterationCauseType), FieldType('treatment_emergency', models.TreatmentEmergencyType), + FieldType('cultural_attributions', CulturalAttributionType), ] SITE_KEYS = { "archaeological_sites": "attached-to-operation", |