Skip to content
This repository has been archived by the owner on Jun 21, 2019. It is now read-only.

Commit

Permalink
temporarily modified Unit.get_user_keys() to use Unit.yoksis_no and U…
Browse files Browse the repository at this point in the history
…nit.parent_unit_no instead of Unit.parent

rref #5367
rref #5366

ref zetaops/zengine#66
ref zetaops/zengine#65
  • Loading branch information
evrenesat committed Jul 29, 2016
1 parent 9efb301 commit 9dbb777
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion ulakbus/models/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 9dbb777

Please sign in to comment.