Merge branch 'main' into production

This commit is contained in:
Mouse Reeve 2022-05-30 08:23:26 -07:00
commit 02a315be00
53 changed files with 523 additions and 83 deletions

View file

@ -1,6 +1,7 @@
""" basics for an activitypub serializer """ """ basics for an activitypub serializer """
from dataclasses import dataclass, fields, MISSING from dataclasses import dataclass, fields, MISSING
from json import JSONEncoder from json import JSONEncoder
import logging
from django.apps import apps from django.apps import apps
from django.db import IntegrityError, transaction from django.db import IntegrityError, transaction
@ -8,6 +9,8 @@ from django.db import IntegrityError, transaction
from bookwyrm.connectors import ConnectorException, get_data from bookwyrm.connectors import ConnectorException, get_data
from bookwyrm.tasks import app from bookwyrm.tasks import app
logger = logging.getLogger(__name__)
class ActivitySerializerError(ValueError): class ActivitySerializerError(ValueError):
"""routine problems serializing activitypub json""" """routine problems serializing activitypub json"""
@ -65,7 +68,7 @@ class ActivityObject:
try: try:
value = kwargs[field.name] value = kwargs[field.name]
if value in (None, MISSING, {}): if value in (None, MISSING, {}):
raise KeyError() raise KeyError("Missing required field", field.name)
try: try:
is_subclass = issubclass(field.type, ActivityObject) is_subclass = issubclass(field.type, ActivityObject)
except TypeError: except TypeError:
@ -268,9 +271,9 @@ def resolve_remote_id(
try: try:
data = get_data(remote_id) data = get_data(remote_id)
except ConnectorException: except ConnectorException:
raise ActivitySerializerError( logger.exception("Could not connect to host for remote_id: %s", remote_id)
f"Could not connect to host for remote_id: {remote_id}" return None
)
# determine the model implicitly, if not provided # determine the model implicitly, if not provided
# or if it's a model with subclasses like Status, check again # or if it's a model with subclasses like Status, check again
if not model or hasattr(model.objects, "select_subclasses"): if not model or hasattr(model.objects, "select_subclasses"):

View file

@ -53,7 +53,12 @@ class ReadThroughForm(CustomForm):
self.add_error( self.add_error(
"finish_date", _("Reading finish date cannot be before start date.") "finish_date", _("Reading finish date cannot be before start date.")
) )
stopped_date = cleaned_data.get("stopped_date")
if start_date and stopped_date and start_date > stopped_date:
self.add_error(
"stopped_date", _("Reading stopped date cannot be before start date.")
)
class Meta: class Meta:
model = models.ReadThrough model = models.ReadThrough
fields = ["user", "book", "start_date", "finish_date"] fields = ["user", "book", "start_date", "finish_date", "stopped_date"]

View file

@ -1,6 +1,7 @@
""" import classes """ """ import classes """
from .importer import Importer from .importer import Importer
from .calibre_import import CalibreImporter
from .goodreads_import import GoodreadsImporter from .goodreads_import import GoodreadsImporter
from .librarything_import import LibrarythingImporter from .librarything_import import LibrarythingImporter
from .openlibrary_import import OpenLibraryImporter from .openlibrary_import import OpenLibraryImporter

View file

@ -0,0 +1,28 @@
""" handle reading a csv from calibre """
from bookwyrm.models import Shelf
from . import Importer
class CalibreImporter(Importer):
"""csv downloads from Calibre"""
service = "Calibre"
def __init__(self, *args, **kwargs):
# Add timestamp to row_mappings_guesses for date_added to avoid
# integrity error
row_mappings_guesses = []
for field, mapping in self.row_mappings_guesses:
if field in ("date_added",):
row_mappings_guesses.append((field, mapping + ["timestamp"]))
else:
row_mappings_guesses.append((field, mapping))
self.row_mappings_guesses = row_mappings_guesses
super().__init__(*args, **kwargs)
def get_shelf(self, normalized_row):
# Calibre export does not indicate which shelf to use. Go with a default one for now
return Shelf.TO_READ

View file

@ -1,5 +1,8 @@
""" handle reading a tsv from librarything """ """ handle reading a tsv from librarything """
import re import re
from bookwyrm.models import Shelf
from . import Importer from . import Importer
@ -21,7 +24,7 @@ class LibrarythingImporter(Importer):
def get_shelf(self, normalized_row): def get_shelf(self, normalized_row):
if normalized_row["date_finished"]: if normalized_row["date_finished"]:
return "read" return Shelf.READ_FINISHED
if normalized_row["date_started"]: if normalized_row["date_started"]:
return "reading" return Shelf.READING
return "to-read" return Shelf.TO_READ

View file

@ -0,0 +1,80 @@
# Generated by Django 3.2.12 on 2022-03-16 23:20
import bookwyrm.models.fields
from django.db import migrations
from bookwyrm.models import Shelf
def add_shelves(apps, schema_editor):
"""add any superusers to the "admin" group"""
db_alias = schema_editor.connection.alias
shelf_model = apps.get_model("bookwyrm", "Shelf")
users = apps.get_model("bookwyrm", "User")
local_users = users.objects.using(db_alias).filter(local=True)
for user in local_users:
remote_id = f"{user.remote_id}/books/stopped"
shelf_model.objects.using(db_alias).create(
name="Stopped reading",
identifier=Shelf.STOPPED_READING,
user=user,
editable=False,
remote_id=remote_id,
)
class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0145_sitesettings_version"),
]
operations = [
migrations.AlterField(
model_name="comment",
name="reading_status",
field=bookwyrm.models.fields.CharField(
blank=True,
choices=[
("to-read", "To-Read"),
("reading", "Reading"),
("read", "Read"),
("stopped-reading", "Stopped-Reading"),
],
max_length=255,
null=True,
),
),
migrations.AlterField(
model_name="quotation",
name="reading_status",
field=bookwyrm.models.fields.CharField(
blank=True,
choices=[
("to-read", "To-Read"),
("reading", "Reading"),
("read", "Read"),
("stopped-reading", "Stopped-Reading"),
],
max_length=255,
null=True,
),
),
migrations.AlterField(
model_name="review",
name="reading_status",
field=bookwyrm.models.fields.CharField(
blank=True,
choices=[
("to-read", "To-Read"),
("reading", "Reading"),
("read", "Read"),
("stopped-reading", "Stopped-Reading"),
],
max_length=255,
null=True,
),
),
migrations.RunPython(add_shelves, reverse_code=migrations.RunPython.noop),
]

View file

@ -0,0 +1,13 @@
# Generated by Django 3.2.12 on 2022-03-26 20:06
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0146_auto_20220316_2320"),
("bookwyrm", "0147_alter_user_preferred_language"),
]
operations = []

View file

@ -0,0 +1,13 @@
# Generated by Django 3.2.13 on 2022-05-26 17:16
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0148_alter_user_preferred_language"),
("bookwyrm", "0148_merge_20220326_2006"),
]
operations = []

View file

@ -0,0 +1,18 @@
# Generated by Django 3.2.13 on 2022-05-26 18:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("bookwyrm", "0149_merge_20220526_1716"),
]
operations = [
migrations.AddField(
model_name="readthrough",
name="stopped_date",
field=models.DateTimeField(blank=True, null=True),
),
]

View file

@ -175,9 +175,15 @@ class ImportItem(models.Model):
def date_added(self): def date_added(self):
"""when the book was added to this dataset""" """when the book was added to this dataset"""
if self.normalized_data.get("date_added"): if self.normalized_data.get("date_added"):
return timezone.make_aware( parsed_date_added = dateutil.parser.parse(
dateutil.parser.parse(self.normalized_data.get("date_added")) self.normalized_data.get("date_added")
) )
if timezone.is_aware(parsed_date_added):
# Keep timezone if import already had one
return parsed_date_added
return timezone.make_aware(parsed_date_added)
return None return None
@property @property

View file

