[IMP] Remove inter module dependency (#274)

This commit introduces significant changes to the architecture of the Horilla HRMS system by decoupling interdependent modules. The following modifications were made:

1. **Module Independence**: Each module has been refactored to eliminate reliance on other modules, promoting a more modular and maintainable codebase.
2. **Refactored Imports and Dependencies**: Adjusted import statements and dependency injections to support independent module operation.
3. **Compatibility and Functionality**: Ensured that all modules are compatible with existing systems and maintain their intended functionality both independently and when integrated with other modules.

These changes enhance the modularity, maintainability, and scalability of the Horilla HRMS, allowing developers to work on individual modules without affecting the entire system. Future development and deployment will be more efficient and less prone to issues arising from tightly coupled code.

**NOTE**
For existing Horilla users, if you face any issues during the migrations, please run the following command and try again the migrations.

- `python3 manage.py makemigrations`
- `python3 manage.py migrate base`
- `python3 manage.py migrate`





* [IMP] ASSET: Asset module dependency removal from other Horilla apps

* [IMP] ATTENDANCE: Attendance module dependency removal from other Horilla apps

* [IMP] BASE: Base module dependency removal from other Horilla apps

* [IMP] EMPLOYEE: Employee module dependency removal from other Horilla apps

* [IMP] HELPDESK: Helpdesk module dependency removal from other Horilla apps

* [IMP] HORILLA AUDIT: Horilla Audit module dependency removal from other Horilla apps

* [IMP] HORILLA CRUMBS: Horilla Crumbs module dependency removal from other Horilla apps

* [IMP] HORILLA AUTOMATIONS: Horilla Automations module dependency removal from other Horilla apps

* [IMP] HORILLA VIEWS: Horilla Views module dependency removal from other Horilla apps

* [IMP] LEAVE: Leave module dependency removal from other Horilla apps

* [IMP] OFFBOARDING: Offboarding module dependency removal from other Horilla apps

* [IMP] ONBOARDING: Onboarding module dependency removal from other Horilla apps

* [IMP] PMS: PMS module dependency removal from other Horilla apps

* [IMP] PAYROLL: Payroll module dependency removal from other Horilla apps

* [IMP] RECRUITMENT: Recruitment module dependency removal from other Horilla apps

* [IMP] HORILLA: Dependency removal updates

* [IMP] TEMPLATES: Dependency removal updates

* [IMP] STATIC: Dependency removal updates

* [IMP] HORILLA DOCUMENTS: Horilla Documents module dependency removal from other Horilla apps

* [ADD] HORILLA: methods.py

* [UPDT] HORILLA: Settings.py

* [FIX] EMPLOYEE: About tab issue

* Update horilla_settings.py

* Remove dummy db init password
This commit is contained in:
Horilla
2024-08-05 14:22:44 +05:30
committed by GitHub
parent 746272d801
commit 2fee7c18bb
308 changed files with 12414 additions and 9577 deletions

45
horilla/methods.py Normal file
View File

@@ -0,0 +1,45 @@
import contextlib
from django.contrib.contenttypes.models import ContentType
def get_horilla_model_class(app_label, model):
"""
Retrieves the model class for the given app label and model name using Django's ContentType framework.
Args:
app_label (str): The label of the application where the model is defined.
model (str): The name of the model to retrieve.
Returns:
Model: The Django model class corresponding to the specified app label and model name.
"""
content_type = ContentType.objects.get(app_label=app_label, model=model)
model_class = content_type.model_class()
return model_class
def dynamic_attr(obj, attribute_path):
"""
Retrieves the value of a nested attribute from a related object dynamically.
Args:
obj: The base object from which to start accessing attributes.
attribute_path (str): The path of the nested attribute to retrieve, using
double underscores ('__') to indicate relationship traversal.
Returns:
The value of the nested attribute if it exists, or None if it doesn't exist.
"""
attributes = attribute_path.split("__")
for attr in attributes:
with contextlib.suppress(Exception):
Contract = get_horilla_model_class(app_label="payroll", model="contract")
if isinstance(obj.first(), Contract):
obj = obj.filter(is_active=True).first()
obj = getattr(obj, attr, None)
if obj is None:
break
return obj