[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

View File

@@ -1,3 +1,13 @@
"""
models.py
=========
This module defines the abstract base model `HorillaModel` for the Horilla HRMS project.
The `HorillaModel` provides common fields and functionalities for other models within
the application, such as tracking creation and modification timestamps and user
information, audit logging, and active/inactive status management.
"""
from auditlog.models import AuditlogHistoryField
from auditlog.registry import auditlog
from django.contrib.auth.models import User
@@ -25,6 +35,11 @@ setattr(FieldFile, "url", url)
class HorillaModel(models.Model):
"""
An abstract base model that includes common fields and functionalities
for models within the Horilla application.
"""
created_at = models.DateTimeField(
auto_now_add=True,
null=True,
@@ -50,16 +65,23 @@ class HorillaModel(models.Model):
related_name="%(class)s_modified_by",
)
horilla_history = AuditlogHistoryField()
objects = models.Manager()
is_active = models.BooleanField(default=True, verbose_name=_("Is Active"))
class Meta:
"""
Meta class for HorillaModel
"""
abstract = True
def save(self, *args, **kwargs):
"""
Override the save method to automatically set the created_by and
modified_by fields based on the current request user.
"""
request = getattr(_thread_locals, "request", None)
# also here will have scheduled activities
# at the time there will no change to the modified user,
# its remains same as previous
if request:
user = request.user
@@ -79,18 +101,25 @@ class HorillaModel(models.Model):
@classmethod
def find(cls, object_id):
"""
Find an object of this class by its ID.
"""
try:
object = cls.objects.filter(id=object_id).first()
return object
except:
obj = cls.objects.filter(id=object_id).first()
return obj
except Exception as e:
# Log the exception if needed
return None
@classmethod
def activate_deactivate(cls, object_id):
object = cls.find(object_id)
if object:
object.is_active = not object.is_active
object.save()
"""
Toggle the is_active status of an object of this class.
"""
obj = cls.find(object_id)
if obj:
obj.is_active = not obj.is_active
obj.save()
auditlog.register(HorillaModel, serialize_data=True)