def decorator(view_func): @wraps(view_func, assigned=available_attrs(view_func)) def _wrapped_view(request, *args, **kwargs): if not request.user.id: Message.warning(request, ("Tu no estás autenticado")) raise PermissionDenied #403.html #return render_to_response("403.html", {'': ''}, context_instance=RequestContext(request)) permiso = "" recurso = "/" response = HttpResponse() response.write('<script type="text/javascript">') response.write('alert("Hola")') response.write('</script>') try: path = request.path.strip( "/" ) # request.get_full_path().strip("/") #"/apps/controller/action/" to "apps/controller/action" except Exception, e: raise Exception( "%s. Asigne adecuadamente el parámetro template_denied_name " % e) path_list = path.split('/') permiso = "%s." % (path_list[0]) recurso = "/%s/" % (path_list[0]) if not isinstance(permiso, (list, tuple)): perms = (permiso, ) else: perms = permiso if not request.user.has_perms(perms) and len(path_list) > 1: permiso = "%s.%s" % (path_list[0], path_list[1]) recurso = "/%s/%s/" % (path_list[0], path_list[1]) if not isinstance(permiso, (list, tuple)): perms = (permiso, ) else: perms = permiso if not request.user.has_perms(perms) and len(path_list) > 2: permiso = "%s.%s_%s" % (path_list[0], path_list[1], path_list[2]) recurso = "/%s/%s/%s/" % (path_list[0], path_list[1], path_list[2]) if not isinstance(permiso, (list, tuple)): perms = (permiso, ) else: perms = permiso if request.user.has_perms(perms): return view_func(request, *args, **kwargs) else: Message.warning( request, ("Tu no posees permisos para acceder a <b>%(route)s</b>") % {'route': recurso}) #raise PermissionDenied return render_to_response( template_denied_name, {'': ''}, context_instance=RequestContext(request))
def decorator(view_func): @wraps(view_func, assigned=available_attrs(view_func)) def _wrapped_view(request, *args, **kwargs) : if not request.user.id: Message.warning(request, ("Tu no estás autenticado")) raise PermissionDenied #403.html #return render_to_response("403.html", {'': ''}, context_instance=RequestContext(request)) permiso = "" recurso = "/" response = HttpResponse() response.write('<script type="text/javascript">') response.write('alert("Hola")') response.write('</script>') try: path = request.path.strip("/") # request.get_full_path().strip("/") #"/apps/controller/action/" to "apps/controller/action" except Exception, e: raise Exception("%s. Asigne adecuadamente el parámetro template_denied_name " % e) path_list = path.split('/') permiso = "%s." % (path_list[0]) recurso = "/%s/" % (path_list[0]) if not isinstance(permiso, (list, tuple)): perms = (permiso,) else: perms = permiso if not request.user.has_perms(perms) and len(path_list) > 1: permiso = "%s.%s" % (path_list[0], path_list[1]) recurso = "/%s/%s/" % (path_list[0], path_list[1]) if not isinstance(permiso, (list, tuple)): perms = (permiso,) else: perms = permiso if not request.user.has_perms(perms) and len(path_list) > 2: permiso = "%s.%s_%s" % (path_list[0], path_list[1], path_list[2]) recurso = "/%s/%s/%s/" % (path_list[0], path_list[1], path_list[2]) if not isinstance(permiso, (list, tuple)): perms = (permiso,) else: perms = permiso if request.user.has_perms(perms): return view_func(request, *args, **kwargs) else: Message.warning(request, ("Tu no posees permisos para acceder a <b>%(route)s</b>") % {'route':recurso}) #raise PermissionDenied return render_to_response(template_denied_name, {'': ''}, context_instance=RequestContext(request))
def _wrapped_view(request, *args, **kwargs) : if not request.user.id: Message.warning(request, ("Tu no estás autenticado")) raise PermissionDenied #403.html #return render_to_response("403.html", {'': ''}, context_instance=RequestContext(request)) permiso = "" recurso = "/" response = HttpResponse() response.write('<script type="text/javascript">') response.write('alert("Hola")') response.write('</script>') try: path = request.path.strip("/") # request.get_full_path().strip("/") #"/apps/controller/action/" to "apps/controller/action" except Exception, e: raise Exception("%s. Asigne adecuadamente el parámetro template_denied_name " % e)
def _wrapped_view(request, *args, **kwargs): if not request.user.id: Message.warning(request, ("Tu no estás autenticado")) raise PermissionDenied #403.html #return render_to_response("403.html", {'': ''}, context_instance=RequestContext(request)) permiso = "" recurso = "/" response = HttpResponse() response.write('<script type="text/javascript">') response.write('alert("Hola")') response.write('</script>') try: path = request.path.strip( "/" ) # request.get_full_path().strip("/") #"/apps/controller/action/" to "apps/controller/action" except Exception, e: raise Exception( "%s. Asigne adecuadamente el parámetro template_denied_name " % e)