Update dta_service/core/models.py
This commit is contained in:
@@ -8,6 +8,28 @@ from django.conf import settings
|
||||
import uuid
|
||||
import os
|
||||
|
||||
class TimeInfoBase(models.Model):
|
||||
|
||||
created = models.DateTimeField(default=timezone.now)
|
||||
last_modified = models.DateTimeField(default=timezone.now)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
if not kwargs.pop("skip_last_modified", False) and not hasattr(
|
||||
self, "skip_last_modified"
|
||||
):
|
||||
self.last_modified = timezone.now()
|
||||
if kwargs.get("update_fields") is not None:
|
||||
kwargs["update_fields"] = list(
|
||||
{*kwargs["update_fields"], "last_modified"}
|
||||
)
|
||||
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
||||
|
||||
class UserManager(BaseUserManager):
|
||||
def create_user(self, email, password=None, **extra_fields):
|
||||
if not email:
|
||||
|
||||
Reference in New Issue
Block a user