summaryrefslogtreecommitdiff
path: root/archaeological_finds/admin.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2020-02-12 13:52:38 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2020-02-12 13:52:38 +0100
commitac0b1d3178b5c7cbc4cc3baf225c093f63d7f72c (patch)
tree94b9295db41a1c8c5ca7fd37a94a94c6b5591f54 /archaeological_finds/admin.py
parent495bfd4c2c963a6c1a8aee72132d789b2c2b9a7f (diff)
downloadIshtar-ac0b1d3178b5c7cbc4cc3baf225c093f63d7f72c.tar.bz2
Ishtar-ac0b1d3178b5c7cbc4cc3baf225c093f63d7f72c.zip
Admin: fix and improve performances
Diffstat (limited to 'archaeological_finds/admin.py')
-rw-r--r--archaeological_finds/admin.py40
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)