diff --git a/bookwyrm/models/__init__.py b/bookwyrm/models/__init__.py index b9a2814e..86bdf219 100644 --- a/bookwyrm/models/__init__.py +++ b/bookwyrm/models/__init__.py @@ -25,8 +25,3 @@ from .site import SiteSettings, SiteInvite, PasswordReset cls_members = inspect.getmembers(sys.modules[__name__], inspect.isclass) activity_models = {c[1].activity_serializer.__name__: c[1] \ for c in cls_members if hasattr(c[1], 'activity_serializer')} - -def to_activity(activity_json): - ''' link up models and activities ''' - activity_type = activity_json.get('type') - return activity_models[activity_type].to_activity(activity_json) diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 55036f2c..43fc4511 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -24,7 +24,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): choices=PrivacyLevels.choices ) sensitive = fields.BooleanField(default=False) - # the created date can't be this, because of receiving federated posts + # created date is different than publish date because of federated posts published_date = fields.DateTimeField( default=timezone.now, activitypub_field='published') deleted = models.BooleanField(default=False) @@ -53,7 +53,9 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): def replies(cls, status): ''' load all replies to a status. idk if there's a better way to write this so it's just a property ''' - return cls.objects.filter(reply_parent=status).select_subclasses() + return cls.objects.filter( + reply_parent=status + ).select_subclasses().order_by('published_date') @property def status_type(self): @@ -68,7 +70,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): **kwargs ) - def to_activity(self, pure=False): + def to_activity(self, pure=False):# pylint: disable=arguments-differ ''' return tombstone if the status is deleted ''' if self.deleted: return activitypub.Tombstone( @@ -190,6 +192,7 @@ class Review(Status): def pure_name(self): ''' clarify review names for mastodon serialization ''' if self.rating: + #pylint: disable=bad-string-format-type return 'Review of "%s" (%d stars): %s' % ( self.book.title, self.rating,