diff options
Diffstat (limited to 'archaeological_finds/admin.py')
| -rw-r--r-- | archaeological_finds/admin.py | 40 | 
1 files changed, 28 insertions, 12 deletions
| diff --git a/archaeological_finds/admin.py b/archaeological_finds/admin.py index f129881e8..1da39ed82 100644 --- a/archaeological_finds/admin.py +++ b/archaeological_finds/admin.py @@ -18,7 +18,8 @@  # See the file COPYING for details.  from ajax_select import make_ajax_form -from ajax_select.fields import AutoCompleteSelectField +from ajax_select.fields import AutoCompleteSelectField, \ +    AutoCompleteSelectMultipleField  from django import forms  from django.contrib import admin @@ -84,7 +85,8 @@ class FindAdmin(HistorizedObjectAdmin):      search_fields = ('label', "base_finds__cache_complete_id",                       "base_finds__context_record__operation__cached_label")      model = models.Find -    form = make_ajax_form(model, { +    ajax_form_dict = HistorizedObjectAdmin.AJAX_FORM_DICT.copy() +    ajax_form_dict.update({          'base_finds': 'base_find',          'container': 'container',          'container_ref': 'container', @@ -95,6 +97,7 @@ class FindAdmin(HistorizedObjectAdmin):          'main_image': 'document',          'documents': 'document',      }) +    form = make_ajax_form(model, ajax_form_dict)      readonly_fields = HistorizedObjectAdmin.readonly_fields + [          'datings', 'cached_label'      ] @@ -121,21 +124,31 @@ class PropertyAdmin(HistorizedObjectAdmin):  admin_site.register(models.Property, PropertyAdmin) +class AdminTreatmentForm(forms.ModelForm): +    class Meta: +        model = models.Treatment +        exclude = [] +    person = AutoCompleteSelectField('person', required=False) +    organization = AutoCompleteSelectField('organization', required=False) +    file = AutoCompleteSelectField('treatment_file', required=False) +    location = AutoCompleteSelectField("warehouse", required=False) +    container = AutoCompleteSelectField("container", required=False) +    scientific_monitoring_manager = AutoCompleteSelectField("person", +                                                            required=False) +    # finds = AutoCompleteSelectMultipleField("find", required=False) +    lock_user = AutoCompleteSelectField("user", required=False) + +  class TreatmentAdmin(HistorizedObjectAdmin): -    list_display = ('year', 'index', 'label','treatment_types_lbl', 'location', +    list_display = ('year', 'index', 'label', 'treatment_types_lbl', 'location',                      'downstream_lbl', 'upstream_lbl', 'container', 'person')      list_filter = ('treatment_types', 'treatment_state', 'year')      model = models.Treatment -    form = make_ajax_form(model, { -        'person': 'person', -        'organization': 'organization', -        'file': 'treatment_file', -        'location': 'warehouse', -        'container': 'container', -    }) +    form = AdminTreatmentForm      readonly_fields = HistorizedObjectAdmin.readonly_fields + [ -        'cached_label', 'downstream_lbl', 'upstream_lbl' +        'cached_label', 'downstream_lbl', 'upstream_lbl',      ] +    exclude = ["documents", "main_image"]      def has_add_permission(self, request):          return False @@ -152,14 +165,17 @@ class TreatmentFileAdmin(HistorizedObjectAdmin):                       'applicant__raw_name', 'applicant_organisation__name',                       'cached_label')      model = models.TreatmentFile -    form = make_ajax_form(model, { +    ajax_form_dict = HistorizedObjectAdmin.AJAX_FORM_DICT.copy() +    ajax_form_dict.update({          'in_charge': 'person',          'applicant': 'person',          'applicant_organisation': 'organization',      }) +    form = make_ajax_form(model, ajax_form_dict)      readonly_fields = HistorizedObjectAdmin.readonly_fields + [          'cached_label',      ] +    exclude = ["documents", "main_image"]  admin_site.register(models.TreatmentFile, TreatmentFileAdmin) | 
