Skip to content

Commit

Permalink
restores py27 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
smirolo committed Apr 12, 2024
1 parent 5a3af25 commit 5f85140
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ Tested with
* loads commenter picture/name from profile API
* makes API endpoint with or without account slug depending on URL pattern
* handles updates to django-storages>=1.14 properly
* newsfeed API for updates to PageElement a user follows (experimental)

[previous release notes](changelog)

Expand Down
1 change: 1 addition & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* loads commenter picture/name from profile API
* makes API endpoint with or without account slug depending on URL pattern
* handles updates to django-storages>=1.14 properly
* newsfeed API for updates to PageElement a user follows (experimental)

-- Sebastien Mirolo <[email protected]> Thu, 11 Apr 2024 16:40:00 -0700

Expand Down
21 changes: 12 additions & 9 deletions pages/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,25 +311,28 @@ class PageElementUpdateSerializer(PageElementSerializer):

class Meta(PageElementSerializer.Meta):
fields = PageElementSerializer.Meta.fields + (
'text_updated_at', 'nb_comments_since_last_read', 'last_read_at', 'descr')
'text_updated_at', 'nb_comments_since_last_read',
'last_read_at', 'descr')
read_only_fields = PageElementSerializer.Meta.read_only_fields + (
'text_updated_at', 'nb_comments_since_last_read', 'last_read_at', 'descr')
'text_updated_at', 'nb_comments_since_last_read',
'last_read_at', 'descr')

def get_descr(self, obj):
final_str_list = []

if obj.text_updated_at and obj.last_read_at:
text_updated_at_str = obj.text_updated_at.strftime(
'%m-%d-%Y:%H:%M:%S')
final_str_list.append(
f"Text last updated on {text_updated_at_str}.")
_("Text last updated on %(text_updated_at)s.") % {
'text_updated_at': obj.text_updated_at.isoformat()})

if obj.nb_comments_since_last_read:
comments_str = "comment" if obj.nb_comments_since_last_read \
comment_or_comments = "comment" if obj.nb_comments_since_last_read \
== 1 else "comments"
final_str_list.append(
f"{obj.nb_comments_since_last_read} new "
f"{comments_str} since last visit.")
final_str_list.append(_("%(nb_comments)s new "\
"%(comment_or_comments)s since last visit.") % {
'nb_comments': obj.nb_comments_since_last_read,
'comment_or_comments': comment_or_comments
})

return ' '.join(final_str_list)

Expand Down

0 comments on commit 5f85140

Please sign in to comment.