403Webshell
Server IP : 65.108.144.40  /  Your IP : 216.73.217.165
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux ubuntu-8gb-hel1-1 5.15.0-173-generic #183-Ubuntu SMP Fri Mar 6 13:29:34 UTC 2026 x86_64
User : dev ( 1000)
PHP Version : 8.2.30
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/erp/accessibility/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/erp/accessibility/decorators.py
"""
employee/decorators.py
"""

from django.contrib import messages
from django.http import HttpResponse
from django.shortcuts import redirect
from django.utils.translation import gettext_lazy as _

from accessibility.methods import check_is_accessible
from base.decorators import decorator_with_arguments


@decorator_with_arguments
def enter_if_accessible(function, feature, perm=None, method=None):
    """
    accessiblie check decorator
    """

    def check_accessible(request, *args, **kwargs):
        """
        Check accessible
        """
        path = "/"
        referrer = request.META.get("HTTP_REFERER")
        if referrer and request.path not in referrer:
            path = request.META["HTTP_REFERER"]
        accessible = False
        cache_key = request.session.session_key + "accessibility_filter"
        employee = getattr(request.user, "employee_get")
        if employee:
            accessible = check_is_accessible(feature, cache_key, employee)
        has_perm = True
        if perm:
            has_perm = request.user.has_perm(perm)

        if accessible or has_perm or (method and method(request)):
            return function(request, *args, **kwargs)
        key = "HTTP_HX_REQUEST"
        keys = request.META.keys()
        messages.info(request, _("You dont have access to the feature"))
        if key in keys:
            return HttpResponse(
                f"""
                <script>
                window.location.href="{referrer}"
                </script>
                """
            )
        return redirect(path)

    return check_accessible

Youez - 2016 - github.com/yon3zu
LinuXploit