fix collection cover

This commit is contained in:
Your Name 2023-01-14 09:48:30 -05:00 committed by Henri Dickson
parent c0b9c0e09e
commit 1738dbd46c
3 changed files with 9 additions and 2 deletions

View file

@ -3,3 +3,7 @@ from catalog.common import *
class Collection(Item):
category = ItemCategory.Collection
@property
def owner_id(self):
return self.journal_item.owner_id if self.journal_item else None

View file

@ -221,7 +221,7 @@ class Item(SoftDeleteMixin, PolymorphicModel):
self.primary_lookup_id_type = None
def __str__(self):
return f"{self.id}|{self.uuid} {self.primary_lookup_id_type}:{self.primary_lookup_id_value if self.primary_lookup_id_value else ''} ({self.title})"
return f"{self.__class__.__name__}|{self.id}|{self.uuid} {self.primary_lookup_id_type}:{self.primary_lookup_id_value if self.primary_lookup_id_value else ''} ({self.title})"
@classmethod
def lookup_id_type_choices(cls):

View file

@ -1,4 +1,5 @@
from django.db import models
from django.db.models.fields import related
from polymorphic.models import PolymorphicModel
from users.models import User
from catalog.common.models import Item, ItemCategory
@ -667,7 +668,9 @@ _RE_HTML_TAG = re.compile(r"<[^>]*>")
class Collection(List):
url_path = "collection"
MEMBER_CLASS = CollectionMember
catalog_item = models.OneToOneField(CatalogCollection, on_delete=models.PROTECT)
catalog_item = models.OneToOneField(
CatalogCollection, on_delete=models.PROTECT, related_name="journal_item"
)
title = models.CharField(_("标题"), max_length=1000, default="")
brief = models.TextField(_("简介"), blank=True, default="")
cover = models.ImageField(