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//methods.py
"""
accessibility/methods.py
"""

from django.core.cache import cache

from accessibility.accessibility import ACCESSBILITY_FEATURE
from accessibility.filters import AccessibilityFilter
from accessibility.models import DefaultAccessibility
from horilla.horilla_middlewares import _thread_locals


def check_is_accessible(feature, cache_key, employee):
    """
    Method to check the employee is accessible for the feature or not
    """
    if not employee:
        return False

    accessibility = DefaultAccessibility.objects.filter(feature=feature).first()

    if accessibility and accessibility.exclude_all:
        return False
    if not feature or not accessibility:
        return True

    data: dict = cache.get(cache_key, default={})
    if data and data.get(feature) is not None:
        return data.get(feature)

    employees = accessibility.employees.all()
    accessible = employee in employees
    return accessible


def update_employee_accessibility_cache(cache_key, employee):
    """
    Cache for get all the queryset
    """
    feature_accessible = {}
    for accessibility, _display in ACCESSBILITY_FEATURE:
        feature_accessible[accessibility] = check_is_accessible(
            accessibility, cache_key, employee
        )
    cache.set(cache_key, feature_accessible)

Youez - 2016 - github.com/yon3zu
LinuXploit