allura
Revisão | e920bc6da262b6b0f4323be09581f2958b4c593a (tree) |
---|---|
Hora | 2012-07-13 05:08:29 |
Autor | Cory Johns <johnsca@geek...> |
Commiter | Cory Johns |
[#3892] Moved ACL.add method as ACL instances are not of the ACL class
Signed-off-by: Cory Johns <johnsca@geek.net>
@@ -44,8 +44,4 @@ class ACL(S.Array): | ||
44 | 44 | super(ACL, self).__init__( |
45 | 45 | field_type=ACE(permissions), **kwargs) |
46 | 46 | |
47 | - def add(self, role): | |
48 | - if role not in self: | |
49 | - self.append(role) | |
50 | - | |
51 | 47 | DENY_ALL = ACE.deny(EVERYONE, ALL_PERMISSIONS) |
@@ -14,6 +14,10 @@ from forgewiki.wiki_main import ForgeWikiApp | ||
14 | 14 | log = logging.getLogger(__name__) |
15 | 15 | |
16 | 16 | |
17 | +def add(acl, role): | |
18 | + if role not in acl: | |
19 | + acl.append(role) | |
20 | + | |
17 | 21 | # migration script for change write permission to create + update |
18 | 22 | def main(): |
19 | 23 | query = {'tool_name': {'$regex': '^tickets$', '$options': 'i'}} |
@@ -23,11 +27,11 @@ def main(): | ||
23 | 27 | role_ids = [(p.role_id, p.access) for p in a.acl if p.permission == 'write'] |
24 | 28 | for role_id, access in role_ids: |
25 | 29 | if access == M.ACE.DENY: |
26 | - a.acl.add(M.ACE.deny(role_id, 'create')) | |
27 | - a.acl.add(M.ACE.deny(role_id, 'update')) | |
30 | + add(a.acl, M.ACE.deny(role_id, 'create')) | |
31 | + add(a.acl, M.ACE.deny(role_id, 'update')) | |
28 | 32 | else: |
29 | - a.acl.add(M.ACE.allow(role_id, 'create')) | |
30 | - a.acl.add(M.ACE.allow(role_id, 'update')) | |
33 | + add(a.acl, M.ACE.allow(role_id, 'create')) | |
34 | + add(a.acl, M.ACE.allow(role_id, 'update')) | |
31 | 35 | |
32 | 36 | ThreadLocalORMSession.flush_all() |
33 | 37 |