summaryrefslogtreecommitdiff
path: root/archaeological_finds/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-06-01 15:50:52 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-06-12 09:57:24 +0200
commit572b9047260322ed19cc9f674657b8be8d62c052 (patch)
tree0ed9392291c50980c7dbff14c9a05edc601076de /archaeological_finds/forms.py
parent66a376e081e335cf94ecf6fd41e5fe13a5445c57 (diff)
downloadIshtar-572b9047260322ed19cc9f674657b8be8d62c052.tar.bz2
Ishtar-572b9047260322ed19cc9f674657b8be8d62c052.zip
Adapt forms, wizards, views, urls for new management of documents (refs #4107)
Diffstat (limited to 'archaeological_finds/forms.py')
-rw-r--r--archaeological_finds/forms.py111
1 files changed, 22 insertions, 89 deletions
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index 6107b744e..1636c7897 100644
--- a/archaeological_finds/forms.py
+++ b/archaeological_finds/forms.py
@@ -24,33 +24,14 @@ Finds forms definitions
import logging
from django import forms
-from django.conf import settings
from django.core import validators
from django.core.exceptions import PermissionDenied
from django.forms.formsets import formset_factory
from django.utils.translation import ugettext_lazy as _
-from ishtar_common.models import valid_id, valid_ids, get_current_profile, \
- SpatialReferenceSystem
-from archaeological_operations.models import Period, ArchaeologicalSite, \
- RelationType as OpeRelationType
+import models
from archaeological_context_records.models import DatingType, DatingQuality, \
ContextRecord, RelationType as CRRelationType
-import models
-
-from ishtar_common.forms import FormSet, FloatField, \
- get_form_selection, reverse_lazy, TableSelect, get_now, FinalForm, \
- ManageOldType, FieldType, IshtarForm, FormHeader
-
-from ishtar_common.forms_common import get_town_field, \
- SourceSelect, CustomForm, BaseImageForm, BaseImageFormset, SourceForm
-from ishtar_common.utils import convert_coordinates_to_point
-from ishtar_common import widgets
-from bootstrap_datepicker.widgets import DatePicker
-from archaeological_operations.widgets import OAWidget
-
-from archaeological_warehouse.models import Warehouse
-
from archaeological_finds.forms_treatments import TreatmentSelect, \
TreatmentFormSelection, BaseTreatmentForm, TreatmentModifyForm, \
AdministrativeActTreatmentForm, TreatmentFormFileChoice, \
@@ -60,11 +41,23 @@ from archaeological_finds.forms_treatments import TreatmentSelect, \
AdministrativeActTreatmentModifForm, \
AdministrativeActTreatmentFileForm, \
AdministrativeActTreatmentFileFormSelection, \
- AdministrativeActTreatmentFileModifForm, SourceTreatmentFormSelection, \
- SourceTreatmentFileFormSelection, TreatmentSourceFormSelection, \
- TreatmentFileSourceFormSelection, DashboardForm as DashboardTreatmentForm, \
- DashboardTreatmentFileForm, TreatmentImagesFormset, \
- TreatmentFileSourceForm, TreatmentSourceForm
+ AdministrativeActTreatmentFileModifForm, \
+ DashboardForm as DashboardTreatmentForm, \
+ DashboardTreatmentFileForm
+from archaeological_operations.models import Period, ArchaeologicalSite, \
+ RelationType as OpeRelationType
+from archaeological_operations.widgets import OAWidget
+from archaeological_warehouse.models import Warehouse
+from bootstrap_datepicker.widgets import DatePicker
+from ishtar_common import widgets
+from ishtar_common.forms import FormSet, FloatField, \
+ reverse_lazy, TableSelect, get_now, FinalForm, \
+ ManageOldType, FieldType, IshtarForm, FormHeader
+from ishtar_common.forms_common import get_town_field, \
+ CustomForm
+from ishtar_common.models import valid_id, valid_ids, get_current_profile, \
+ SpatialReferenceSystem
+from ishtar_common.utils import convert_coordinates_to_point
__all__ = [
'TreatmentSelect', 'TreatmentFormSelection', 'BaseTreatmentForm',
@@ -76,22 +69,17 @@ __all__ = [
'AdministrativeActTreatmentFileForm',
'AdministrativeActTreatmentFileFormSelection',
'AdministrativeActTreatmentFormSelection',
- 'AdministrativeActTreatmentFileModifForm', 'SourceTreatmentFormSelection',
- 'SourceTreatmentFileFormSelection', 'TreatmentSourceFormSelection',
- 'TreatmentFileSourceFormSelection', 'DashboardTreatmentForm',
- 'DashboardTreatmentFileForm', 'TreatmentSourceForm',
- 'TreatmentFileSourceForm',
+ 'AdministrativeActTreatmentFileModifForm',
+ 'DashboardTreatmentForm', 'DashboardTreatmentFileForm',
'RecordFormSelection', 'FindForm', 'DateForm', 'DatingFormSet',
- 'PreservationForm', 'ImagesFormset',
+ 'PreservationForm',
'FindSelect', 'FindFormSelection', 'FindFormSelectionWarehouseModule',
'MultipleFindFormSelection', 'MultipleFindFormSelectionWarehouseModule',
'FindMultipleFormSelection', 'check_form', 'check_exist', 'check_not_exist',
'check_value', 'check_type_field', 'check_type_not_field',
'check_treatment', 'ResultFindForm', 'ResultFindFormSet',
- 'FindDeletionForm', 'UpstreamFindFormSelection', 'SourceFindFormSelection',
- 'FindSourceSelect', 'FindSourceFormSelection', 'NewFindBasketForm',
+ 'FindDeletionForm', 'UpstreamFindFormSelection', 'NewFindBasketForm',
'SelectFindBasketForm', 'DeleteFindBasketForm', 'FindBasketAddItemForm',
- 'TreatmentImagesFormset', 'FindSourceForm'
]
logger = logging.getLogger(__name__)
@@ -327,14 +315,6 @@ class FindForm(CustomForm, ManageOldType):
return self.cleaned_data
-ImagesFormset = formset_factory(BaseImageForm, can_delete=True,
- formset=BaseImageFormset)
-ImagesFormset.file_upload = True
-ImagesFormset.form_label = _(u"Images")
-ImagesFormset.form_admin_name = _(u"Find - 025 - Images")
-ImagesFormset.form_slug = "find-025-images"
-
-
class PreservationForm(CustomForm, ManageOldType):
form_label = _("Preservation")
form_admin_name = _(u"Find - 030 - Preservation")
@@ -747,49 +727,6 @@ class UpstreamFindFormSelection(FindFormSelection):
self.fields['resulting_pk'] = self.fields.pop('pk')
-##############################################
-# Source management for archaeological finds #
-##############################################
-
-SourceFindFormSelection = get_form_selection(
- 'SourceFindFormSelection', _(u"Archaeological find search"), 'find',
- models.Find, FindSelect, 'get-find',
- _(u"You should select an archaeological find."))
-
-
-class FindSourceSelect(SourceSelect):
- find__base_finds__context_record__operation__year = forms.IntegerField(
- label=_(u"Year of the operation"))
- find__base_finds__context_record__operation__operation_code = \
- forms.IntegerField(label=_(u"Numeric reference"))
- if settings.COUNTRY == 'fr':
- find__base_finds__context_record__operation__code_patriarche = \
- forms.IntegerField(
- widget=OAWidget,
- label="Code PATRIARCHE")
- find__datings__period = forms.ChoiceField(
- label=_(u"Period of the archaeological find"), choices=[])
- find__material_type = forms.ChoiceField(
- label=_("Material type of the archaeological find"), choices=[])
- find__description = forms.CharField(
- label=_(u"Description of the archaeological find"))
-
- def __init__(self, *args, **kwargs):
- super(FindSourceSelect, self).__init__(*args, **kwargs)
- self.fields['find__datings__period'].choices = Period.get_types()
- self.fields['find__datings__period'].help_text = Period.get_help()
- self.fields['find__material_type'].choices = \
- models.MaterialType.get_types()
- self.fields['find__material_type'].help_text = \
- models.MaterialType.get_help()
-
-FindSourceFormSelection = get_form_selection(
- 'FindSourceFormSelection', _(u"Documentation search"), 'pk',
- models.FindSource, FindSourceSelect, 'get-findsource',
- _(u"You should select a document."),
- get_full_url='get-findsource-full')
-
-
class NewFindBasketForm(forms.ModelForm):
class Meta:
model = models.FindBasket
@@ -867,7 +804,3 @@ class FindBasketAddItemForm(forms.Form):
raise PermissionDenied
basket.items.add(item)
return basket
-
-
-class FindSourceForm(SourceForm):
- form_slug = "findsource-general"