diff --git a/bookwyrm/activitypub/note.py b/bookwyrm/activitypub/note.py index d61471fe..eb18b8b8 100644 --- a/bookwyrm/activitypub/note.py +++ b/bookwyrm/activitypub/note.py @@ -35,6 +35,7 @@ class Note(ActivityObject): tag: List[Link] = field(default_factory=lambda: []) attachment: List[Document] = field(default_factory=lambda: []) sensitive: bool = False + updated: str = None type: str = "Note" diff --git a/bookwyrm/activitypub/verbs.py b/bookwyrm/activitypub/verbs.py index 50a479b7..b32b0413 100644 --- a/bookwyrm/activitypub/verbs.py +++ b/bookwyrm/activitypub/verbs.py @@ -69,8 +69,9 @@ class Update(Verb): def action(self): """update a model instance from the dataclass""" - if self.object: - self.object.to_model(allow_create=False) + if not self.object: + return + self.object.to_model(allow_create=False) @dataclass(init=False) diff --git a/bookwyrm/migrations/0109_status_edited_date.py b/bookwyrm/migrations/0109_status_edited_date.py new file mode 100644 index 00000000..3d4d733b --- /dev/null +++ b/bookwyrm/migrations/0109_status_edited_date.py @@ -0,0 +1,19 @@ +# Generated by Django 3.2.5 on 2021-10-15 15:54 + +import bookwyrm.models.fields +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0108_alter_user_preferred_language"), + ] + + operations = [ + migrations.AddField( + model_name="status", + name="edited_date", + field=bookwyrm.models.fields.DateTimeField(blank=True, null=True), + ), + ] diff --git a/bookwyrm/migrations/0110_auto_20211015_1734.py b/bookwyrm/migrations/0110_auto_20211015_1734.py new file mode 100644 index 00000000..ed7dd43c --- /dev/null +++ b/bookwyrm/migrations/0110_auto_20211015_1734.py @@ -0,0 +1,23 @@ +# Generated by Django 3.2.5 on 2021-10-15 17:34 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0109_status_edited_date"), + ] + + operations = [ + migrations.AddField( + model_name="quotation", + name="raw_quote", + field=models.TextField(blank=True, null=True), + ), + migrations.AddField( + model_name="status", + name="raw_content", + field=models.TextField(blank=True, null=True), + ), + ] diff --git a/bookwyrm/models/base_model.py b/bookwyrm/models/base_model.py index b781a506..07f6b0d5 100644 --- a/bookwyrm/models/base_model.py +++ b/bookwyrm/models/base_model.py @@ -67,16 +67,15 @@ class BookWyrmModel(models.Model): return # you can see the followers only posts of people you follow - if ( - self.privacy == "followers" - and self.user.followers.filter(id=viewer.id).first() + if self.privacy == "followers" and ( + self.user.followers.filter(id=viewer.id).first() ): return # you can see dms you are tagged in if hasattr(self, "mention_users"): if ( - self.privacy == "direct" + self.privacy in ["direct", "followers"] and self.mention_users.filter(id=viewer.id).first() ): return diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 1325aa88..2b395ec8 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -31,6 +31,7 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): "User", on_delete=models.PROTECT, activitypub_field="attributedTo" ) content = fields.HtmlField(blank=True, null=True) + raw_content = models.TextField(blank=True, null=True) mention_users = fields.TagField("User", related_name="mention_user") mention_books = fields.TagField("Edition", related_name="mention_book") local = models.BooleanField(default=True) @@ -43,6 +44,9 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): published_date = fields.DateTimeField( default=timezone.now, activitypub_field="published" ) + edited_date = fields.DateTimeField( + blank=True, null=True, activitypub_field="updated" + ) deleted = models.BooleanField(default=False) deleted_date = models.DateTimeField(blank=True, null=True) favorites = models.ManyToManyField( @@ -220,6 +224,16 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel): ~Q(Q(user=viewer) | Q(mention_users=viewer)), privacy="direct" ) + @classmethod + def followers_filter(cls, queryset, viewer): + """Override-able filter for "followers" privacy level""" + return queryset.exclude( + ~Q( # not yourself, a follower, or someone who is tagged + Q(user__followers=viewer) | Q(user=viewer) | Q(mention_users=viewer) + ), + privacy="followers", # and the status is followers only + ) + class GeneratedNote(Status): """these are app-generated messages about user activity""" @@ -292,6 +306,7 @@ class Quotation(BookStatus): """like a review but without a rating and transient""" quote = fields.HtmlField() + raw_quote = models.TextField(blank=True, null=True) position = models.IntegerField( validators=[MinValueValidator(0)], null=True, blank=True ) diff --git a/bookwyrm/settings.py b/bookwyrm/settings.py index 1794db9f..44d65cca 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -9,12 +9,12 @@ from django.utils.translation import gettext_lazy as _ env = Env() env.read_env() DOMAIN = env("DOMAIN") -VERSION = "0.0.1" +VERSION = "0.1.0" PAGE_LENGTH = env("PAGE_LENGTH", 15) DEFAULT_LANGUAGE = env("DEFAULT_LANGUAGE", "English") -JS_CACHE = "c02929b1" +JS_CACHE = "3eb4edb1" # email EMAIL_BACKEND = env("EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend") diff --git a/bookwyrm/static/css/bookwyrm.css b/bookwyrm/static/css/bookwyrm.css index eca7914a..0d280fd5 100644 --- a/bookwyrm/static/css/bookwyrm.css +++ b/bookwyrm/static/css/bookwyrm.css @@ -509,6 +509,20 @@ ol.ordered-list li::before { border-left: 2px solid #e0e0e0; } +/* Breadcrumbs + ******************************************************************************/ + +.breadcrumb li:first-child * { + padding-left: 0; +} + +.breadcrumb li > * { + align-items: center; + display: flex; + justify-content: center; + padding: 0 0.75em; +} + /* Dimensions * @todo These could be in rem. ******************************************************************************/ diff --git a/bookwyrm/templates/snippets/create_status/comment.html b/bookwyrm/templates/snippets/create_status/comment.html index 4bf1fc24..82ccdbe7 100644 --- a/bookwyrm/templates/snippets/create_status/comment.html +++ b/bookwyrm/templates/snippets/create_status/comment.html @@ -35,7 +35,7 @@ uuid: a unique identifier used to make html "id" attributes unique and clarify j size="3" value="{% firstof draft.progress readthrough.progress '' %}" id="progress_{{ uuid }}" - data-cache-draft="id_progress_comment_{{ book.id }}" + {% if not draft %}data-cache-draft="id_progress_comment_{{ book.id }}"{% endif %} >
@@ -43,7 +43,7 @@ uuid: a unique identifier used to make html "id" attributes unique and clarify j
diff --git a/bookwyrm/templates/snippets/create_status/review.html b/bookwyrm/templates/snippets/create_status/review.html index 67214f33..13d349ca 100644 --- a/bookwyrm/templates/snippets/create_status/review.html +++ b/bookwyrm/templates/snippets/create_status/review.html @@ -24,7 +24,7 @@ uuid: a unique identifier used to make html "id" attributes unique and clarify j id="id_name_{{ book.id }}" placeholder="{% blocktrans with book_title=book.title %}Your review of '{{ book_title }}'{% endblocktrans %}" value="{% firstof draft.name ''%}" - data-cache-draft="id_name_{{ book.id }}_{{ type }}" + {% if not draft %}data-cache-draft="id_name_{{ book.id }}_{{ type }}"{% endif %} > diff --git a/bookwyrm/templates/snippets/page_text.html b/bookwyrm/templates/snippets/page_text.html index dc7a6a33..2ce8eb36 100644 --- a/bookwyrm/templates/snippets/page_text.html +++ b/bookwyrm/templates/snippets/page_text.html @@ -1,7 +1,19 @@ +{% spaceless %} + {% load humanize %} {% load i18n %} + {% if total_pages %} -{% blocktrans with page=page|intcomma total_pages=total_pages|intcomma %}page {{ page }} of {{ total_pages }}{% endblocktrans %} + +{% blocktrans trimmed with page=page|intcomma total_pages=total_pages|intcomma %} +page {{ page }} of {{ total_pages }} +{% endblocktrans %} + {% else %} -{% blocktrans with page=page|intcomma %}page {{ page }}{% endblocktrans %} + +{% blocktrans trimmed with page=page|intcomma %} +page {{ page }} +{% endblocktrans %} + {% endif %} +{% endspaceless %} diff --git a/bookwyrm/templates/snippets/rate_action.html b/bookwyrm/templates/snippets/rate_action.html index 711c3b3e..767039a3 100644 --- a/bookwyrm/templates/snippets/rate_action.html +++ b/bookwyrm/templates/snippets/rate_action.html @@ -3,7 +3,7 @@ {% if request.user.is_authenticated %} {% trans "Leave a rating" %}
-
+ {% csrf_token %} diff --git a/bookwyrm/templates/snippets/status/header.html b/bookwyrm/templates/snippets/status/header.html index 62eae548..ae25932f 100644 --- a/bookwyrm/templates/snippets/status/header.html +++ b/bookwyrm/templates/snippets/status/header.html @@ -31,18 +31,38 @@ {% include "snippets/status/header_content.html" %} -

- {{ status.published_date|published_date }} - {% if status.progress %} - - {% if status.progress_mode == 'PG' %} - ({% include 'snippets/page_text.html' with page=status.progress total_pages=status.book.pages %}) - {% else %} - ({{ status.progress }}%) - {% endif %} - - {% endif %} - {% include 'snippets/privacy-icons.html' with item=status %} -

+
diff --git a/bookwyrm/templates/snippets/status/layout.html b/bookwyrm/templates/snippets/status/layout.html index 9d1863ee..93620a08 100644 --- a/bookwyrm/templates/snippets/status/layout.html +++ b/bookwyrm/templates/snippets/status/layout.html @@ -67,7 +67,7 @@ {% endblock %} {% block card-bonus %} -{% if request.user.is_authenticated and not moderation_mode %} +{% if request.user.is_authenticated and not moderation_mode and not no_interact %} {% with status.id|uuid as uuid %}