User p tags for pure status serializer

This commit is contained in:
Mouse Reeve
2020-12-18 11:00:30 -08:00
parent 40c4f4f5de
commit 80de6079fa
4 changed files with 197 additions and 29 deletions

View File

@ -73,7 +73,10 @@ class Book(ActivitypubMixin, BookWyrmModel):
@property
def alt_text(self):
''' image alt test '''
return '%s cover (%s)' % (self.title, self.edition_info)
text = '%s cover' % self.title
if self.edition_info:
text += ' (%s)' % self.edition_info
return text
def save(self, *args, **kwargs):
''' can't be abstract for query reasons, but you shouldn't USE it '''

View File

@ -132,8 +132,8 @@ class Comment(Status):
@property
def pure_content(self):
''' indicate the book in question for mastodon (or w/e) users '''
return self.content + '<br><br>(comment on <a href="%s">"%s"</a>)' % \
(self.book.remote_id, self.book.title)
return '<p>%s</p><p>(comment on <a href="%s">"%s"</a>)</p>' % \
(self.content, self.book.remote_id, self.book.title)
activity_serializer = activitypub.Comment
pure_type = 'Note'
@ -148,7 +148,7 @@ class Quotation(Status):
@property
def pure_content(self):
''' indicate the book in question for mastodon (or w/e) users '''
return '"%s"<br>-- <a href="%s">"%s"</a><br><br>%s' % (
return '<p>"%s"<br>-- <a href="%s">"%s"</a></p><p>%s</p>' % (
self.quote,
self.book.remote_id,
self.book.title,

View File

@ -91,6 +91,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
last_active_date = models.DateTimeField(auto_now=True)
manually_approves_followers = fields.BooleanField(default=False)
name_field = 'username'
@property
def alt_text(self):
''' alt text with username '''