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/importers/goodreads_import.py b/bookwyrm/importers/goodreads_import.py index 7b577ea8..c62e6582 100644 --- a/bookwyrm/importers/goodreads_import.py +++ b/bookwyrm/importers/goodreads_import.py @@ -3,10 +3,10 @@ from . import Importer class GoodreadsImporter(Importer): - """GoodReads is the default importer, thus Importer follows its structure. + """Goodreads is the default importer, thus Importer follows its structure. For a more complete example of overriding see librarything_import.py""" - service = "GoodReads" + service = "Goodreads" def parse_fields(self, entry): """handle the specific fields in goodreads csvs""" diff --git a/bookwyrm/importers/importer.py b/bookwyrm/importers/importer.py index a10b4060..6d898a2a 100644 --- a/bookwyrm/importers/importer.py +++ b/bookwyrm/importers/importer.py @@ -1,4 +1,4 @@ -""" handle reading a csv from an external service, defaults are from GoodReads """ +""" handle reading a csv from an external service, defaults are from Goodreads """ import csv import logging diff --git a/bookwyrm/migrations/0107_alter_user_preferred_language.py b/bookwyrm/migrations/0107_alter_user_preferred_language.py new file mode 100644 index 00000000..be0fc5ea --- /dev/null +++ b/bookwyrm/migrations/0107_alter_user_preferred_language.py @@ -0,0 +1,31 @@ +# Generated by Django 3.2.5 on 2021-10-11 16:22 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0106_user_preferred_language"), + ] + + operations = [ + migrations.AlterField( + model_name="user", + name="preferred_language", + field=models.CharField( + blank=True, + choices=[ + ("en-us", "English"), + ("de-de", "Deutsch (German)"), + ("es", "Español (Spanish)"), + ("fr-fr", "Français (French)"), + ("pt-br", "Português - Brasil (Brazilian Portugues)"), + ("zh-hans", "简体中文 (Simplified Chinese)"), + ("zh-hant", "繁體中文 (Traditional Chinese)"), + ], + max_length=255, + null=True, + ), + ), + ] diff --git a/bookwyrm/migrations/0108_alter_user_preferred_language.py b/bookwyrm/migrations/0108_alter_user_preferred_language.py new file mode 100644 index 00000000..3614ae1c --- /dev/null +++ b/bookwyrm/migrations/0108_alter_user_preferred_language.py @@ -0,0 +1,31 @@ +# Generated by Django 3.2.5 on 2021-10-11 17:38 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0107_alter_user_preferred_language"), + ] + + operations = [ + migrations.AlterField( + model_name="user", + name="preferred_language", + field=models.CharField( + blank=True, + choices=[ + ("en-us", "English"), + ("de-de", "Deutsch (German)"), + ("es-es", "Español (Spanish)"), + ("fr-fr", "Français (French)"), + ("pt-br", "Português - Brasil (Brazilian Portuguese)"), + ("zh-hans", "简体中文 (Simplified Chinese)"), + ("zh-hant", "繁體中文 (Traditional Chinese)"), + ], + max_length=255, + null=True, + ), + ), + ] 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 ec6ffd40..f62678f7 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() ): 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 55b4c445..44d65cca 100644 --- a/bookwyrm/settings.py +++ b/bookwyrm/settings.py @@ -7,13 +7,14 @@ 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") @@ -162,11 +163,12 @@ AUTH_PASSWORD_VALIDATORS = [ LANGUAGE_CODE = "en-us" LANGUAGES = [ ("en-us", _("English")), - ("de-de", _("Deutsch (German)")), # German - ("es", _("Español (Spanish)")), # Spanish - ("fr-fr", _("Français (French)")), # French - ("zh-hans", _("简体中文 (Simplified Chinese)")), # Simplified Chinese - ("zh-hant", _("繁體中文 (Traditional Chinese)")), # Traditional Chinese + ("de-de", _("Deutsch (German)")), + ("es-es", _("Español (Spanish)")), + ("fr-fr", _("Français (French)")), + ("pt-br", _("Português - Brasil (Brazilian Portuguese)")), + ("zh-hans", _("简体中文 (Simplified Chinese)")), + ("zh-hant", _("繁體中文 (Traditional Chinese)")), ] 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/author/edit_author.html b/bookwyrm/templates/author/edit_author.html index 103341bf..54d7f4f1 100644 --- a/bookwyrm/templates/author/edit_author.html +++ b/bookwyrm/templates/author/edit_author.html @@ -12,7 +12,9 @@
{% trans "Added:" %} {{ author.created_date | naturaltime }}
{% trans "Updated:" %} {{ author.updated_date | naturaltime }}
+ {% if author.last_edited_by %}{% trans "Last edited by:" %} {{ author.last_edited_by.display_name }}
+ {% endif %}
{% if format and not pages %}
- {% blocktrans %}{{ format }}{% endblocktrans %}
+ {{ format }}
{% elif format and pages %}
{% blocktrans %}{{ format }}, {{ pages }} pages{% endblocktrans %}
{% elif pages %}
diff --git a/bookwyrm/templates/compose.html b/bookwyrm/templates/compose.html
index 3a222cf6..ca0d8296 100644
--- a/bookwyrm/templates/compose.html
+++ b/bookwyrm/templates/compose.html
@@ -2,10 +2,10 @@
{% load i18n %}
{% load utilities %}
-{% block title %}{% trans "Compose status" %}{% endblock %}
+{% block title %}{% trans "Edit status" %}{% endblock %}
{% block content %}
{% trans "Compose status" %}
+ {% trans "Edit status" %}
diff --git a/bookwyrm/templates/email/invite/html_content.html b/bookwyrm/templates/email/invite/html_content.html index 358e23dc..adc993b7 100644 --- a/bookwyrm/templates/email/invite/html_content.html +++ b/bookwyrm/templates/email/invite/html_content.html @@ -12,6 +12,6 @@
{% url 'code-of-conduct' as coc_path %} {% url 'about' as about_path %} - {% blocktrans %}Learn more about this instance.{% endblocktrans %} + {% blocktrans %}Learn more about {{ site_name }}.{% endblocktrans %}
{% endblock %} diff --git a/bookwyrm/templates/email/invite/text_content.html b/bookwyrm/templates/email/invite/text_content.html index c3fcdc04..26dcd172 100644 --- a/bookwyrm/templates/email/invite/text_content.html +++ b/bookwyrm/templates/email/invite/text_content.html @@ -5,6 +5,6 @@ {{ invite_link }} -{% trans "Learn more about this instance:" %} https://{{ domain }}{% url 'about' %} +{% blocktrans %}Learn more about {{ site_name }}:{% endblocktrans %} https://{{ domain }}{% url 'about' %} {% endblock %} diff --git a/bookwyrm/templates/import/import.html b/bookwyrm/templates/import/import.html index cc296b75..81f0daa5 100644 --- a/bookwyrm/templates/import/import.html +++ b/bookwyrm/templates/import/import.html @@ -22,8 +22,8 @@