From 9dbb77772835ff33027901d2d2e1cf4e4cf9e7d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Evren=20Esat=20=C3=96zkan?= Date: Fri, 29 Jul 2016 10:18:02 +0300 Subject: [PATCH] temporarily modified Unit.get_user_keys() to use Unit.yoksis_no and Unit.parent_unit_no instead of Unit.parent rref #5367 rref #5366 ref zetaops/zengine#66 ref zetaops/zengine#65 --- ulakbus/models/auth.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ulakbus/models/auth.py b/ulakbus/models/auth.py index d2de87e2..323a0980 100644 --- a/ulakbus/models/auth.py +++ b/ulakbus/models/auth.py @@ -226,16 +226,25 @@ class Unit(Model): @classmethod def get_user_keys(cls, unit_key): + return cls.get_user_keys_by_yoksis(Unit.objects.get(unit_key).yoksis_no) stack = Role.objects.filter(unit_id=unit_key).values_list('user_id', flatten=True) for unit_key in cls.objects.filter(parent_id=unit_key).values_list('key', flatten=True): stack.extend(cls.get_user_keys(unit_key)) return stack + @classmethod + def get_user_keys_by_yoksis(cls, yoksis_no): + # because we don't refactor our data to use Unit.parent, yet! + stack = Role.objects.filter(unit_id=Unit.objects.get(yoksis_no=yoksis_no).key).values_list('user_id', flatten=True) + for yoksis_no in cls.objects.filter(parent_unit_no=yoksis_no).values_list('yoksis_no', flatten=True): + stack.extend(cls.get_user_keys_by_yoksis(yoksis_no)) + return stack + class Meta: app = 'Sistem' verbose_name = "Unit" verbose_name_plural = "Units" - search_fields = ['name'] + search_fields = ['name', 'yoksis_no'] list_fields = ['name', 'unit_type'] def __unicode__(self):