[UPDT] PMS: Employee bonus point

This commit is contained in:
Horilla
2024-08-30 14:57:56 +05:30
parent 1fc2b383eb
commit 1c62b8d337
2 changed files with 16 additions and 1 deletions

View File

@@ -5,6 +5,8 @@ employee/methods.py
import re import re
from itertools import groupby from itertools import groupby
from django.db import models
from base.context_processors import get_initial_prefix from base.context_processors import get_initial_prefix
from employee.models import Employee from employee.models import Employee
@@ -60,3 +62,17 @@ def get_ordered_badge_ids():
if pure_numbers: if pure_numbers:
result.insert(0, [pure_numbers[0], pure_numbers[-1]]) result.insert(0, [pure_numbers[0], pure_numbers[-1]])
return result return result
def check_relationship_with_employee_model(model):
related_fields = []
for field in model._meta.get_fields():
# Check if the field is a ForeignKey or ManyToManyField and related to Employee
if isinstance(field, models.ForeignKey) and field.related_model == Employee:
related_fields.append((field.name, "ForeignKey"))
elif (
isinstance(field, models.ManyToManyField)
and field.related_model == Employee
):
related_fields.append((field.name, "ManyToManyField"))
return related_fields

View File

@@ -90,7 +90,6 @@ def get_model_class(model_path):
method to return the model class from string 'app.models.Model' method to return the model class from string 'app.models.Model'
""" """
module_name, class_name = model_path.rsplit(".", 1) module_name, class_name = model_path.rsplit(".", 1)
module = __import__(module_name, fromlist=[class_name]) module = __import__(module_name, fromlist=[class_name])
model_class: Employee = getattr(module, class_name) model_class: Employee = getattr(module, class_name)
return model_class return model_class