Cleans up base model
This commit is contained in:
parent
3edfc0be74
commit
2e7d2f96f8
5 changed files with 7 additions and 12 deletions
|
@ -1,22 +0,0 @@
|
|||
''' base model with default fields '''
|
||||
from django.db import models
|
||||
|
||||
from fedireads.settings import DOMAIN
|
||||
|
||||
# TODO maybe this should be in /models?
|
||||
class FedireadsModel(models.Model):
|
||||
''' fields and functions for every model '''
|
||||
created_date = models.DateTimeField(auto_now_add=True)
|
||||
updated_date = models.DateTimeField(auto_now=True)
|
||||
|
||||
@property
|
||||
def absolute_id(self):
|
||||
''' constructs the absolute reference to any db object '''
|
||||
base_path = 'https://%s' % DOMAIN
|
||||
if hasattr(self, 'user'):
|
||||
base_path = self.user.absolute_id
|
||||
model_name = type(self).__name__.lower()
|
||||
return '%s/%s/%d' % (base_path, model_name, self.id)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
Loading…
Add table
Add a link
Reference in a new issue