@ -27,6 +27,7 @@ class ReadThrough(BookWyrmModel):
) )
start_date = models.DateTimeField(blank=True, null=True) start_date = models.DateTimeField(blank=True, null=True)
finish_date = models.DateTimeField(blank=True, null=True) finish_date = models.DateTimeField(blank=True, null=True)
stopped_date = models.DateTimeField(blank=True, null=True)
is_active = models.BooleanField(default=True) is_active = models.BooleanField(default=True)
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
@ -34,7 +35,7 @@ class ReadThrough(BookWyrmModel):
cache.delete(f"latest_read_through-{self.user.id}-{self.book.id}") cache.delete(f"latest_read_through-{self.user.id}-{self.book.id}")
self.user.update_active_date() self.user.update_active_date()
# an active readthrough must have an unset finish date # an active readthrough must have an unset finish date
if self.finish_date: if self.finish_date or self.stopped_date:
self.is_active = False self.is_active = False
super().save(*args, **kwargs) super().save(*args, **kwargs)

View file

@ -18,8 +18,9 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel):
TO_READ = "to-read" TO_READ = "to-read"
READING = "reading" READING = "reading"
READ_FINISHED = "read" READ_FINISHED = "read"
STOPPED_READING = "stopped-reading"
READ_STATUS_IDENTIFIERS = (TO_READ, READING, READ_FINISHED) READ_STATUS_IDENTIFIERS = (TO_READ, READING, READ_FINISHED, STOPPED_READING)
name = fields.CharField(max_length=100) name = fields.CharField(max_length=100)
identifier = models.CharField(max_length=100) identifier = models.CharField(max_length=100)

View file

@ -116,11 +116,8 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
def ignore_activity(cls, activity): # pylint: disable=too-many-return-statements def ignore_activity(cls, activity): # pylint: disable=too-many-return-statements
"""keep notes if they are replies to existing statuses""" """keep notes if they are replies to existing statuses"""
if activity.type == "Announce": if activity.type == "Announce":
try: boosted = activitypub.resolve_remote_id(activity.object, get_activity=True)
boosted = activitypub.resolve_remote_id( if not boosted:
activity.object, get_activity=True
)
except activitypub.ActivitySerializerError:
# if we can't load the status, definitely ignore it # if we can't load the status, definitely ignore it
return True return True
# keep the boost if we would keep the status # keep the boost if we would keep the status
@ -265,7 +262,7 @@ class GeneratedNote(Status):
ReadingStatusChoices = models.TextChoices( ReadingStatusChoices = models.TextChoices(
"ReadingStatusChoices", ["to-read", "reading", "read"] "ReadingStatusChoices", ["to-read", "reading", "read", "stopped-reading"]
) )

View file

@ -374,6 +374,10 @@ class User(OrderedCollectionPageMixin, AbstractUser):
"name": "Read", "name": "Read",
"identifier": "read", "identifier": "read",
}, },
{
"name": "Stopped Reading",
"identifier": "stopped-reading",
},
] ]
for shelf in shelves: for shelf in shelves:

View file

