Cleans up base model

This commit is contained in:
Mouse Reeve 2020-05-10 13:38:47 -07:00
parent 3edfc0be74
commit 2e7d2f96f8
5 changed files with 7 additions and 12 deletions

View file

@ -3,7 +3,6 @@ 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)
@ -12,6 +11,9 @@ class FedireadsModel(models.Model):
@property
def absolute_id(self):
''' constructs the absolute reference to any db object '''
if self.remote_id:
return self.remote_id
base_path = 'https://%s' % DOMAIN
if hasattr(self, 'user'):
base_path = self.user.absolute_id

View file

@ -6,7 +6,7 @@ from model_utils.managers import InheritanceManager
from fedireads import activitypub
from fedireads.settings import DOMAIN
from fedireads.utils.fields import JSONField, ArrayField
from fedireads.utils.models import FedireadsModel
from .base_model import FedireadsModel
from fedireads.connectors.settings import CONNECTORS

View file

@ -2,7 +2,7 @@
from django.db import models
from fedireads import activitypub
from fedireads.utils.models import FedireadsModel
from .base_model import FedireadsModel
class Shelf(FedireadsModel):

View file

@ -7,7 +7,7 @@ from django.db import models
from model_utils.managers import InheritanceManager
from fedireads import activitypub
from fedireads.utils.models import FedireadsModel
from .base_model import FedireadsModel
class Status(FedireadsModel):
@ -113,13 +113,6 @@ class Favorite(FedireadsModel):
status = models.ForeignKey('Status', on_delete=models.PROTECT)
remote_id = models.CharField(max_length=255, unique=True, null=True)
@property
def absolute_id(self):
''' constructs the absolute reference to any db object '''
if self.remote_id:
return self.remote_id
return super().absolute_id
class Meta:
unique_together = ('user', 'status')

View file

@ -7,7 +7,7 @@ from django.dispatch import receiver
from fedireads.models.shelf import Shelf
from fedireads.settings import DOMAIN
from fedireads.utils.models import FedireadsModel
from .base_model import FedireadsModel
class User(AbstractUser):