[IMP] HORILLA: Updated FileField in models to use dynamic upload path via upload_path function

This commit is contained in:
Horilla
2025-07-30 13:02:47 +05:30
parent f99eeafddd
commit da06922424
11 changed files with 67 additions and 46 deletions

View File

@@ -34,7 +34,7 @@ from base.models import (
from employee.methods.duration_methods import format_time, strtime_seconds
from horilla import horilla_middlewares
from horilla.methods import get_horilla_model_class
from horilla.models import HorillaModel, has_xss
from horilla.models import HorillaModel, has_xss, upload_path
from horilla_audit.methods import get_diff
from horilla_audit.models import HorillaAuditInfo, HorillaAuditLog
@@ -78,9 +78,7 @@ class Employee(models.Model):
employee_last_name = models.CharField(
max_length=200, null=True, blank=True, verbose_name=_("Last Name")
)
employee_profile = models.ImageField(
upload_to="employee/profile", null=True, blank=True
)
employee_profile = models.ImageField(upload_to=upload_path, null=True, blank=True)
email = models.EmailField(max_length=254, unique=True)
phone = models.CharField(
max_length=25,
@@ -775,7 +773,7 @@ class EmployeeBankDetails(HorillaModel):
class NoteFiles(HorillaModel):
files = models.FileField(upload_to="employee/NoteFiles", blank=True, null=True)
files = models.FileField(upload_to=upload_path, blank=True, null=True)
objects = models.Manager()
def __str__(self):
@@ -810,7 +808,7 @@ class PolicyMultipleFile(HorillaModel):
PoliciesMultipleFile model
"""
attachment = models.FileField(upload_to="employee/policies")
attachment = models.FileField(upload_to=upload_path)
class Policy(HorillaModel):
@@ -942,9 +940,7 @@ class DisciplinaryAction(HorillaModel):
validators=[validate_time_format],
)
start_date = models.DateField(null=True)
attachment = models.FileField(
upload_to="employee/discipline", null=True, blank=True
)
attachment = models.FileField(upload_to=upload_path, null=True, blank=True)
objects = HorillaCompanyManager("employee_id__employee_work_info__company_id")
def __str__(self) -> str: