diff options
Diffstat (limited to 'archaeological_finds/forms.py')
| -rw-r--r-- | archaeological_finds/forms.py | 28 | 
1 files changed, 26 insertions, 2 deletions
| diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py index fff378ff0..75b61cd37 100644 --- a/archaeological_finds/forms.py +++ b/archaeological_finds/forms.py @@ -330,10 +330,11 @@ class QAFindFormMulti(QAForm):      MULTI = True      REPLACE_FIELDS = [ -        'qa_manufacturing_place', 'qa_checked_type', 'qa_check_date' +        'qa_ue', 'qa_manufacturing_place', 'qa_checked_type', 'qa_check_date'      ]      HEADERS = { +        'qa_ue': FormHeader(_(u"Context record")),          'qa_label': FormHeader(_(u"Identification")),          'qa_description': FormHeader(_(u"Description")),          'qa_checked_type': FormHeader(_(u"Sheet")) @@ -344,10 +345,16 @@ class QAFindFormMulti(QAForm):          'qa_get_first_base_find__excavation_id', 'qa_museum_id',          'qa_seal_number', 'qa_mark'      ] +    qa_ue = forms.IntegerField( +        label=_(u"Context record"), +        widget=widgets.JQueryAutoComplete( +            reverse_lazy('autocomplete-contextrecord'), +            associated_model=ContextRecord), +        validators=[valid_id(ContextRecord)], required=False)      qa_label = forms.CharField(          label=_(u"Free ID"), -        validators=[validators.MaxLengthValidator(60)]) +        validators=[validators.MaxLengthValidator(60)], required=False)      qa_denomination = forms.CharField(label=_(u"Denomination"), required=False)      qa_previous_id = forms.CharField(label=_("Previous ID"), required=False)      qa_get_first_base_find__excavation_id = forms.CharField( @@ -394,6 +401,23 @@ class QAFindFormMulti(QAForm):          FieldType('qa_checked_type', models.CheckedType),      ] +    def _get_qa_ue(self, value): +        try: +            value = ContextRecord.objects.get(pk=value).cached_label +        except ContextRecord.DoesNotExist: +            return "" +        return value + +    def _set_qa_ue(self, item, user): +        ue = self.cleaned_data['qa_ue'] +        if not ue: +            return +        cr = ContextRecord.objects.get(pk=ue) +        bf = item.get_first_base_find() +        bf.context_record = cr +        bf.history_modifier = user +        bf.save() +  class QAFindFormSingle(QAFindFormMulti):      MULTI = False | 