@ -11,7 +11,7 @@ from django.utils.translation import gettext_lazy as _
env = Env() env = Env()
env.read_env() env.read_env()
DOMAIN = env("DOMAIN") DOMAIN = env("DOMAIN")
VERSION = "0.3.4" VERSION = "0.4.0"
RELEASE_API = env( RELEASE_API = env(
"RELEASE_API", "RELEASE_API",
@ -21,7 +21,7 @@ RELEASE_API = env(
PAGE_LENGTH = env("PAGE_LENGTH", 15) PAGE_LENGTH = env("PAGE_LENGTH", 15)
DEFAULT_LANGUAGE = env("DEFAULT_LANGUAGE", "English") DEFAULT_LANGUAGE = env("DEFAULT_LANGUAGE", "English")
JS_CACHE = "bc93172a" JS_CACHE = "e678183b"
# email # email
EMAIL_BACKEND = env("EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend") EMAIL_BACKEND = env("EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend")

View file

@ -203,6 +203,8 @@ let StatusCache = new (class {
.forEach((item) => (item.disabled = false)); .forEach((item) => (item.disabled = false));
next_identifier = next_identifier == "complete" ? "read" : next_identifier; next_identifier = next_identifier == "complete" ? "read" : next_identifier;
next_identifier =
next_identifier == "stopped-reading-complete" ? "stopped-reading" : next_identifier;
// Disable the current state // Disable the current state
button.querySelector( button.querySelector(

View file

@ -24,7 +24,7 @@
</div> </div>
{% endif %} {% endif %}
<form class="block" name="edit-author" action="{{ author.local_path }}/edit" method="post"> <form class="block" name="edit-author" action="{% url 'edit-author' author.id %}" method="post">
{% csrf_token %} {% csrf_token %}
<input type="hidden" name="last_edited_by" value="{{ request.user.id }}"> <input type="hidden" name="last_edited_by" value="{{ request.user.id }}">

View file

@ -10,6 +10,7 @@
{% if shelf.identifier == 'to-read' %}{% trans "To Read" %} {% if shelf.identifier == 'to-read' %}{% trans "To Read" %}
{% elif shelf.identifier == 'reading' %}{% trans "Currently Reading" %} {% elif shelf.identifier == 'reading' %}{% trans "Currently Reading" %}
{% elif shelf.identifier == 'read' %}{% trans "Read" %} {% elif shelf.identifier == 'read' %}{% trans "Read" %}
{% elif shelf.identifier == 'stopped-reading' %}{% trans "Stopped Reading" %}
{% else %}{{ shelf.name }}{% endif %} {% else %}{{ shelf.name }}{% endif %}
</option> </option>
{% endfor %} {% endfor %}

View file

@ -32,6 +32,9 @@
<option value="OpenLibrary" {% if current == 'OpenLibrary' %}selected{% endif %}> <option value="OpenLibrary" {% if current == 'OpenLibrary' %}selected{% endif %}>
OpenLibrary (CSV) OpenLibrary (CSV)
</option> </option>
<option value="Calibre" {% if current == 'Calibre' %}selected{% endif %}>
Calibre (CSV)
</option>
</select> </select>
</div> </div>

View file

@ -0,0 +1,14 @@
{% extends 'layout.html' %}
{% load i18n %}
{% block title %}
{% blocktrans trimmed with book_title=book.title %}
Stop Reading "{{ book_title }}"
{% endblocktrans %}
{% endblock %}
{% block content %}
{% include "snippets/reading_modals/stop_reading_modal.html" with book=book active=True static=True %}
{% endblock %}

View file

@ -19,6 +19,7 @@
</label> </label>
{% include "snippets/progress_field.html" with id=field_id %} {% include "snippets/progress_field.html" with id=field_id %}
{% endif %} {% endif %}
<div class="field"> <div class="field">
<label class="label" for="id_finish_date_{{ readthrough.id }}"> <label class="label" for="id_finish_date_{{ readthrough.id }}">
{% trans "Finished reading" %} {% trans "Finished reading" %}

View file

@ -8,10 +8,12 @@
<div class="column"> <div class="column">
{% trans "Progress Updates:" %} {% trans "Progress Updates:" %}
<ul> <ul>
{% if readthrough.finish_date or readthrough.progress %} {% if readthrough.finish_date or readthrough.stopped_date or readthrough.progress %}
<li> <li>
{% if readthrough.finish_date %} {% if readthrough.finish_date %}
{{ readthrough.finish_date | localtime | naturalday }}: {% trans "finished" %} {{ readthrough.finish_date | localtime | naturalday }}: {% trans "finished" %}
{% elif readthrough.stopped_date %}
{{ readthrough.stopped_date | localtime | naturalday }}: {% trans "stopped" %}
{% else %} {% else %}
{% if readthrough.progress_mode == 'PG' %} {% if readthrough.progress_mode == 'PG' %}

View file

@ -86,6 +86,7 @@
{% if shelf.identifier == 'to-read' %}{% trans "To Read" %} {% if shelf.identifier == 'to-read' %}{% trans "To Read" %}
{% elif shelf.identifier == 'reading' %}{% trans "Currently Reading" %} {% elif shelf.identifier == 'reading' %}{% trans "Currently Reading" %}
{% elif shelf.identifier == 'read' %}{% trans "Read" %} {% elif shelf.identifier == 'read' %}{% trans "Read" %}
{% elif shelf.identifier == 'stopped-reading' %}{% trans "Stopped Reading" %}
{% else %}{{ shelf.name }}{% endif %} {% else %}{{ shelf.name }}{% endif %}
<span class="subtitle"> <span class="subtitle">
{% include 'snippets/privacy-icons.html' with item=shelf %} {% include 'snippets/privacy-icons.html' with item=shelf %}
@ -150,7 +151,7 @@
{% if is_self %} {% if is_self %}
<th>{% trans "Shelved" as text %}{% include 'snippets/table-sort-header.html' with field="shelved_date" sort=sort text=text %}</th> <th>{% trans "Shelved" as text %}{% include 'snippets/table-sort-header.html' with field="shelved_date" sort=sort text=text %}</th>
<th>{% trans "Started" as text %}{% include 'snippets/table-sort-header.html' with field="start_date" sort=sort text=text %}</th> <th>{% trans "Started" as text %}{% include 'snippets/table-sort-header.html' with field="start_date" sort=sort text=text %}</th>
<th>{% trans "Finished" as text %}{% include 'snippets/table-sort-header.html' with field="finish_date" sort=sort text=text %}</th> <th>{% if shelf.identifier == 'read' %}{% trans "Finished" as text %}{% else %}{% trans "Until" as text %}{% endif %}{% include 'snippets/table-sort-header.html' with field="finish_date" sort=sort text=text %}</th>
{% endif %} {% endif %}
<th>{% trans "Rating" as text %}{% include 'snippets/table-sort-header.html' with field="rating" sort=sort text=text %}</th> <th>{% trans "Rating" as text %}{% include 'snippets/table-sort-header.html' with field="rating" sort=sort text=text %}</th>
{% endif %} {% endif %}
@ -180,7 +181,7 @@
<td data-title="{% trans "Started" %}"> <td data-title="{% trans "Started" %}">
{{ book.start_date|naturalday|default_if_none:""}} {{ book.start_date|naturalday|default_if_none:""}}
</td> </td>
<td data-title="{% trans "Finished" %}"> <td data-title="{% if shelf.identifier == 'read' %}{% trans "Finished" as text %}{% else %}{% trans "Until" as text %}{% endif %}">
{{ book.finish_date|naturalday|default_if_none:""}} {{ book.finish_date|naturalday|default_if_none:""}}
</td> </td>
{% endif %} {% endif %}

View file

@ -0,0 +1,42 @@
{% extends 'snippets/reading_modals/layout.html' %}
{% load i18n %}
{% load utilities %}
{% block modal-title %}
{% blocktrans trimmed with book_title=book|book_title %}
Stop Reading "<em>{{ book_title }}</em>"
{% endblocktrans %}
{% endblock %}
{% block modal-form-open %}
<form name="stop-reading-{{ uuid }}" action="{% url 'reading-status' 'stop' book.id %}" method="post" {% if not refresh %}class="submit-status"{% endif %}>
{% csrf_token %}
<input type="hidden" name="id" value="{{ readthrough.id }}">
<input type="hidden" name="reading_status" value="stopped-reading">
<input type="hidden" name="shelf" value="{{ move_from }}">
{% endblock %}
{% block reading-dates %}
<div class="columns">
<div class="column is-half">
<div class="field">
<label class="label" for="stop_id_start_date_{{ uuid }}">
{% trans "Started reading" %}
</label>
<input type="date" name="start_date" class="input" id="stop_id_start_date_{{ uuid }}" value="{{ readthrough.start_date | date:"Y-m-d" }}">
</div>
</div>
<div class="column is-half">
<div class="field">
<label class="label" for="id_read_until_date_{{ uuid }}">
{% trans "Stopped reading" %}
</label>
<input type="date" name="stopped_date" class="input" id="id_read_until_date_{{ uuid }}" value="{% now "Y-m-d" %}">
</div>
</div>
</div>
{% endblock %}
{% block form %}
{% include "snippets/reading_modals/form.html" with optional=True type="stop_modal" %}
{% endblock %}

View file

@ -49,6 +49,13 @@
{% join "finish_reading" uuid as modal_id %} {% join "finish_reading" uuid as modal_id %}
{% include 'snippets/shelve_button/modal_button.html' with class=button_class fallback_url=fallback_url %} {% include 'snippets/shelve_button/modal_button.html' with class=button_class fallback_url=fallback_url %}
{% elif shelf.identifier == 'stopped-reading' %}
{% trans "Stopped reading" as button_text %}
{% url 'reading-status' 'stop' book.id as fallback_url %}
{% join "stop_reading" uuid as modal_id %}
{% include 'snippets/shelve_button/modal_button.html' with class=button_class fallback_url=fallback_url %}
{% elif shelf.identifier == 'to-read' %} {% elif shelf.identifier == 'to-read' %}
{% trans "Want to read" as button_text %} {% trans "Want to read" as button_text %}
@ -99,5 +106,8 @@
{% join "finish_reading" uuid as modal_id %} {% join "finish_reading" uuid as modal_id %}
{% include 'snippets/reading_modals/finish_reading_modal.html' with book=active_shelf.book id=modal_id move_from=current.id readthrough=readthrough refresh=True class="" %} {% include 'snippets/reading_modals/finish_reading_modal.html' with book=active_shelf.book id=modal_id move_from=current.id readthrough=readthrough refresh=True class="" %}
{% join "stop_reading" uuid as modal_id %}
{% include 'snippets/reading_modals/stop_reading_modal.html' with book=active_shelf.book id=modal_id move_from=current.id readthrough=readthrough refresh=True class="" %}
{% endwith %} {% endwith %}
{% endblock %} {% endblock %}

View file

@ -29,6 +29,9 @@
{% join "finish_reading" uuid as modal_id %} {% join "finish_reading" uuid as modal_id %}
{% include 'snippets/reading_modals/finish_reading_modal.html' with book=active_shelf_book id=modal_id readthrough=readthrough class="" %} {% include 'snippets/reading_modals/finish_reading_modal.html' with book=active_shelf_book id=modal_id readthrough=readthrough class="" %}
{% join "stop_reading" uuid as modal_id %}
{% include 'snippets/reading_modals/stop_reading_modal.html' with book=active_shelf_book id=modal_id readthrough=readthrough class="" %}
{% join "progress_update" uuid as modal_id %} {% join "progress_update" uuid as modal_id %}
{% include 'snippets/reading_modals/progress_update_modal.html' with book=active_shelf_book id=modal_id readthrough=readthrough class="" %} {% include 'snippets/reading_modals/progress_update_modal.html' with book=active_shelf_book id=modal_id readthrough=readthrough class="" %}

View file

@ -8,7 +8,7 @@
{% comparison_bool shelf.identifier active_shelf.shelf.identifier as is_current %} {% comparison_bool shelf.identifier active_shelf.shelf.identifier as is_current %}
<li role="menuitem" class="dropdown-item p-0"> <li role="menuitem" class="dropdown-item p-0">
<div <div
class="{% if next_shelf_identifier == shelf.identifier %}is-hidden{% endif %}" class="{% if is_current or next_shelf_identifier == shelf.identifier %}is-hidden{% elif shelf.identifier == 'stopped-reading' and active_shelf.shelf.identifier != "reading" %}is-hidden{% endif %}"
data-shelf-dropdown-identifier="{{ shelf.identifier }}" data-shelf-dropdown-identifier="{{ shelf.identifier }}"
data-shelf-next="{{ shelf.identifier|next_shelf }}" data-shelf-next="{{ shelf.identifier|next_shelf }}"
> >
@ -26,6 +26,13 @@
{% join "finish_reading" button_uuid as modal_id %} {% join "finish_reading" button_uuid as modal_id %}
{% include 'snippets/shelve_button/modal_button.html' with class=class fallback_url=fallback_url %} {% include 'snippets/shelve_button/modal_button.html' with class=class fallback_url=fallback_url %}
{% elif shelf.identifier == 'stopped-reading' %}
{% trans "Stop reading" as button_text %}
{% url 'reading-status' 'stop' book.id as fallback_url %}
{% join "stop_reading" button_uuid as modal_id %}
{% include 'snippets/shelve_button/modal_button.html' with class=class fallback_url=fallback_url %}
{% elif shelf.identifier == 'to-read' %} {% elif shelf.identifier == 'to-read' %}
{% trans "Want to read" as button_text %} {% trans "Want to read" as button_text %}

View file

@ -13,6 +13,15 @@
</button> </button>
</div> </div>
<div
class="{% if next_shelf_identifier != 'stopped-reading-complete' %}is-hidden{% endif %}"
data-shelf-identifier="stopped-reading-complete"
>
<button type="button" class="button {{ class }}" disabled>
<span>{% trans "Stopped reading" %}</span>
</button>
</div>
{% for shelf in shelves %} {% for shelf in shelves %}
<div <div
class="{% if next_shelf_identifier != shelf.identifier %}is-hidden{% endif %}" class="{% if next_shelf_identifier != shelf.identifier %}is-hidden{% endif %}"
@ -33,6 +42,14 @@
{% join "finish_reading" button_uuid as modal_id %} {% join "finish_reading" button_uuid as modal_id %}
{% include 'snippets/shelve_button/modal_button.html' with class=class fallback_url=fallback_url %} {% include 'snippets/shelve_button/modal_button.html' with class=class fallback_url=fallback_url %}
{% elif shelf.identifier == 'stopped-reading' %}
{% trans "Stop reading" as button_text %}
{% url 'reading-status' 'finish' book.id as fallback_url %}
{% join "stop_reading" button_uuid as modal_id %}
{% include 'snippets/shelve_button/modal_button.html' with class=class fallback_url=fallback_url %}
{% elif shelf.identifier == 'to-read' %} {% elif shelf.identifier == 'to-read' %}
{% trans "Want to read" as button_text %} {% trans "Want to read" as button_text %}

View file

@ -0,0 +1,23 @@
{% spaceless %}
{% load i18n %}
{% load utilities %}
{% load status_display %}
{% load_book status as book %}
{% if book.authors.exists %}
{% with author=book.authors.first %}
{% blocktrans trimmed with book_path=book.local_path book=book|book_title author_name=author.name author_path=author.local_path %}
stopped reading <a href="{{ book_path }}">{{ book }}</a> by <a href="{{ author_path }}">{{ author_name }}</a>
{% endblocktrans %}
{% endwith %}
{% else %}
{% blocktrans trimmed with book_path=book.local_path book=book|book_title %}
stopped reading <a href="{{ book_path }}">{{ book }}</a>
{% endblocktrans %}
{% endif %}
{% endspaceless %}

View file

@ -33,8 +33,9 @@
{% if shelf.name == 'To Read' %}{% trans "To Read" %} {% if shelf.name == 'To Read' %}{% trans "To Read" %}
{% elif shelf.name == 'Currently Reading' %}{% trans "Currently Reading" %} {% elif shelf.name == 'Currently Reading' %}{% trans "Currently Reading" %}
{% elif shelf.name == 'Read' %}{% trans "Read" %} {% elif shelf.name == 'Read' %}{% trans "Read" %}
{% elif shelf.name == 'Stopped Reading' %}{% trans "Stopped Reading" %}
{% else %}{{ shelf.name }}{% endif %} {% else %}{{ shelf.name }}{% endif %}
{% if shelf.size > 3 %}<small>(<a href="{{ shelf.local_path }}">{% blocktrans with size=shelf.size %}View all {{ size }}{% endblocktrans %}</a>)</small>{% endif %} {% if shelf.size > 4 %}<small>(<a href="{{ shelf.local_path }}">{% blocktrans with size=shelf.size %}View all {{ size }}{% endblocktrans %}</a>)</small>{% endif %}
</h3> </h3>
<div class="is-mobile field is-grouped"> <div class="is-mobile field is-grouped">
{% for book in shelf.books %} {% for book in shelf.books %}

View file

@ -30,6 +30,8 @@ def get_next_shelf(current_shelf):
return "read" return "read"
if current_shelf == "read": if current_shelf == "read":
return "complete" return "complete"
if current_shelf == "stopped-reading":
return "stopped-reading-complete"
return "to-read" return "to-read"

View file

@ -0,0 +1,2 @@
authors,author_sort,rating,library_name,timestamp,formats,size,isbn,identifiers,comments,tags,series,series_index,languages,title,cover,title_sort,publisher,pubdate,id,uuid
"Seanan McGuire","McGuire, Seanan","5","Bücher","2021-01-19T22:41:16+01:00","epub, original_epub","1433809","9780756411800","goodreads:39077187,isbn:9780756411800","REPLACED COMMENTS (BOOK DESCRIPTION) BECAUSE IT IS REALLY LONG.","Cryptids, Fantasy, Romance, Magic","InCryptid","8.0","eng","That Ain't Witchcraft","/home/tastytea/Bücher/Seanan McGuire/That Ain't Witchcraft (864)/cover.jpg","That Ain't Witchcraft","Daw Books","2019-03-05T01:00:00+01:00","864","3051ed45-8943-4900-a22a-d2704e3583df"
1 authors author_sort rating library_name timestamp formats size isbn identifiers comments tags series series_index languages title cover title_sort publisher pubdate id uuid
2 Seanan McGuire McGuire, Seanan 5 Bücher 2021-01-19T22:41:16+01:00 epub, original_epub 1433809 9780756411800 goodreads:39077187,isbn:9780756411800 REPLACED COMMENTS (BOOK DESCRIPTION) BECAUSE IT IS REALLY LONG. Cryptids, Fantasy, Romance, Magic InCryptid 8.0 eng That Ain't Witchcraft /home/tastytea/Bücher/Seanan McGuire/That Ain't Witchcraft (864)/cover.jpg That Ain't Witchcraft Daw Books 2019-03-05T01:00:00+01:00 864 3051ed45-8943-4900-a22a-d2704e3583df

View file

@ -0,0 +1,71 @@
""" testing import """
import pathlib
from unittest.mock import patch
from django.test import TestCase
from bookwyrm import models
from bookwyrm.importers import CalibreImporter
from bookwyrm.importers.importer import handle_imported_book
# pylint: disable=consider-using-with
@patch("bookwyrm.suggested_users.rerank_suggestions_task.delay")
@patch("bookwyrm.activitystreams.populate_stream_task.delay")
@patch("bookwyrm.activitystreams.add_book_statuses_task.delay")
class CalibreImport(TestCase):
"""importing from Calibre csv"""
def setUp(self):
"""use a test csv"""
self.importer = CalibreImporter()
datafile = pathlib.Path(__file__).parent.joinpath("../data/calibre.csv")
self.csv = open(datafile, "r", encoding=self.importer.encoding)
with patch("bookwyrm.suggested_users.rerank_suggestions_task.delay"), patch(
"bookwyrm.activitystreams.populate_stream_task.delay"
), patch("bookwyrm.lists_stream.populate_lists_task.delay"):
self.local_user = models.User.objects.create_user(
"mouse", "mouse@mouse.mouse", "password", local=True
)
work = models.Work.objects.create(title="Test Work")
self.book = models.Edition.objects.create(
title="Example Edition",
remote_id="https://example.com/book/1",
parent_work=work,
)
def test_create_job(self, *_):
"""creates the import job entry and checks csv"""
import_job = self.importer.create_job(
self.local_user, self.csv, False, "public"
)
import_items = (
models.ImportItem.objects.filter(job=import_job).order_by("index").all()
)
self.assertEqual(len(import_items), 1)
self.assertEqual(import_items[0].index, 0)
self.assertEqual(
import_items[0].normalized_data["title"], "That Ain't Witchcraft"
)
def test_handle_imported_book(self, *_):
"""calibre import added a book, this adds related connections"""
shelf = self.local_user.shelf_set.filter(
identifier=models.Shelf.TO_READ
).first()
self.assertIsNone(shelf.books.first())
import_job = self.importer.create_job(
self.local_user, self.csv, False, "public"
)
import_item = import_job.items.first()
import_item.book = self.book
import_item.save()
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
handle_imported_book(import_item)
shelf.refresh_from_db()
self.assertEqual(shelf.books.first(), self.book)

View file

@ -84,7 +84,9 @@ class GoodreadsImport(TestCase):
def test_handle_imported_book(self, *_): def test_handle_imported_book(self, *_):
"""goodreads import added a book, this adds related connections""" """goodreads import added a book, this adds related connections"""
shelf = self.local_user.shelf_set.filter(identifier="read").first() shelf = self.local_user.shelf_set.filter(
identifier=models.Shelf.READ_FINISHED
).first()
self.assertIsNone(shelf.books.first()) self.assertIsNone(shelf.books.first())
import_job = self.importer.create_job( import_job = self.importer.create_job(

View file

@ -174,7 +174,9 @@ class GenericImporter(TestCase):
def test_handle_imported_book(self, *_): def test_handle_imported_book(self, *_):
"""import added a book, this adds related connections""" """import added a book, this adds related connections"""
shelf = self.local_user.shelf_set.filter(identifier="read").first() shelf = self.local_user.shelf_set.filter(
identifier=models.Shelf.READ_FINISHED
).first()
self.assertIsNone(shelf.books.first()) self.assertIsNone(shelf.books.first())
import_job = self.importer.create_job( import_job = self.importer.create_job(
@ -193,7 +195,9 @@ class GenericImporter(TestCase):
def test_handle_imported_book_already_shelved(self, *_): def test_handle_imported_book_already_shelved(self, *_):
"""import added a book, this adds related connections""" """import added a book, this adds related connections"""
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"): with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
shelf = self.local_user.shelf_set.filter(identifier="to-read").first() shelf = self.local_user.shelf_set.filter(
identifier=models.Shelf.TO_READ
).first()
models.ShelfBook.objects.create( models.ShelfBook.objects.create(
shelf=shelf, shelf=shelf,
user=self.local_user, user=self.local_user,
@ -217,12 +221,16 @@ class GenericImporter(TestCase):
shelf.shelfbook_set.first().shelved_date, make_date(2020, 2, 2) shelf.shelfbook_set.first().shelved_date, make_date(2020, 2, 2)
) )
self.assertIsNone( self.assertIsNone(
self.local_user.shelf_set.get(identifier="read").books.first() self.local_user.shelf_set.get(
identifier=models.Shelf.READ_FINISHED
).books.first()
) )
def test_handle_import_twice(self, *_): def test_handle_import_twice(self, *_):
"""re-importing books""" """re-importing books"""
shelf = self.local_user.shelf_set.filter(identifier="read").first() shelf = self.local_user.shelf_set.filter(
identifier=models.Shelf.READ_FINISHED
).first()
import_job = self.importer.create_job( import_job = self.importer.create_job(
self.local_user, self.csv, False, "public" self.local_user, self.csv, False, "public"
) )

View file

@ -93,7 +93,9 @@ class LibrarythingImport(TestCase):
def test_handle_imported_book(self, *_): def test_handle_imported_book(self, *_):
"""librarything import added a book, this adds related connections""" """librarything import added a book, this adds related connections"""
shelf = self.local_user.shelf_set.filter(identifier="read").first() shelf = self.local_user.shelf_set.filter(
identifier=models.Shelf.READ_FINISHED
).first()
self.assertIsNone(shelf.books.first()) self.assertIsNone(shelf.books.first())
import_job = self.importer.create_job( import_job = self.importer.create_job(
@ -117,7 +119,9 @@ class LibrarythingImport(TestCase):
def test_handle_imported_book_already_shelved(self, *_): def test_handle_imported_book_already_shelved(self, *_):
"""librarything import added a book, this adds related connections""" """librarything import added a book, this adds related connections"""
with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"): with patch("bookwyrm.models.activitypub_mixin.broadcast_task.apply_async"):
shelf = self.local_user.shelf_set.filter(identifier="to-read").first() shelf = self.local_user.shelf_set.filter(
identifier=models.Shelf.TO_READ
).first()
models.ShelfBook.objects.create( models.ShelfBook.objects.create(
shelf=shelf, user=self.local_user, book=self.book shelf=shelf, user=self.local_user, book=self.book
) )
@ -135,7 +139,9 @@ class LibrarythingImport(TestCase):
shelf.refresh_from_db() shelf.refresh_from_db()
self.assertEqual(shelf.books.first(), self.book) self.assertEqual(shelf.books.first(), self.book)
self.assertIsNone( self.assertIsNone(
self.local_user.shelf_set.get(identifier="read").books.first() self.local_user.shelf_set.get(
identifier=models.Shelf.READ_FINISHED
).books.first()
) )
readthrough = models.ReadThrough.objects.get(user=self.local_user) readthrough = models.ReadThrough.objects.get(user=self.local_user)

View file

@ -70,7 +70,9 @@ class OpenLibraryImport(TestCase):
def test_handle_imported_book(self, *_): def test_handle_imported_book(self, *_):
"""openlibrary import added a book, this adds related connections""" """openlibrary import added a book, this adds related connections"""
shelf = self.local_user.shelf_set.filter(identifier="reading").first() shelf = self.local_user.shelf_set.filter(
identifier=models.Shelf.READING
).first()
self.assertIsNone(shelf.books.first()) self.assertIsNone(shelf.books.first())
import_job = self.importer.create_job( import_job = self.importer.create_job(

View file

@ -62,7 +62,9 @@ class StorygraphImport(TestCase):
def test_handle_imported_book(self, *_): def test_handle_imported_book(self, *_):
"""storygraph import added a book, this adds related connections""" """storygraph import added a book, this adds related connections"""
shelf = self.local_user.shelf_set.filter(identifier="to-read").first() shelf = self.local_user.shelf_set.filter(
identifier=models.Shelf.TO_READ
).first()
self.assertIsNone(shelf.books.first()) self.assertIsNone(shelf.books.first())
import_job = self.importer.create_job( import_job = self.importer.create_job(

View file

@ -462,6 +462,8 @@ class Status(TestCase):
@responses.activate @responses.activate
def test_ignore_activity_boost(self, *_): def test_ignore_activity_boost(self, *_):
"""don't bother with most remote statuses""" """don't bother with most remote statuses"""
responses.add(responses.GET, "http://fish.com/nothing")
activity = activitypub.Announce( activity = activitypub.Announce(
id="http://www.faraway.com/boost/12", id="http://www.faraway.com/boost/12",
actor=self.remote_user.remote_id, actor=self.remote_user.remote_id,

View file

@ -53,15 +53,17 @@ class User(TestCase):
def test_user_shelves(self): def test_user_shelves(self):
shelves = models.Shelf.objects.filter(user=self.user).all() shelves = models.Shelf.objects.filter(user=self.user).all()
self.assertEqual(len(shelves), 3) self.assertEqual(len(shelves), 4)
names = [s.name for s in shelves] names = [s.name for s in shelves]
self.assertTrue("To Read" in names) self.assertTrue("To Read" in names)
self.assertTrue("Currently Reading" in names) self.assertTrue("Currently Reading" in names)
self.assertTrue("Read" in names) self.assertTrue("Read" in names)
self.assertTrue("Stopped Reading" in names)
ids = [s.identifier for s in shelves] ids = [s.identifier for s in shelves]
self.assertTrue("to-read" in ids) self.assertTrue("to-read" in ids)
self.assertTrue("reading" in ids) self.assertTrue("reading" in ids)
self.assertTrue("read" in ids) self.assertTrue("read" in ids)
self.assertTrue("stopped-reading" in ids)
def test_activitypub_serialize(self): def test_activitypub_serialize(self):
activity = self.user.to_activity() activity = self.user.to_activity()

View file

@ -9,6 +9,7 @@ from django.test import TestCase
from django.test.client import RequestFactory from django.test.client import RequestFactory
from bookwyrm import forms, models, views from bookwyrm import forms, models, views
from bookwyrm.views.books.edit_book import add_authors
from bookwyrm.tests.validate_html import validate_html from bookwyrm.tests.validate_html import validate_html
from bookwyrm.tests.views.books.test_book import _setup_cover_url from bookwyrm.tests.views.books.test_book import _setup_cover_url
@ -214,3 +215,22 @@ class EditBookViews(TestCase):
self.book.refresh_from_db() self.book.refresh_from_db()
self.assertTrue(self.book.cover) self.assertTrue(self.book.cover)
def test_add_authors_helper(self):
"""converts form input into author matches"""
form = forms.EditionForm(instance=self.book)
form.data["title"] = "New Title"
form.data["last_edited_by"] = self.local_user.id
form.data["add_author"] = ["Sappho", "Some Guy"]
request = self.factory.post("", form.data)
request.user = self.local_user
with patch("bookwyrm.utils.isni.find_authors_by_name") as mock:
mock.return_value = []
result = add_authors(request, form.data)
self.assertTrue(result["confirm_mode"])
self.assertEqual(result["add_author"], ["Sappho", "Some Guy"])
self.assertEqual(len(result["author_matches"]), 2)
self.assertEqual(result["author_matches"][0]["name"], "Sappho")
self.assertEqual(result["author_matches"][1]["name"], "Some Guy")

View file

@ -622,7 +622,7 @@ urlpatterns = [
name="reading-status-update", name="reading-status-update",
), ),
re_path( re_path(
r"^reading-status/(?P<status>want|start|finish)/(?P<book_id>\d+)/?$", r"^reading-status/(?P<status>want|start|finish|stop)/(?P<book_id>\d+)/?$",
views.ReadingStatus.as_view(), views.ReadingStatus.as_view(),
name="reading-status", name="reading-status",
), ),

View file

@ -115,6 +115,7 @@ class CreateBook(View):
# go to confirm mode # go to confirm mode
if not parent_work_id or data.get("add_author"): if not parent_work_id or data.get("add_author"):
data["confirm_mode"] = True
return TemplateResponse(request, "book/edit/edit_book.html", data) return TemplateResponse(request, "book/edit/edit_book.html", data)
with transaction.atomic(): with transaction.atomic():
@ -189,7 +190,7 @@ def add_authors(request, data):
"existing_isnis": exists, "existing_isnis": exists,
} }
) )
return data return data
@require_POST @require_POST

View file

@ -138,6 +138,7 @@ def handle_reading_status(user, shelf, book, privacy):
"to-read": "wants to read", "to-read": "wants to read",
"reading": "started reading", "reading": "started reading",
"read": "finished reading", "read": "finished reading",
"stopped-reading": "stopped reading",
}[shelf.identifier] }[shelf.identifier]
except KeyError: except KeyError:
# it's a non-standard shelf, don't worry about it # it's a non-standard shelf, don't worry about it

View file

@ -11,6 +11,7 @@ from django.views import View
from bookwyrm import forms, models from bookwyrm import forms, models
from bookwyrm.importers import ( from bookwyrm.importers import (
CalibreImporter,
LibrarythingImporter, LibrarythingImporter,
GoodreadsImporter, GoodreadsImporter,
StorygraphImporter, StorygraphImporter,
@ -52,6 +53,8 @@ class Import(View):
importer = StorygraphImporter() importer = StorygraphImporter()
elif source == "OpenLibrary": elif source == "OpenLibrary":
importer = OpenLibraryImporter() importer = OpenLibraryImporter()
elif source == "Calibre":
importer = CalibreImporter()
else: else:
# Default : Goodreads # Default : Goodreads
importer = GoodreadsImporter() importer = GoodreadsImporter()

View file

@ -1,4 +1,5 @@
""" the good stuff! the books! """ """ the good stuff! the books! """
import logging
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.core.cache import cache from django.core.cache import cache
from django.db import transaction from django.db import transaction
@ -15,6 +16,8 @@ from .status import CreateStatus
from .helpers import get_edition, handle_reading_status, is_api_request from .helpers import get_edition, handle_reading_status, is_api_request
from .helpers import load_date_in_user_tz_as_utc from .helpers import load_date_in_user_tz_as_utc
logger = logging.getLogger(__name__)
# pylint: disable=no-self-use # pylint: disable=no-self-use
# pylint: disable=too-many-return-statements # pylint: disable=too-many-return-statements
@ -29,20 +32,24 @@ class ReadingStatus(View):
"want": "want.html", "want": "want.html",
"start": "start.html", "start": "start.html",
"finish": "finish.html", "finish": "finish.html",
"stop": "stop.html",
}.get(status) }.get(status)
if not template: if not template:
return HttpResponseNotFound() return HttpResponseNotFound()
# redirect if we're already on this shelf # redirect if we're already on this shelf
return TemplateResponse(request, f"reading_progress/{template}", {"book": book}) return TemplateResponse(request, f"reading_progress/{template}", {"book": book})
@transaction.atomic
def post(self, request, status, book_id): def post(self, request, status, book_id):
"""Change the state of a book by shelving it and adding reading dates""" """Change the state of a book by shelving it and adding reading dates"""
identifier = { identifier = {
"want": models.Shelf.TO_READ, "want": models.Shelf.TO_READ,
"start": models.Shelf.READING, "start": models.Shelf.READING,
"finish": models.Shelf.READ_FINISHED, "finish": models.Shelf.READ_FINISHED,
"stop": models.Shelf.STOPPED_READING,
}.get(status) }.get(status)
if not identifier: if not identifier:
logger.exception("Invalid reading status type: %s", status)
return HttpResponseBadRequest() return HttpResponseBadRequest()
# invalidate related caches # invalidate related caches
@ -85,6 +92,7 @@ class ReadingStatus(View):
desired_shelf.identifier, desired_shelf.identifier,
start_date=request.POST.get("start_date"), start_date=request.POST.get("start_date"),
finish_date=request.POST.get("finish_date"), finish_date=request.POST.get("finish_date"),
stopped_date=request.POST.get("stopped_date"),
) )
# post about it (if you want) # post about it (if you want)
@ -153,8 +161,9 @@ class ReadThrough(View):
@transaction.atomic @transaction.atomic
# pylint: disable=too-many-arguments
def update_readthrough_on_shelve( def update_readthrough_on_shelve(
user, annotated_book, status, start_date=None, finish_date=None user, annotated_book, status, start_date=None, finish_date=None, stopped_date=None
): ):
"""update the current readthrough for a book when it is re-shelved""" """update the current readthrough for a book when it is re-shelved"""
# there *should* only be one of current active readthrough, but it's a list # there *should* only be one of current active readthrough, but it's a list
@ -176,8 +185,9 @@ def update_readthrough_on_shelve(
) )
# santiize and set dates # santiize and set dates
active_readthrough.start_date = load_date_in_user_tz_as_utc(start_date, user) active_readthrough.start_date = load_date_in_user_tz_as_utc(start_date, user)
# if the finish date is set, the readthrough will be automatically set as inactive # if the stop or finish date is set, the readthrough will be set as inactive
active_readthrough.finish_date = load_date_in_user_tz_as_utc(finish_date, user) active_readthrough.finish_date = load_date_in_user_tz_as_utc(finish_date, user)
active_readthrough.stopped_date = load_date_in_user_tz_as_utc(stopped_date, user)
active_readthrough.save() active_readthrough.save()

View file

@ -1,5 +1,6 @@
""" what are we here for if not for posting """ """ what are we here for if not for posting """
import re import re
import logging
from urllib.parse import urlparse from urllib.parse import urlparse
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
@ -21,6 +22,8 @@ from bookwyrm.utils import regex
from .helpers import handle_remote_webfinger, is_api_request from .helpers import handle_remote_webfinger, is_api_request
from .helpers import load_date_in_user_tz_as_utc from .helpers import load_date_in_user_tz_as_utc
logger = logging.getLogger(__name__)
# pylint: disable= no-self-use # pylint: disable= no-self-use
@method_decorator(login_required, name="dispatch") @method_decorator(login_required, name="dispatch")
@ -72,11 +75,14 @@ class CreateStatus(View):
form = getattr(forms, f"{status_type}Form")( form = getattr(forms, f"{status_type}Form")(
request.POST, instance=existing_status request.POST, instance=existing_status
) )
except AttributeError: except AttributeError as err:
logger.exception(err)
return HttpResponseBadRequest() return HttpResponseBadRequest()
if not form.is_valid(): if not form.is_valid():
if is_api_request(request): if is_api_request(request):
return HttpResponse(status=500) logger.exception(form.errors)
return HttpResponseBadRequest()
return redirect(request.headers.get("Referer", "/")) return redirect(request.headers.get("Referer", "/"))
status = form.save(commit=False) status = form.save(commit=False)

View file

@ -106,7 +106,7 @@ class Followers(View):
if is_api_request(request): if is_api_request(request):
return ActivitypubResponse(user.to_followers_activity(**request.GET)) return ActivitypubResponse(user.to_followers_activity(**request.GET))
if user.hide_follows: if user.hide_follows and user != request.user:
raise PermissionDenied() raise PermissionDenied()
followers = annotate_if_follows(request.user, user.followers) followers = annotate_if_follows(request.user, user.followers)
@ -129,7 +129,7 @@ class Following(View):
if is_api_request(request): if is_api_request(request):
return ActivitypubResponse(user.to_following_activity(**request.GET)) return ActivitypubResponse(user.to_following_activity(**request.GET))
if user.hide_follows: if user.hide_follows and user != request.user:
raise PermissionDenied() raise PermissionDenied()
following = annotate_if_follows(request.user, user.following) following = annotate_if_follows(request.user, user.following)

View file

@ -1 +1 @@
black==22.1.0 black==22.3.0

Binary file not shown.

View file

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: 0.0.1\n" "Project-Id-Version: 0.0.1\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-05-14 14:03+0000\n" "POT-Creation-Date: 2022-05-23 21:04+0000\n"
"PO-Revision-Date: 2021-02-28 17:19-0800\n" "PO-Revision-Date: 2021-02-28 17:19-0800\n"
"Last-Translator: Mouse Reeve <mousereeve@riseup.net>\n" "Last-Translator: Mouse Reeve <mousereeve@riseup.net>\n"
"Language-Team: English <LL@li.org>\n" "Language-Team: English <LL@li.org>\n"
@ -122,25 +122,25 @@ msgstr ""
msgid "Automatically generated report" msgid "Automatically generated report"
msgstr "" msgstr ""
#: bookwyrm/models/base_model.py:17 bookwyrm/models/link.py:72 #: bookwyrm/models/base_model.py:18 bookwyrm/models/link.py:72
#: bookwyrm/templates/import/import_status.html:200 #: bookwyrm/templates/import/import_status.html:200
#: bookwyrm/templates/settings/link_domains/link_domains.html:19 #: bookwyrm/templates/settings/link_domains/link_domains.html:19
msgid "Pending" msgid "Pending"
msgstr "" msgstr ""
#: bookwyrm/models/base_model.py:18 #: bookwyrm/models/base_model.py:19
msgid "Self deletion" msgid "Self deletion"
msgstr "" msgstr ""
#: bookwyrm/models/base_model.py:19 #: bookwyrm/models/base_model.py:20
msgid "Moderator suspension" msgid "Moderator suspension"
msgstr "" msgstr ""
#: bookwyrm/models/base_model.py:20 #: bookwyrm/models/base_model.py:21
msgid "Moderator deletion" msgid "Moderator deletion"
msgstr "" msgstr ""
#: bookwyrm/models/base_model.py:21 #: bookwyrm/models/base_model.py:22
msgid "Domain block" msgid "Domain block"
msgstr "" msgstr ""
@ -735,7 +735,7 @@ msgstr ""
#: bookwyrm/templates/author/edit_author.html:115 #: bookwyrm/templates/author/edit_author.html:115
#: bookwyrm/templates/book/book.html:202 #: bookwyrm/templates/book/book.html:202
#: bookwyrm/templates/book/edit/edit_book.html:127 #: bookwyrm/templates/book/edit/edit_book.html:135
#: bookwyrm/templates/book/file_links/add_link_modal.html:60 #: bookwyrm/templates/book/file_links/add_link_modal.html:60
#: bookwyrm/templates/book/file_links/edit_links.html:82 #: bookwyrm/templates/book/file_links/edit_links.html:82
#: bookwyrm/templates/groups/form.html:32 #: bookwyrm/templates/groups/form.html:32
@ -758,8 +758,8 @@ msgstr ""
#: bookwyrm/templates/author/sync_modal.html:23 #: bookwyrm/templates/author/sync_modal.html:23
#: bookwyrm/templates/book/book.html:203 #: bookwyrm/templates/book/book.html:203
#: bookwyrm/templates/book/cover_add_modal.html:33 #: bookwyrm/templates/book/cover_add_modal.html:33
#: bookwyrm/templates/book/edit/edit_book.html:129 #: bookwyrm/templates/book/edit/edit_book.html:137
#: bookwyrm/templates/book/edit/edit_book.html:132 #: bookwyrm/templates/book/edit/edit_book.html:140
#: bookwyrm/templates/book/file_links/add_link_modal.html:59 #: bookwyrm/templates/book/file_links/add_link_modal.html:59
#: bookwyrm/templates/book/file_links/verification_modal.html:25 #: bookwyrm/templates/book/file_links/verification_modal.html:25
#: bookwyrm/templates/book/sync_modal.html:23 #: bookwyrm/templates/book/sync_modal.html:23
@ -781,7 +781,7 @@ msgid "Loading data will connect to <strong>%(source_name)s</strong> and check f
msgstr "" msgstr ""
#: bookwyrm/templates/author/sync_modal.html:24 #: bookwyrm/templates/author/sync_modal.html:24
#: bookwyrm/templates/book/edit/edit_book.html:114 #: bookwyrm/templates/book/edit/edit_book.html:122
#: bookwyrm/templates/book/sync_modal.html:24 #: bookwyrm/templates/book/sync_modal.html:24
#: bookwyrm/templates/groups/members.html:29 #: bookwyrm/templates/groups/members.html:29
#: bookwyrm/templates/landing/password_reset.html:42 #: bookwyrm/templates/landing/password_reset.html:42
@ -950,42 +950,42 @@ msgstr ""
msgid "Add Book" msgid "Add Book"
msgstr "" msgstr ""
#: bookwyrm/templates/book/edit/edit_book.html:54 #: bookwyrm/templates/book/edit/edit_book.html:62
msgid "Confirm Book Info" msgid "Confirm Book Info"
msgstr "" msgstr ""
#: bookwyrm/templates/book/edit/edit_book.html:62 #: bookwyrm/templates/book/edit/edit_book.html:70
#, python-format #, python-format
msgid "Is \"%(name)s\" one of these authors?" msgid "Is \"%(name)s\" one of these authors?"
msgstr "" msgstr ""
#: bookwyrm/templates/book/edit/edit_book.html:73 #: bookwyrm/templates/book/edit/edit_book.html:81
#: bookwyrm/templates/book/edit/edit_book.html:75 #: bookwyrm/templates/book/edit/edit_book.html:83
msgid "Author of " msgid "Author of "
msgstr "" msgstr ""
#: bookwyrm/templates/book/edit/edit_book.html:75 #: bookwyrm/templates/book/edit/edit_book.html:83
msgid "Find more information at isni.org" msgid "Find more information at isni.org"
msgstr "" msgstr ""
#: bookwyrm/templates/book/edit/edit_book.html:85 #: bookwyrm/templates/book/edit/edit_book.html:93
msgid "This is a new author" msgid "This is a new author"
msgstr "" msgstr ""
#: bookwyrm/templates/book/edit/edit_book.html:92 #: bookwyrm/templates/book/edit/edit_book.html:100
#, python-format #, python-format
msgid "Creating a new author: %(name)s" msgid "Creating a new author: %(name)s"
msgstr "" msgstr ""
#: bookwyrm/templates/book/edit/edit_book.html:99 #: bookwyrm/templates/book/edit/edit_book.html:107
msgid "Is this an edition of an existing work?" msgid "Is this an edition of an existing work?"
msgstr "" msgstr ""
#: bookwyrm/templates/book/edit/edit_book.html:107 #: bookwyrm/templates/book/edit/edit_book.html:115
msgid "This is a new work" msgid "This is a new work"
msgstr "" msgstr ""
#: bookwyrm/templates/book/edit/edit_book.html:116 #: bookwyrm/templates/book/edit/edit_book.html:124
#: bookwyrm/templates/feed/status.html:21 #: bookwyrm/templates/feed/status.html:21
msgid "Back" msgid "Back"
msgstr "" msgstr ""
@ -1971,33 +1971,33 @@ msgstr ""
msgid "Data source:" msgid "Data source:"
msgstr "" msgstr ""
#: bookwyrm/templates/import/import.html:39 #: bookwyrm/templates/import/import.html:42
msgid "You can download your Goodreads data from the <a href=\"https://www.goodreads.com/review/import\" target=\"_blank\" rel=\"noopener noreferrer\">Import/Export page</a> of your Goodreads account." msgid "You can download your Goodreads data from the <a href=\"https://www.goodreads.com/review/import\" target=\"_blank\" rel=\"noopener noreferrer\">Import/Export page</a> of your Goodreads account."
msgstr "" msgstr ""
#: bookwyrm/templates/import/import.html:44 #: bookwyrm/templates/import/import.html:47
msgid "Data file:" msgid "Data file:"
msgstr "" msgstr ""
#: bookwyrm/templates/import/import.html:52 #: bookwyrm/templates/import/import.html:55
msgid "Include reviews" msgid "Include reviews"
msgstr "" msgstr ""
#: bookwyrm/templates/import/import.html:57 #: bookwyrm/templates/import/import.html:60
msgid "Privacy setting for imported reviews:" msgid "Privacy setting for imported reviews:"
msgstr "" msgstr ""
#: bookwyrm/templates/import/import.html:63 #: bookwyrm/templates/import/import.html:66
#: bookwyrm/templates/preferences/layout.html:31 #: bookwyrm/templates/preferences/layout.html:31
#: bookwyrm/templates/settings/federation/instance_blocklist.html:76 #: bookwyrm/templates/settings/federation/instance_blocklist.html:76
msgid "Import" msgid "Import"
msgstr "" msgstr ""
#: bookwyrm/templates/import/import.html:68 #: bookwyrm/templates/import/import.html:71
msgid "Recent Imports" msgid "Recent Imports"
msgstr "" msgstr ""
#: bookwyrm/templates/import/import.html:70 #: bookwyrm/templates/import/import.html:73
msgid "No recent imports" msgid "No recent imports"
msgstr "" msgstr ""
@ -5114,7 +5114,7 @@ msgstr ""
msgid "%(title)s: %(subtitle)s" msgid "%(title)s: %(subtitle)s"
msgstr "" msgstr ""
#: bookwyrm/views/imports/import_data.py:67 #: bookwyrm/views/imports/import_data.py:70
msgid "Not a valid csv file" msgid "Not a valid csv file"
msgstr "" msgstr ""

Binary file not shown.

View file

@ -3,7 +3,7 @@ msgstr ""
"Project-Id-Version: bookwyrm\n" "Project-Id-Version: bookwyrm\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-08 21:00+0000\n" "POT-Creation-Date: 2022-04-08 21:00+0000\n"
"PO-Revision-Date: 2022-05-14 12:42\n" "PO-Revision-Date: 2022-05-16 21:13\n"
"Last-Translator: Mouse Reeve <mousereeve@riseup.net>\n" "Last-Translator: Mouse Reeve <mousereeve@riseup.net>\n"
"Language-Team: Romanian\n" "Language-Team: Romanian\n"
"Language: ro\n" "Language: ro\n"
@ -515,9 +515,9 @@ msgstr "Din păcate %(display_name)s nu a terminat nicio carte în %(year)s"
#, python-format #, python-format
msgid "In %(year)s, %(display_name)s read %(books_total)s book<br />for a total of %(pages_total)s pages!" msgid "In %(year)s, %(display_name)s read %(books_total)s book<br />for a total of %(pages_total)s pages!"
msgid_plural "In %(year)s, %(display_name)s read %(books_total)s books<br />for a total of %(pages_total)s pages!" msgid_plural "In %(year)s, %(display_name)s read %(books_total)s books<br />for a total of %(pages_total)s pages!"
msgstr[0] "" msgstr[0] "În %(year)s, %(display_name)s a citit %(books_total)s carte<br />pentru un total de %(pages_total)s pagini!"
msgstr[1] "" msgstr[1] ""
msgstr[2] "În %(year)s, %(display_name)s a citit %(books_total)s cărți<br />pentru un total de %(pages_total)s de pagini!" msgstr[2] "În %(year)s, %(display_name)s a citit %(books_total)s cărți<br />pentru un total de %(pages_total)s pagini!"
#: bookwyrm/templates/annual_summary/layout.html:124 #: bookwyrm/templates/annual_summary/layout.html:124
msgid "Thats great!" msgid "Thats great!"
@ -532,7 +532,7 @@ msgstr "Asta înseamnă o medie de %(pages)s de pagini pe carte."
#, python-format #, python-format
msgid "(%(no_page_number)s book doesnt have pages)" msgid "(%(no_page_number)s book doesnt have pages)"
msgid_plural "(%(no_page_number)s books dont have pages)" msgid_plural "(%(no_page_number)s books dont have pages)"
msgstr[0] "" msgstr[0] "(cartea %(no_page_number)s nu are pagini)"
msgstr[1] "" msgstr[1] ""
msgstr[2] "(cărțile %(no_page_number)s nu au pagini)" msgstr[2] "(cărțile %(no_page_number)s nu au pagini)"
@ -576,9 +576,9 @@ msgstr "Felicitări!"
#, python-format #, python-format
msgid "%(display_name)s left %(ratings_total)s rating, <br />their average rating is %(rating_average)s" msgid "%(display_name)s left %(ratings_total)s rating, <br />their average rating is %(rating_average)s"
msgid_plural "%(display_name)s left %(ratings_total)s ratings, <br />their average rating is %(rating_average)s" msgid_plural "%(display_name)s left %(ratings_total)s ratings, <br />their average rating is %(rating_average)s"
msgstr[0] "" msgstr[0] "%(display_name)s a lăsat %(ratings_total)s recenzie, <br />ratingul său mediu este %(rating_average)s"
msgstr[1] "" msgstr[1] ""
msgstr[2] "%(display_name)s a lăsat recenzii de %(ratings_total)s, <br />ratingul său mediu este %(rating_average)s" msgstr[2] "%(display_name)s a lăsat %(ratings_total)s recenzii, <br />ratingul său mediu este %(rating_average)s"
#: bookwyrm/templates/annual_summary/layout.html:238 #: bookwyrm/templates/annual_summary/layout.html:238
msgid "Their best rated review" msgid "Their best rated review"
@ -816,7 +816,7 @@ msgstr "Clic pentru a mări"
#, python-format #, python-format
msgid "(%(review_count)s review)" msgid "(%(review_count)s review)"
msgid_plural "(%(review_count)s reviews)" msgid_plural "(%(review_count)s reviews)"
msgstr[0] "" msgstr[0] "(%(review_count)s recenzie)"
msgstr[1] "" msgstr[1] ""
msgstr[2] "(%(review_count)s recenzii)" msgstr[2] "(%(review_count)s recenzii)"
@ -834,7 +834,7 @@ msgstr "Descriere:"
#, python-format #, python-format
msgid "%(count)s edition" msgid "%(count)s edition"
msgid_plural "%(count)s editions" msgid_plural "%(count)s editions"
msgstr[0] "" msgstr[0] "%(count)s ediție"
msgstr[1] "" msgstr[1] ""
msgstr[2] "%(count)s ediții" msgstr[2] "%(count)s ediții"
@ -3379,7 +3379,7 @@ msgstr "Opere"
#, python-format #, python-format
msgid "%(display_count)s open report" msgid "%(display_count)s open report"
msgid_plural "%(display_count)s open reports" msgid_plural "%(display_count)s open reports"
msgstr[0] "" msgstr[0] "%(display_count)s raport deschis"
msgstr[1] "" msgstr[1] ""
msgstr[2] "%(display_count)s raporturi dechise" msgstr[2] "%(display_count)s raporturi dechise"