summaryrefslogtreecommitdiff
path: root/archaeological_warehouse
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-08-17 19:31:14 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-08-17 19:31:14 +0200
commit585c1206ce9d32ed70a74c0c4d25b510164389f2 (patch)
tree5a05340c85d5a3d0d6bae556f8020d9ef914fede /archaeological_warehouse
parent8c077c5d9c392e5eb7358610f4a843d4f74f3e72 (diff)
downloadIshtar-585c1206ce9d32ed70a74c0c4d25b510164389f2.tar.bz2
Ishtar-585c1206ce9d32ed70a74c0c4d25b510164389f2.zip
Warehouse: fix division form int and save
Diffstat (limited to 'archaeological_warehouse')
-rw-r--r--archaeological_warehouse/forms.py1
-rw-r--r--archaeological_warehouse/models.py10
-rw-r--r--archaeological_warehouse/templates/ishtar/sheet_warehouse.html1
3 files changed, 11 insertions, 1 deletions
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
@@ -106,6 +106,14 @@ class Warehouse(Address, DashboardFormItem, OwnPerms):
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') + '-' + \
slugify(unicode(self))
@@ -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 "<pre>" "</pre>" %}
{% include "ishtar/blocks/sheet_json.html" %}
</div>