diff options
Diffstat (limited to 'archaeological_operations/forms.py')
| -rw-r--r-- | archaeological_operations/forms.py | 43 | 
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 #  #################################### | 
