added first public views - no check for access rights at the moment
This commit is contained in:
35
lib/core/db/models/mixins.py
Normal file
35
lib/core/db/models/mixins.py
Normal file
@@ -0,0 +1,35 @@
|
||||
from django.contrib.auth.models import User
|
||||
from django.db import models
|
||||
|
||||
from lib.middleware.current_user import get_current_user
|
||||
|
||||
|
||||
class DateAware(models.Model):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
|
||||
class AuthorAware(models.Model):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
author = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, default=get_current_user)
|
||||
|
||||
|
||||
class DescriptionAware(models.Model):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
description = models.TextField(null=True, blank=True)
|
||||
|
||||
|
||||
class NameAware(models.Model):
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
name = models.CharField(max_length=100, unique=True, db_index=True)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user