[UPDT] PMS: Updated PMS Module Models Objects Manager
This commit is contained in:
@@ -1,24 +1,19 @@
|
|||||||
import operator
|
import operator
|
||||||
from datetime import date
|
|
||||||
from typing import Iterable
|
|
||||||
|
|
||||||
from dateutil.relativedelta import relativedelta
|
from dateutil.relativedelta import relativedelta
|
||||||
from django import forms
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.core.validators import MinValueValidator
|
from django.core.validators import MinValueValidator
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models.signals import post_delete, post_save, pre_save
|
|
||||||
from django.urls import reverse
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
from base.horilla_company_manager import HorillaCompanyManager
|
from base.horilla_company_manager import HorillaCompanyManager
|
||||||
from base.models import Company, Department, JobPosition
|
from base.models import Company, Department, JobPosition
|
||||||
from employee.models import BonusPoint, Employee
|
from employee.models import BonusPoint, Employee
|
||||||
|
from horilla import horilla_middlewares
|
||||||
from horilla.models import HorillaModel
|
from horilla.models import HorillaModel
|
||||||
from horilla_audit.methods import get_diff
|
from horilla_audit.methods import get_diff
|
||||||
from horilla_audit.models import HorillaAuditInfo, HorillaAuditLog
|
from horilla_audit.models import HorillaAuditInfo, HorillaAuditLog
|
||||||
from horilla_automations.methods.methods import get_model_class
|
|
||||||
from horilla_views.cbv_methods import render_template
|
from horilla_views.cbv_methods import render_template
|
||||||
|
|
||||||
"""Objectives and key result section"""
|
"""Objectives and key result section"""
|
||||||
@@ -129,7 +124,7 @@ class Objective(HorillaModel):
|
|||||||
on_delete=models.CASCADE,
|
on_delete=models.CASCADE,
|
||||||
)
|
)
|
||||||
self_employee_progress_update = models.BooleanField(default=True)
|
self_employee_progress_update = models.BooleanField(default=True)
|
||||||
objects = HorillaCompanyManager("employee_id__employee_work_info__company_id")
|
objects = HorillaCompanyManager()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
"""
|
"""
|
||||||
@@ -143,6 +138,19 @@ class Objective(HorillaModel):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.title}"
|
return f"{self.title}"
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
request = getattr(horilla_middlewares._thread_locals, "request", None)
|
||||||
|
selected_company = request.session.get("selected_company")
|
||||||
|
if (
|
||||||
|
not self.id
|
||||||
|
and not self.company_id
|
||||||
|
and selected_company
|
||||||
|
and selected_company != "all"
|
||||||
|
):
|
||||||
|
self.company_id = Company.find(selected_company)
|
||||||
|
|
||||||
|
super().save()
|
||||||
|
|
||||||
|
|
||||||
class EmployeeObjective(HorillaModel):
|
class EmployeeObjective(HorillaModel):
|
||||||
"""this is a EmployObjective model used for creating Employee objectives"""
|
"""this is a EmployObjective model used for creating Employee objectives"""
|
||||||
@@ -773,6 +781,15 @@ class Meetings(HorillaModel):
|
|||||||
)
|
)
|
||||||
response = models.TextField(null=True, blank=True)
|
response = models.TextField(null=True, blank=True)
|
||||||
show_response = models.BooleanField(default=False, editable=False)
|
show_response = models.BooleanField(default=False, editable=False)
|
||||||
|
company_id = models.ForeignKey(
|
||||||
|
Company,
|
||||||
|
null=True,
|
||||||
|
blank=True,
|
||||||
|
editable=False,
|
||||||
|
verbose_name=_("Company"),
|
||||||
|
on_delete=models.CASCADE,
|
||||||
|
)
|
||||||
|
objects = HorillaCompanyManager()
|
||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
verbose_name = _("Meetings")
|
verbose_name = _("Meetings")
|
||||||
@@ -781,6 +798,19 @@ class Meetings(HorillaModel):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.title
|
return self.title
|
||||||
|
|
||||||
|
def save(self, *args, **kwargs):
|
||||||
|
request = getattr(horilla_middlewares._thread_locals, "request", None)
|
||||||
|
selected_company = request.session.get("selected_company")
|
||||||
|
if (
|
||||||
|
not self.id
|
||||||
|
and not self.company_id
|
||||||
|
and selected_company
|
||||||
|
and selected_company != "all"
|
||||||
|
):
|
||||||
|
self.company_id = Company.find(selected_company)
|
||||||
|
|
||||||
|
super().save()
|
||||||
|
|
||||||
|
|
||||||
class MeetingsAnswer(models.Model):
|
class MeetingsAnswer(models.Model):
|
||||||
"""feedback answer model"""
|
"""feedback answer model"""
|
||||||
|
|||||||
Reference in New Issue
Block a user