Development (#128)
* [UPDT] RECRUITMENT: Updated recruitment stage update method by changing hx-target * [UPDT] LEAVE: Updated company leave create , update and delete method by adding hx-target * [UPDT] ATTENDANCE: Updated attendance request create method by changing hx-target * [UPDT] LEAVE: Updated leave request create form hx-target * [IMP] Add HorillaModel abstract model * [UPDT] EMPLOYEE: Updated employee disciplinary form by adding parent model class for disciplinary model
This commit is contained in:
22
horilla/models.py
Normal file
22
horilla/models.py
Normal file
@@ -0,0 +1,22 @@
|
||||
from django.db import models
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
class HorillaModel(models.Model):
|
||||
created_at = models.DateTimeField(auto_now_add=True, null=True, blank=True)
|
||||
created_by = models.ForeignKey(
|
||||
User, on_delete=models.SET_NULL, null=True, blank=True, editable=False
|
||||
)
|
||||
is_active = models.BooleanField(default=True)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
request = kwargs.get("request", None)
|
||||
if request and not self.pk:
|
||||
user = request.user
|
||||
if user.is_authenticated:
|
||||
self.created_by = user
|
||||
request = kwargs.pop("request", None)
|
||||
super(HorillaModel, self).save(*args, **kwargs)
|
||||
Reference in New Issue
Block a user