summaryrefslogtreecommitdiff
path: root/archaeological_operations/forms.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-02-14 12:39:03 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-02-15 17:20:19 +0100
commit32b9575cefa9eede2be68ea8464a7c70d52e4105 (patch)
treedf7cf20de56e13c9660d14219d7ee5d825bb2909 /archaeological_operations/forms.py
parent5bbafc5b1a398afa4cd37acf20293eddb8c12f9b (diff)
downloadIshtar-32b9575cefa9eede2be68ea8464a7c70d52e4105.tar.bz2
Ishtar-32b9575cefa9eede2be68ea8464a7c70d52e4105.zip
Archaeological site: search view (refs #3913)
- add site to profile - allow alternate label in menus for sites - add entry in menu - basic configuration of site model
Diffstat (limited to 'archaeological_operations/forms.py')
-rw-r--r--archaeological_operations/forms.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py
index 4f5ac0435..38efb269f 100644
--- a/archaeological_operations/forms.py
+++ b/archaeological_operations/forms.py
@@ -1245,6 +1245,49 @@ class OperationDeletionForm(FinalForm):
confirm_msg = " "
confirm_end_msg = _(u"Would you like to delete this operation?")
+#########
+# Sites #
+#########
+
+
+class SiteSelect(TableSelect):
+ search_vector = forms.CharField(label=_(u"Full text search"))
+ reference = forms.CharField(label=_(u"Reference"), max_length=200,
+ required=False)
+ name = forms.CharField(label=_(u"Name"), max_length=200, required=False)
+ periods = forms.ChoiceField(label=_(u"Periods"), choices=[], required=False)
+ remains = forms.ChoiceField(label=_(u"Remains"), choices=[], required=False)
+ TYPES = [
+ FieldType('periods', models.Period),
+ FieldType('remains', models.RemainType),
+ ]
+
+
+class SiteFormSelection(IshtarForm):
+ SEARCH_AND_SELECT = True
+ associated_models = {'pk': models.ArchaeologicalSite}
+ currents = {'pk': models.ArchaeologicalSite}
+ pk = forms.IntegerField(
+ label="", required=False,
+ widget=widgets.DataTable(
+ reverse_lazy('get-site'), SiteSelect,
+ models.ArchaeologicalSite,
+ source_full=reverse_lazy('get-site-full')),
+ validators=[valid_id(models.Operation)])
+
+ @classmethod
+ def form_label(cls):
+ return unicode(_(u"{} search")).format(
+ get_current_profile().get_site_label()
+ )
+
+ def clean(self):
+ cleaned_data = self.cleaned_data
+ if 'pk' not in cleaned_data or not cleaned_data['pk']:
+ raise forms.ValidationError(_(u"You should select an item."))
+ return cleaned_data
+
+
####################################
# Source management for operations #
####################################