From 585c1206ce9d32ed70a74c0c4d25b510164389f2 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/models.py | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'archaeological_warehouse/models.py') 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) -- cgit v1.2.3