79 |
79 |
80 # Do not pollute helper.decorators with access specific imports |
80 # Do not pollute helper.decorators with access specific imports |
81 from soc.views import out_of_band |
81 from soc.views import out_of_band |
82 from soc.views import helper |
82 from soc.views import helper |
83 from soc.views.helper import access |
83 from soc.views.helper import access |
|
84 from soc.views.helper import responses |
84 |
85 |
85 @wraps(func) |
86 @wraps(func) |
86 def wrapper(self, request, access_type, *args, **kwargs): |
87 def wrapper(self, request, access_type, *args, **kwargs): |
87 params = kwargs.get('params', {}) |
88 params = kwargs.get('params', {}) |
88 |
89 |
90 if 'rights' in params: |
91 if 'rights' in params: |
91 rights = params['rights'] |
92 rights = params['rights'] |
92 else: |
93 else: |
93 rights = self._params['rights'] |
94 rights = self._params['rights'] |
94 |
95 |
|
96 check_kwargs = kwargs.copy() |
|
97 context = responses.getUniversalContext(request) |
|
98 |
|
99 check_kwargs['GET'] = request.GET |
|
100 check_kwargs['POST'] = request.POST |
|
101 check_kwargs['context'] = context |
|
102 |
95 # Do the access check dance |
103 # Do the access check dance |
96 try: |
104 try: |
97 access.checkAccess(access_type, request, rights, args, kwargs) |
105 access.checkAccess(access_type, rights, kwargs=check_kwargs) |
98 except out_of_band.Error, error: |
106 except out_of_band.Error, error: |
99 return helper.responses.errorResponse(error, request) |
107 return helper.responses.errorResponse(error, request) |
100 return func(self, request, access_type, *args, **kwargs) |
108 return func(self, request, access_type, *args, **kwargs) |
101 |
109 |
102 return wrapper |
110 return wrapper |