27 |
27 |
28 class Checker(object): |
28 class Checker(object): |
29 """Checker class that maps from prefix and status to membership. |
29 """Checker class that maps from prefix and status to membership. |
30 """ |
30 """ |
31 |
31 |
32 SITE_MEMBERSHIP = { |
32 def __init__(self, rights, prefix): |
33 'admin': [], |
|
34 'restricted': ['host'], |
|
35 'member': ['user'], |
|
36 'list': ['host'], |
|
37 } |
|
38 |
|
39 CLUB_MEMBERSHIP = { |
|
40 'admin': ['host', 'club_admin'], |
|
41 'restricted': ['host', 'club_admin'], |
|
42 'member': ['host', 'club_admin', 'club_member'], |
|
43 'list': ['host', 'club_admin', 'club_member'], |
|
44 } |
|
45 |
|
46 SPONSOR_MEMBERSHIP = { |
|
47 'admin': ['host'], |
|
48 'restricted': ['host'], |
|
49 'member': ['host'], |
|
50 'list': ['host'], |
|
51 } |
|
52 |
|
53 PROGRAM_MEMBERSHIP = { |
|
54 'admin': ['host'], |
|
55 'restricted': ['host', 'org_admin'], |
|
56 'member': ['host', 'org_admin', 'org_mentor', 'org_student'], |
|
57 'list': ['host', 'org_admin', 'org_mentor'], |
|
58 } |
|
59 |
|
60 ORGANIZATION_MEMBERSHIP = { |
|
61 'admin': ['host', 'org_admin'], |
|
62 'restricted': ['host', 'org_admin', 'org_mentor'], |
|
63 'member': ['host', 'org_admin', 'org_mentor', 'org_student'], |
|
64 'list': ['host', 'org_admin', 'org_mentor'], |
|
65 } |
|
66 |
|
67 USER_MEMBERSHIP = { |
|
68 'admin': ['user_self'], |
|
69 'restricted': ['user_self'], # ,'friends' |
|
70 'member': ['user'], |
|
71 'list': ['user_self'], |
|
72 } |
|
73 |
|
74 RIGHTS = { |
|
75 'site': SITE_MEMBERSHIP, |
|
76 'club': CLUB_MEMBERSHIP, |
|
77 'sponsor': SPONSOR_MEMBERSHIP, |
|
78 'program': PROGRAM_MEMBERSHIP, |
|
79 'org': ORGANIZATION_MEMBERSHIP, |
|
80 'user': USER_MEMBERSHIP, |
|
81 } |
|
82 |
|
83 def __init__(self, prefix): |
|
84 """Constructs a Checker for the specified prefix. |
33 """Constructs a Checker for the specified prefix. |
85 """ |
34 """ |
86 |
35 |
|
36 self.rights = rights[prefix] |
87 self.prefix = prefix |
37 self.prefix = prefix |
88 self.rights = self.RIGHTS[prefix] |
|
89 |
38 |
90 def getMembership(self, status): |
39 def getMembership(self, status): |
91 """Retrieves the membership list for the specified status. |
40 """Retrieves the membership list for the specified status. |
92 """ |
41 """ |
93 |
42 |