author | Santosh G. Vattam <vattam.santosh@gmail.com> |
Thu, 06 Aug 2009 18:49:06 +0530 | |
changeset 7 | 3e6916eb3d2c |
parent 5 | 88ae12bc6280 |
child 8 | 294ff7ac9cb6 |
permissions | -rw-r--r-- |
5
88ae12bc6280
Access check helper file added.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
1 |
"""This module contains the access checks |
88ae12bc6280
Access check helper file added.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
2 |
""" |
88ae12bc6280
Access check helper file added.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
3 |
|
88ae12bc6280
Access check helper file added.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
4 |
|
88ae12bc6280
Access check helper file added.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
5 |
__authors__ = [ |
88ae12bc6280
Access check helper file added.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
6 |
'"Madhusudan.C.S" <madhusudancs@gmail.com>', |
88ae12bc6280
Access check helper file added.
Madhusudan.C.S <madhusudancs@gmail.com>
parents:
diff
changeset
|
7 |
] |
7
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
8 |
|
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
9 |
|
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
10 |
def checkAccess(func, request): |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
11 |
""" To check the access of the user and then return the appropriate function |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
12 |
object |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
13 |
""" |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
14 |
user_kind = rights[func.__name__] |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
15 |
if user.is_authenticated(): |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
16 |
if user_kind == 'staff': |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
17 |
if user.is_staff: |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
18 |
return func(request) |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
19 |
else: |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
20 |
return |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
21 |
|
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
22 |
if user_kind == 'proposer': |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
23 |
if not user.is_staff: |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
24 |
return func(request) |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
25 |
else: |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
26 |
return |
3e6916eb3d2c
Added checkAccess routine
Santosh G. Vattam <vattam.santosh@gmail.com>
parents:
5
diff
changeset
|
27 |