From 580818aedffebce068728de1d36ffdb8447fee14 Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Fri, 17 Aug 2018 19:31:14 +0200 Subject: Warehouse: fix division form int and save --- archaeological_warehouse/forms.py | 1 - archaeological_warehouse/models.py | 10 ++++++++++ archaeological_warehouse/templates/ishtar/sheet_warehouse.html | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'archaeological_warehouse') diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py index 350e48814..57992c7e2 100644 --- a/archaeological_warehouse/forms.py +++ b/archaeological_warehouse/forms.py @@ -76,7 +76,6 @@ SelectedDivisionFormset = formset_factory( SelectedDivisionFormset.form_label = _(u"Divisions") SelectedDivisionFormset.form_admin_name = _(u"Warehouse - 020 - Divisions") SelectedDivisionFormset.form_slug = "warehouse-020-divisions" -SelectedDivisionFormset.form_through_name = "divisions" class WarehouseSelect(TableSelect): diff --git a/archaeological_warehouse/models.py b/archaeological_warehouse/models.py index bf7ea1eb6..bbcdd93d7 100644 --- a/archaeological_warehouse/models.py +++ b/archaeological_warehouse/models.py @@ -105,6 +105,14 @@ class Warehouse(Address, DashboardFormItem, OwnPerms): def _get_base_image_path(self): return u"{}/{}".format(self.SLUG, slugify(self.name)) + @property + def location_types(self): + return [ + wd.division.label + for wd in WarehouseDivisionLink.objects.filter( + warehouse=self).order_by('order').all() + ] + @property def associated_filename(self): return datetime.date.today().strftime('%Y-%m-%d') + '-' + \ @@ -254,6 +262,8 @@ post_delete.connect(post_save_cache, sender=WarehouseDivision) class WarehouseDivisionLink(models.Model): + RELATED_SET_NAME = "divisions" + RELATED_ATTRS = ["order"] RELATIVE_MODELS = {Warehouse: 'warehouse'} warehouse = models.ForeignKey(Warehouse, related_name='divisions') division = models.ForeignKey(WarehouseDivision) diff --git a/archaeological_warehouse/templates/ishtar/sheet_warehouse.html b/archaeological_warehouse/templates/ishtar/sheet_warehouse.html index 84eb02ae9..1b16819b6 100644 --- a/archaeological_warehouse/templates/ishtar/sheet_warehouse.html +++ b/archaeological_warehouse/templates/ishtar/sheet_warehouse.html @@ -32,6 +32,7 @@ {% field_flex "Person in charge" item.person_in_charge %} {% include "ishtar/blocks/sheet_creation_section.html" %} {% include "ishtar/blocks/sheet_address_section.html" %} + {% field_flex "Divisions" item.location_types|join:", " %} {% field_flex_full "Comment" item.comment "
" "
" %} {% include "ishtar/blocks/sheet_json.html" %} -- cgit v1.2.3