1
0
Fork 0

Forgot to add the migration and models helper

This commit is contained in:
Mouse Reeve 2020-02-17 16:50:44 -08:00
parent 71027a1459
commit 3e434077f9
2 changed files with 96 additions and 0 deletions

21
fedireads/utils/models.py Normal file
View file

@ -0,0 +1,21 @@
from django.db import models
from fedireads.settings import DOMAIN
class FedireadsModel(models.Model):
content = models.TextField(blank=True, null=True)
created_date = models.DateTimeField(auto_now_add=True)
@property
def absolute_id(self):
''' constructs the absolute reference to any db object '''
base_path = 'https://%s' % DOMAIN
if self.user:
base_path = self.user.absolute_id
model_name = type(self).__name__
return '%s/%s/%d' % (base_path, model_name, self.id)
class Meta:
abstract = True