author | Pawel Solyga <Pawel.Solyga@gmail.com> |
Sun, 01 Feb 2009 13:26:25 +0000 | |
changeset 1143 | b07b7d5b3e27 |
parent 1136 | aaf75aa8eca5 |
child 1299 | e209bda5addb |
permissions | -rw-r--r-- |
1133 | 1 |
#!/usr/bin/python2.5 |
2 |
# |
|
3 |
# Copyright 2008 the Melange authors. |
|
4 |
# |
|
5 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
|
6 |
# you may not use this file except in compliance with the License. |
|
7 |
# You may obtain a copy of the License at |
|
8 |
# |
|
9 |
# http://www.apache.org/licenses/LICENSE-2.0 |
|
10 |
# |
|
11 |
# Unless required by applicable law or agreed to in writing, software |
|
12 |
# distributed under the License is distributed on an "AS IS" BASIS, |
|
13 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 |
# See the License for the specific language governing permissions and |
|
15 |
# limitations under the License. |
|
16 |
||
17 |
"""Module with rights related methods. |
|
18 |
""" |
|
19 |
||
20 |
__authors__ = [ |
|
21 |
'"Sverre Rabbelier" <sverre@rabbelier.nl>', |
|
22 |
] |
|
23 |
||
24 |
||
25 |
class Checker(object): |
|
1136
aaf75aa8eca5
Added two forgotten comments in rights.Checker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1133
diff
changeset
|
26 |
"""Checker class that maps from prefix and status to membership. |
1133 | 27 |
""" |
28 |
||
29 |
SITE_MEMBERSHIP = { |
|
30 |
'admin': [], |
|
31 |
'restricted': ['host'], |
|
32 |
'member': ['user'], |
|
33 |
} |
|
34 |
||
35 |
CLUB_MEMBERSHIP = { |
|
36 |
'admin': ['host', 'club_admin'], |
|
37 |
'restricted': ['host', 'club_admin'], |
|
38 |
'member': ['host', 'club_admin', 'club_member'], |
|
39 |
} |
|
40 |
||
41 |
SPONSOR_MEMBERSHIP = { |
|
42 |
'admin': ['host'], |
|
43 |
'restricted': ['host'], |
|
44 |
'member': ['host'], |
|
45 |
} |
|
46 |
||
47 |
PROGRAM_MEMBERSHIP = { |
|
48 |
'admin': ['host'], |
|
49 |
'restricted': ['host', 'org_admin'], |
|
50 |
'member': ['host', 'org_admin', 'org_mentor', 'org_student'], |
|
51 |
} |
|
52 |
||
53 |
ORGANIZATION_MEMBERSHIP = { |
|
54 |
'admin': ['host', 'org_admin'], |
|
55 |
'restricted': ['host', 'org_admin', 'org_mentor'], |
|
56 |
'member': ['host', 'org_admin', 'org_mentor', 'org_student'], |
|
57 |
} |
|
58 |
||
59 |
USER_MEMBERSHIP = { |
|
60 |
'admin': ['user_self'], |
|
61 |
'restricted': ['user_self'], # ,'friends' |
|
62 |
'member': ['user'], |
|
63 |
} |
|
64 |
||
65 |
RIGHTS = { |
|
66 |
'site': SITE_MEMBERSHIP, |
|
67 |
'club': CLUB_MEMBERSHIP, |
|
68 |
'sponsor': SPONSOR_MEMBERSHIP, |
|
69 |
'program': PROGRAM_MEMBERSHIP, |
|
70 |
'organization': ORGANIZATION_MEMBERSHIP, |
|
71 |
'user': USER_MEMBERSHIP, |
|
72 |
} |
|
73 |
||
74 |
def __init__(self, prefix): |
|
1143
b07b7d5b3e27
Fix missing dots and blank lines to soc.logic modules.
Pawel Solyga <Pawel.Solyga@gmail.com>
parents:
1136
diff
changeset
|
75 |
"""Constructs a Checker for the specified prefix. |
1133 | 76 |
""" |
77 |
||
78 |
self.prefix = prefix |
|
79 |
self.rights = self.RIGHTS[prefix] |
|
80 |
||
81 |
def getMembership(self, status): |
|
1136
aaf75aa8eca5
Added two forgotten comments in rights.Checker
Sverre Rabbelier <srabbelier@gmail.com>
parents:
1133
diff
changeset
|
82 |
"""Retrieves the membership list for the specified status. |
1133 | 83 |
""" |
84 |
||
85 |
if status == 'user': |
|
86 |
return ['user'] |
|
87 |
||
88 |
if status == 'public': |
|
89 |
return ['anyone'] |
|
90 |
||
91 |
return self.rights[status] |