diff options
author | Étienne Loks <etienne.loks@proxience.com> | 2015-12-18 17:46:12 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@proxience.com> | 2015-12-18 17:46:12 +0100 |
commit | 2cdd0113bef60cefabd09fb41123d0add9f1137d (patch) | |
tree | a04efd3e00a5a5928ce6495d24ad3bff076d21d5 /archaeological_operations/forms.py | |
parent | 557d6e5d552f6fbae85a7170756d9b7c977e0b79 (diff) | |
download | Ishtar-2cdd0113bef60cefabd09fb41123d0add9f1137d.tar.bz2 Ishtar-2cdd0113bef60cefabd09fb41123d0add9f1137d.zip |
RecordRelations form for operations
Diffstat (limited to 'archaeological_operations/forms.py')
-rw-r--r-- | archaeological_operations/forms.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py index 3d679d555..8c3650c21 100644 --- a/archaeological_operations/forms.py +++ b/archaeological_operations/forms.py @@ -335,6 +335,28 @@ ParcelFormSet = formset_factory(ParcelForm, can_delete=True, formset=ParcelFormSet) ParcelFormSet.form_label = _(u"Parcels") + +class RecordRelationsForm(forms.Form): + base_model = 'right_relation' + associated_models = {'right_record': models.Operation, + 'relation_type': models.RelationType} + relation_type = forms.ChoiceField(label=_(u"Relation type"), + choices=[], required=False) + right_record = forms.IntegerField( + label=_(u"Operation"), + widget=widgets.JQueryAutoComplete( + reverse_lazy('autocomplete-operation'), + associated_model=models.Operation), + validators=[valid_id(models.Operation)], required=False) + + def __init__(self, *args, **kwargs): + super(RecordRelationsForm, self).__init__(*args, **kwargs) + self.fields['relation_type'].choices = \ + models.RelationType.get_types() + +RecordRelationsFormSet = formset_factory(RecordRelationsForm, can_delete=True) +RecordRelationsFormSet.form_label = _(u"Relations") + SRA_AGENT, created = PersonType.objects.get_or_create(txt_idx='sra_agent') HEAD_SCIENTIST, created = PersonType.objects.get_or_create( txt_idx='head_scientist') |