equal
deleted
inserted
replaced
196 # decorators (simple wrappers around above functions) |
196 # decorators (simple wrappers around above functions) |
197 def has_global_perm(perm_name, must_be_logged_in=False, redirect_field_name=REDIRECT_FIELD_NAME): |
197 def has_global_perm(perm_name, must_be_logged_in=False, redirect_field_name=REDIRECT_FIELD_NAME): |
198 def _dec(view_func): |
198 def _dec(view_func): |
199 def _check_global_perm(request, *args, **kwargs): |
199 def _check_global_perm(request, *args, **kwargs): |
200 if must_be_logged_in and not is_authenticated(request): |
200 if must_be_logged_in and not is_authenticated(request): |
201 login_url = reverse('login') |
201 raise UnauthorizedException('Should be logged in') |
202 return HttpResponseRedirect('%s?%s=%s' % (login_url, redirect_field_name, urlquote(request.get_full_path()))) |
|
203 |
202 |
204 if has_perm(request, perm_name, text=None): |
203 if has_perm(request, perm_name, text=None): |
205 return view_func(request, *args, **kwargs) |
204 return view_func(request, *args, **kwargs) |
206 |
205 |
207 raise UnauthorizedException('No global perm %s' % perm_name) |
206 raise UnauthorizedException('No global perm %s' % perm_name) |
220 def _check_local_perm(request, *args, **kwargs): |
219 def _check_local_perm(request, *args, **kwargs): |
221 if cm_settings.NO_SECURITY: |
220 if cm_settings.NO_SECURITY: |
222 return view_func(request, *args, **kwargs) |
221 return view_func(request, *args, **kwargs) |
223 |
222 |
224 if must_be_logged_in and not is_authenticated(request): |
223 if must_be_logged_in and not is_authenticated(request): |
225 login_url = reverse('login') |
224 raise UnauthorizedException('Should be logged in') |
226 return HttpResponseRedirect('%s?%s=%s' % (login_url, redirect_field_name, urlquote(request.get_full_path()))) |
|
227 |
225 |
228 if 'key' in kwargs: |
226 if 'key' in kwargs: |
229 text = get_object_or_404(Text, key=kwargs['key']) |
227 text = get_object_or_404(Text, key=kwargs['key']) |
230 else: |
228 else: |
231 raise Exception('no security check possible') |
229 raise Exception('no security check possible') |