Skip to content

Instantly share code, notes, and snippets.

@jalanb
Created September 20, 2016 23:24
Show Gist options
  • Select an option

  • Save jalanb/cf96395baa68dcf1f72919a76886902b to your computer and use it in GitHub Desktop.

Select an option

Save jalanb/cf96395baa68dcf1f72919a76886902b to your computer and use it in GitHub Desktop.
class OrgAccess(object):
""" Extract Region, Area, Branch, District codes from permissions
"""
def __init__(self, permissions):
OrgAccess.permissions = permissions
@classmethod
def regions(cls):
return [p[10:] for p in cls.permissions if p[0:10] == 'DashRegion']
@classmethod
def areas(cls):
return [p[8:] for p in cls.permissions if p[0:8] == 'DashArea']
@classmethod
def districts(cls):
return [p[12:] for p in cls.permissions if p[0:12] == 'DashDistrict']
@classmethod
def branches(cls):
return [p[10:] for p in cls.permissions if p[0:10] == 'DashBranch']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment