diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py index edf1d9e45..d723ebdbf 100644 --- a/bookwyrm/forms.py +++ b/bookwyrm/forms.py @@ -76,7 +76,16 @@ class ReviewForm(CustomForm): class CommentForm(CustomForm): class Meta: model = models.Comment - fields = ["user", "book", "content", "content_warning", "sensitive", "privacy"] + fields = [ + "user", + "book", + "content", + "content_warning", + "sensitive", + "privacy", + "progress", + "progress_mode", + ] class QuotationForm(CustomForm): diff --git a/bookwyrm/migrations/0055_auto_20210321_0101.py b/bookwyrm/migrations/0055_auto_20210321_0101.py new file mode 100644 index 000000000..dea219c4d --- /dev/null +++ b/bookwyrm/migrations/0055_auto_20210321_0101.py @@ -0,0 +1,34 @@ +# Generated by Django 3.1.6 on 2021-03-21 01:01 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("bookwyrm", "0054_auto_20210319_1942"), + ] + + operations = [ + migrations.AddField( + model_name="comment", + name="progress", + field=models.IntegerField( + blank=True, + null=True, + validators=[django.core.validators.MinValueValidator(0)], + ), + ), + migrations.AddField( + model_name="comment", + name="progress_mode", + field=models.CharField( + blank=True, + choices=[("PG", "page"), ("PCT", "percent")], + default="PG", + max_length=3, + null=True, + ), + ), + ] diff --git a/bookwyrm/models/readthrough.py b/bookwyrm/models/readthrough.py index 3445573c4..1a5fcb0d5 100644 --- a/bookwyrm/models/readthrough.py +++ b/bookwyrm/models/readthrough.py @@ -7,6 +7,8 @@ from .base_model import BookWyrmModel class ProgressMode(models.TextChoices): + """ types of prgress available """ + PAGE = "PG", "page" PERCENT = "PCT", "percent" @@ -32,10 +34,12 @@ class ReadThrough(BookWyrmModel): super().save(*args, **kwargs) def create_update(self): + """ add update to the readthrough """ if self.progress: return self.progressupdate_set.create( user=self.user, progress=self.progress, mode=self.progress_mode ) + return None class ProgressUpdate(BookWyrmModel): diff --git a/bookwyrm/models/status.py b/bookwyrm/models/status.py index 09a7c4ec1..904ce461d 100644 --- a/bookwyrm/models/status.py +++ b/bookwyrm/models/status.py @@ -14,6 +14,7 @@ from .activitypub_mixin import ActivitypubMixin, ActivityMixin from .activitypub_mixin import OrderedCollectionPageMixin from .base_model import BookWyrmModel from .fields import image_serializer +from .readthrough import ProgressMode from . import fields @@ -229,6 +230,19 @@ class Comment(Status): "Edition", on_delete=models.PROTECT, activitypub_field="inReplyToBook" ) + # this is it's own field instead of a foreign key to the progress update + # so that the update can be deleted without impacting the status + progress = models.IntegerField( + validators=[MinValueValidator(0)], null=True, blank=True + ) + progress_mode = models.CharField( + max_length=3, + choices=ProgressMode.choices, + default=ProgressMode.PAGE, + null=True, + blank=True, + ) + @property def pure_content(self): """ indicate the book in question for mastodon (or w/e) users """ diff --git a/bookwyrm/static/css/format.css b/bookwyrm/static/css/format.css index 9715f1608..c68eb40d2 100644 --- a/bookwyrm/static/css/format.css +++ b/bookwyrm/static/css/format.css @@ -14,9 +14,6 @@ html { .card { overflow: visible; } -.card-header-title { - overflow: hidden; -} /* --- SHELVING --- */ .shelf-option:disabled > *::after { diff --git a/bookwyrm/templates/feed/feed_layout.html b/bookwyrm/templates/feed/feed_layout.html index 24294e5d0..6ed696a12 100644 --- a/bookwyrm/templates/feed/feed_layout.html +++ b/bookwyrm/templates/feed/feed_layout.html @@ -47,20 +47,18 @@ {% for book in shelf.books %}
- {% include 'snippets/book_titleby.html' with book=book %} -
+{% include 'snippets/book_titleby.html' with book=book %}
+ {% include 'snippets/shelve_button/shelve_button.html' with book=book %} +{% blocktrans with pages=book.pages %}of {{ pages }} pages{% endblocktrans %}
+ {% endif %} ++ ({% if status.progress_mode == 'PG' %}page {{ status.progress }}{%else %}{{ status.progress }}%{% endif %}) +
+{% endif %} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index 44492668b..c24b83f70 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -183,7 +183,7 @@ urlpatterns = [ re_path(r"^shelve/?$", views.shelve), re_path(r"^unshelve/?$", views.unshelve), # reading progress - re_path(r"^edit-readthrough/?$", views.edit_readthrough), + re_path(r"^edit-readthrough/?$", views.edit_readthrough, name="edit-readthrough"), re_path(r"^delete-readthrough/?$", views.delete_readthrough), re_path(r"^create-readthrough/?$", views.create_readthrough), re_path(r"^delete-progressupdate/?$", views.delete_progressupdate), diff --git a/bookwyrm/views/status.py b/bookwyrm/views/status.py index 0cb5974bd..fb548690d 100644 --- a/bookwyrm/views/status.py +++ b/bookwyrm/views/status.py @@ -13,6 +13,7 @@ from bookwyrm.settings import DOMAIN from bookwyrm.status import delete_status from bookwyrm.utils import regex from .helpers import handle_remote_webfinger +from .reading import edit_readthrough # pylint: disable= no-self-use @@ -64,6 +65,10 @@ class CreateStatus(View): status.quote = to_markdown(status.quote) status.save(created=True) + + # update a readthorugh, if needed + edit_readthrough(request) + return redirect(request.headers.get("Referer", "/"))