forked from mirrors/bookwyrm
Merge branch 'main' into production
This commit is contained in:
commit
02a315be00
53 changed files with 523 additions and 83 deletions
|
@ -1,6 +1,7 @@
|
|||
""" basics for an activitypub serializer """
|
||||
from dataclasses import dataclass, fields, MISSING
|
||||
from json import JSONEncoder
|
||||
import logging
|
||||
|
||||
from django.apps import apps
|
||||
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.tasks import app
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ActivitySerializerError(ValueError):
|
||||
"""routine problems serializing activitypub json"""
|
||||
|
@ -65,7 +68,7 @@ class ActivityObject:
|
|||
try:
|
||||
value = kwargs[field.name]
|
||||
if value in (None, MISSING, {}):
|
||||
raise KeyError()
|
||||
raise KeyError("Missing required field", field.name)
|
||||
try:
|
||||
is_subclass = issubclass(field.type, ActivityObject)
|
||||
except TypeError:
|
||||
|
@ -268,9 +271,9 @@ def resolve_remote_id(
|
|||
try:
|
||||
data = get_data(remote_id)
|
||||
except ConnectorException:
|
||||
raise ActivitySerializerError(
|
||||
f"Could not connect to host for remote_id: {remote_id}"
|
||||
)
|
||||
logger.exception("Could not connect to host for remote_id: %s", remote_id)
|
||||
return None
|
||||
|
||||
# determine the model implicitly, if not provided
|
||||
# or if it's a model with subclasses like Status, check again
|
||||
if not model or hasattr(model.objects, "select_subclasses"):
|
||||
|
|
|
@ -53,7 +53,12 @@ class ReadThroughForm(CustomForm):
|
|||
self.add_error(
|
||||
"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:
|
||||
model = models.ReadThrough
|
||||
fields = ["user", "book", "start_date", "finish_date"]
|
||||
fields = ["user", "book", "start_date", "finish_date", "stopped_date"]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
""" import classes """
|
||||
|
||||
from .importer import Importer
|
||||
from .calibre_import import CalibreImporter
|
||||
from .goodreads_import import GoodreadsImporter
|
||||
from .librarything_import import LibrarythingImporter
|
||||
from .openlibrary_import import OpenLibraryImporter
|
||||
|
|
28
bookwyrm/importers/calibre_import.py
Normal file
28
bookwyrm/importers/calibre_import.py
Normal 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
|
|
@ -1,5 +1,8 @@
|
|||
""" handle reading a tsv from librarything """
|
||||
import re
|
||||
|
||||
from bookwyrm.models import Shelf
|
||||
|
||||
from . import Importer
|
||||
|
||||
|
||||
|
@ -21,7 +24,7 @@ class LibrarythingImporter(Importer):
|
|||
|
||||
def get_shelf(self, normalized_row):
|
||||
if normalized_row["date_finished"]:
|
||||
return "read"
|
||||
return Shelf.READ_FINISHED
|
||||
if normalized_row["date_started"]:
|
||||
return "reading"
|
||||
return "to-read"
|
||||
return Shelf.READING
|
||||
return Shelf.TO_READ
|
||||
|
|
80
bookwyrm/migrations/0146_auto_20220316_2320.py
Normal file
80
bookwyrm/migrations/0146_auto_20220316_2320.py
Normal 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),
|
||||
]
|
13
bookwyrm/migrations/0148_merge_20220326_2006.py
Normal file
13
bookwyrm/migrations/0148_merge_20220326_2006.py
Normal 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 = []
|
13
bookwyrm/migrations/0149_merge_20220526_1716.py
Normal file
13
bookwyrm/migrations/0149_merge_20220526_1716.py
Normal 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 = []
|
18
bookwyrm/migrations/0150_readthrough_stopped_date.py
Normal file
18
bookwyrm/migrations/0150_readthrough_stopped_date.py
Normal 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),
|
||||
),
|
||||
]
|
|
@ -175,9 +175,15 @@ class ImportItem(models.Model):
|
|||
def date_added(self):
|
||||
"""when the book was added to this dataset"""
|
||||
if self.normalized_data.get("date_added"):
|
||||
return timezone.make_aware(
|
||||
dateutil.parser.parse(self.normalized_data.get("date_added"))
|
||||
parsed_date_added = dateutil.parser.parse(
|
||||
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
|
||||
|
||||
@property
|
||||
|
|
|
@ -27,6 +27,7 @@ class ReadThrough(BookWyrmModel):
|
|||
)
|
||||
start_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)
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
|
@ -34,7 +35,7 @@ class ReadThrough(BookWyrmModel):
|
|||
cache.delete(f"latest_read_through-{self.user.id}-{self.book.id}")
|
||||
self.user.update_active_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
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
|
|
|
@ -18,8 +18,9 @@ class Shelf(OrderedCollectionMixin, BookWyrmModel):
|
|||
TO_READ = "to-read"
|
||||
READING = "reading"
|
||||
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)
|
||||
identifier = models.CharField(max_length=100)
|
||||
|
|
|
@ -116,11 +116,8 @@ class Status(OrderedCollectionPageMixin, BookWyrmModel):
|
|||
def ignore_activity(cls, activity): # pylint: disable=too-many-return-statements
|
||||
"""keep notes if they are replies to existing statuses"""
|
||||
if activity.type == "Announce":
|
||||
try:
|
||||
boosted = activitypub.resolve_remote_id(
|
||||
activity.object, get_activity=True
|
||||
)
|
||||
except activitypub.ActivitySerializerError:
|
||||
boosted = activitypub.resolve_remote_id(activity.object, get_activity=True)
|
||||
if not boosted:
|
||||
# if we can't load the status, definitely ignore it
|
||||
return True
|
||||
# keep the boost if we would keep the status
|
||||
|
@ -265,7 +262,7 @@ class GeneratedNote(Status):
|
|||
|
||||
|
||||
ReadingStatusChoices = models.TextChoices(
|
||||
"ReadingStatusChoices", ["to-read", "reading", "read"]
|
||||
"ReadingStatusChoices", ["to-read", "reading", "read", "stopped-reading"]
|
||||
)
|
||||
|
||||
|
||||
|
|
|
@ -374,6 +374,10 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
|||
"name": "Read",
|
||||
"identifier": "read",
|
||||
},
|
||||
{
|
||||
"name": "Stopped Reading",
|
||||
"identifier": "stopped-reading",
|
||||
},
|
||||
]
|
||||
|
||||
for shelf in shelves:
|
||||
|
|
|
@ -11,7 +11,7 @@ from django.utils.translation import gettext_lazy as _
|
|||
env = Env()
|
||||
env.read_env()
|
||||
DOMAIN = env("DOMAIN")
|
||||
VERSION = "0.3.4"
|
||||
VERSION = "0.4.0"
|
||||
|
||||
RELEASE_API = env(
|
||||
"RELEASE_API",
|
||||
|
@ -21,7 +21,7 @@ RELEASE_API = env(
|
|||
PAGE_LENGTH = env("PAGE_LENGTH", 15)
|
||||
DEFAULT_LANGUAGE = env("DEFAULT_LANGUAGE", "English")
|
||||
|
||||
JS_CACHE = "bc93172a"
|
||||
JS_CACHE = "e678183b"
|
||||
|
||||
# email
|
||||
EMAIL_BACKEND = env("EMAIL_BACKEND", "django.core.mail.backends.smtp.EmailBackend")
|
||||
|
|
|
@ -203,6 +203,8 @@ let StatusCache = new (class {
|
|||
.forEach((item) => (item.disabled = false));
|
||||
|
||||
next_identifier = next_identifier == "complete" ? "read" : next_identifier;
|
||||
next_identifier =
|
||||
next_identifier == "stopped-reading-complete" ? "stopped-reading" : next_identifier;
|
||||
|
||||
// Disable the current state
|
||||
button.querySelector(
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
</div>
|
||||
{% 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 %}
|
||||
<input type="hidden" name="last_edited_by" value="{{ request.user.id }}">
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
{% if shelf.identifier == 'to-read' %}{% trans "To Read" %}
|
||||
{% elif shelf.identifier == 'reading' %}{% trans "Currently Reading" %}
|
||||
{% elif shelf.identifier == 'read' %}{% trans "Read" %}
|
||||
{% elif shelf.identifier == 'stopped-reading' %}{% trans "Stopped Reading" %}
|
||||
{% else %}{{ shelf.name }}{% endif %}
|
||||
</option>
|
||||
{% endfor %}
|
||||
|
|
|
@ -32,6 +32,9 @@
|
|||
<option value="OpenLibrary" {% if current == 'OpenLibrary' %}selected{% endif %}>
|
||||
OpenLibrary (CSV)
|
||||
</option>
|
||||
<option value="Calibre" {% if current == 'Calibre' %}selected{% endif %}>
|
||||
Calibre (CSV)
|
||||
</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
|
|
14
bookwyrm/templates/reading_progress/stop.html
Normal file
14
bookwyrm/templates/reading_progress/stop.html
Normal 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 %}
|
|
@ -19,6 +19,7 @@
|
|||
</label>
|
||||
{% include "snippets/progress_field.html" with id=field_id %}
|
||||
{% endif %}
|
||||
|
||||
<div class="field">
|
||||
<label class="label" for="id_finish_date_{{ readthrough.id }}">
|
||||
{% trans "Finished reading" %}
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
<div class="column">
|
||||
{% trans "Progress Updates:" %}
|
||||
<ul>
|
||||
{% if readthrough.finish_date or readthrough.progress %}
|
||||
{% if readthrough.finish_date or readthrough.stopped_date or readthrough.progress %}
|
||||
<li>
|
||||
{% if readthrough.finish_date %}
|
||||
{{ readthrough.finish_date | localtime | naturalday }}: {% trans "finished" %}
|
||||
{% elif readthrough.stopped_date %}
|
||||
{{ readthrough.stopped_date | localtime | naturalday }}: {% trans "stopped" %}
|
||||
{% else %}
|
||||
|
||||
{% if readthrough.progress_mode == 'PG' %}
|
||||
|
|
|
@ -86,6 +86,7 @@
|
|||
{% if shelf.identifier == 'to-read' %}{% trans "To Read" %}
|
||||
{% elif shelf.identifier == 'reading' %}{% trans "Currently Reading" %}
|
||||
{% elif shelf.identifier == 'read' %}{% trans "Read" %}
|
||||
{% elif shelf.identifier == 'stopped-reading' %}{% trans "Stopped Reading" %}
|
||||
{% else %}{{ shelf.name }}{% endif %}
|
||||
<span class="subtitle">
|
||||
{% include 'snippets/privacy-icons.html' with item=shelf %}
|
||||
|
@ -150,7 +151,7 @@
|
|||
{% 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 "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 %}
|
||||
<th>{% trans "Rating" as text %}{% include 'snippets/table-sort-header.html' with field="rating" sort=sort text=text %}</th>
|
||||
{% endif %}
|
||||
|
@ -180,7 +181,7 @@
|
|||
<td data-title="{% trans "Started" %}">
|
||||
{{ book.start_date|naturalday|default_if_none:""}}
|
||||
</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:""}}
|
||||
</td>
|
||||
{% endif %}
|
||||
|
|
|
@ -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 %}
|
|
@ -49,6 +49,13 @@
|
|||
{% join "finish_reading" uuid as modal_id %}
|
||||
{% 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' %}
|
||||
|
||||
{% trans "Want to read" as button_text %}
|
||||
|
@ -99,5 +106,8 @@
|
|||
{% 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="" %}
|
||||
|
||||
{% 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 %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -29,6 +29,9 @@
|
|||
{% 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="" %}
|
||||
|
||||
{% 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 %}
|
||||
{% include 'snippets/reading_modals/progress_update_modal.html' with book=active_shelf_book id=modal_id readthrough=readthrough class="" %}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
{% comparison_bool shelf.identifier active_shelf.shelf.identifier as is_current %}
|
||||
<li role="menuitem" class="dropdown-item p-0">
|
||||
<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-next="{{ shelf.identifier|next_shelf }}"
|
||||
>
|
||||
|
@ -26,6 +26,13 @@
|
|||
{% join "finish_reading" button_uuid as modal_id %}
|
||||
{% 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' %}
|
||||
|
||||
{% trans "Want to read" as button_text %}
|
||||
|
|
|
@ -13,6 +13,15 @@
|
|||
</button>
|
||||
</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 %}
|
||||
<div
|
||||
class="{% if next_shelf_identifier != shelf.identifier %}is-hidden{% endif %}"
|
||||
|
@ -33,6 +42,14 @@
|
|||
{% join "finish_reading" button_uuid as modal_id %}
|
||||
{% 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' %}
|
||||
|
||||
{% trans "Want to read" as button_text %}
|
||||
|
|
|
@ -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 %}
|
||||
|
|
@ -33,8 +33,9 @@
|
|||
{% if shelf.name == 'To Read' %}{% trans "To Read" %}
|
||||
{% elif shelf.name == 'Currently Reading' %}{% trans "Currently Reading" %}
|
||||
{% elif shelf.name == 'Read' %}{% trans "Read" %}
|
||||
{% elif shelf.name == 'Stopped Reading' %}{% trans "Stopped Reading" %}
|
||||
{% 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>
|
||||
<div class="is-mobile field is-grouped">
|
||||
{% for book in shelf.books %}
|
||||
|
|
|
@ -30,6 +30,8 @@ def get_next_shelf(current_shelf):
|
|||
return "read"
|
||||
if current_shelf == "read":
|
||||
return "complete"
|
||||
if current_shelf == "stopped-reading":
|
||||
return "stopped-reading-complete"
|
||||
return "to-read"
|
||||
|
||||
|
||||
|
|
2
bookwyrm/tests/data/calibre.csv
Normal file
2
bookwyrm/tests/data/calibre.csv
Normal 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"
|
|
71
bookwyrm/tests/importers/test_calibre_import.py
Normal file
71
bookwyrm/tests/importers/test_calibre_import.py
Normal 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)
|
|
@ -84,7 +84,9 @@ class GoodreadsImport(TestCase):
|
|||
|
||||
def test_handle_imported_book(self, *_):
|
||||
"""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())
|
||||
|
||||
import_job = self.importer.create_job(
|
||||
|
|
|
@ -174,7 +174,9 @@ class GenericImporter(TestCase):
|
|||
|
||||
def test_handle_imported_book(self, *_):
|
||||
"""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())
|
||||
|
||||
import_job = self.importer.create_job(
|
||||
|
@ -193,7 +195,9 @@ class GenericImporter(TestCase):
|
|||
def test_handle_imported_book_already_shelved(self, *_):
|
||||
"""import added a book, this adds related connections"""
|
||||
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(
|
||||
shelf=shelf,
|
||||
user=self.local_user,
|
||||
|
@ -217,12 +221,16 @@ class GenericImporter(TestCase):
|
|||
shelf.shelfbook_set.first().shelved_date, make_date(2020, 2, 2)
|
||||
)
|
||||
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, *_):
|
||||
"""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(
|
||||
self.local_user, self.csv, False, "public"
|
||||
)
|
||||
|
|
|
@ -93,7 +93,9 @@ class LibrarythingImport(TestCase):
|
|||
|
||||
def test_handle_imported_book(self, *_):
|
||||
"""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())
|
||||
|
||||
import_job = self.importer.create_job(
|
||||
|
@ -117,7 +119,9 @@ class LibrarythingImport(TestCase):
|
|||
def test_handle_imported_book_already_shelved(self, *_):
|
||||
"""librarything import added a book, this adds related connections"""
|
||||
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(
|
||||
shelf=shelf, user=self.local_user, book=self.book
|
||||
)
|
||||
|
@ -135,7 +139,9 @@ class LibrarythingImport(TestCase):
|
|||
shelf.refresh_from_db()
|
||||
self.assertEqual(shelf.books.first(), self.book)
|
||||
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)
|
||||
|
|
|
@ -70,7 +70,9 @@ class OpenLibraryImport(TestCase):
|
|||
|
||||
def test_handle_imported_book(self, *_):
|
||||
"""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())
|
||||
|
||||
import_job = self.importer.create_job(
|
||||
|
|
|
@ -62,7 +62,9 @@ class StorygraphImport(TestCase):
|
|||
|
||||
def test_handle_imported_book(self, *_):
|
||||
"""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())
|
||||
|
||||
import_job = self.importer.create_job(
|
||||
|
|
|
@ -462,6 +462,8 @@ class Status(TestCase):
|
|||
@responses.activate
|
||||
def test_ignore_activity_boost(self, *_):
|
||||
"""don't bother with most remote statuses"""
|
||||
responses.add(responses.GET, "http://fish.com/nothing")
|
||||
|
||||
activity = activitypub.Announce(
|
||||
id="http://www.faraway.com/boost/12",
|
||||
actor=self.remote_user.remote_id,
|
||||
|
|
|
@ -53,15 +53,17 @@ class User(TestCase):
|
|||
|
||||
def test_user_shelves(self):
|
||||
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]
|
||||
self.assertTrue("To Read" in names)
|
||||
self.assertTrue("Currently Reading" in names)
|
||||
self.assertTrue("Read" in names)
|
||||
self.assertTrue("Stopped Reading" in names)
|
||||
ids = [s.identifier for s in shelves]
|
||||
self.assertTrue("to-read" in ids)
|
||||
self.assertTrue("reading" in ids)
|
||||
self.assertTrue("read" in ids)
|
||||
self.assertTrue("stopped-reading" in ids)
|
||||
|
||||
def test_activitypub_serialize(self):
|
||||
activity = self.user.to_activity()
|
||||
|
|
|
@ -9,6 +9,7 @@ from django.test import TestCase
|
|||
from django.test.client import RequestFactory
|
||||
|
||||
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.views.books.test_book import _setup_cover_url
|
||||
|
||||
|
@ -214,3 +215,22 @@ class EditBookViews(TestCase):
|
|||
|
||||
self.book.refresh_from_db()
|
||||
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")
|
||||
|
|
|
@ -622,7 +622,7 @@ urlpatterns = [
|
|||
name="reading-status-update",
|
||||
),
|
||||
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(),
|
||||
name="reading-status",
|
||||
),
|
||||
|
|
|
@ -115,6 +115,7 @@ class CreateBook(View):
|
|||
|
||||
# go to confirm mode
|
||||
if not parent_work_id or data.get("add_author"):
|
||||
data["confirm_mode"] = True
|
||||
return TemplateResponse(request, "book/edit/edit_book.html", data)
|
||||
|
||||
with transaction.atomic():
|
||||
|
|
|
@ -138,6 +138,7 @@ def handle_reading_status(user, shelf, book, privacy):
|
|||
"to-read": "wants to read",
|
||||
"reading": "started reading",
|
||||
"read": "finished reading",
|
||||
"stopped-reading": "stopped reading",
|
||||
}[shelf.identifier]
|
||||
except KeyError:
|
||||
# it's a non-standard shelf, don't worry about it
|
||||
|
|
|
@ -11,6 +11,7 @@ from django.views import View
|
|||
|
||||
from bookwyrm import forms, models
|
||||
from bookwyrm.importers import (
|
||||
CalibreImporter,
|
||||
LibrarythingImporter,
|
||||
GoodreadsImporter,
|
||||
StorygraphImporter,
|
||||
|
@ -52,6 +53,8 @@ class Import(View):
|
|||
importer = StorygraphImporter()
|
||||
elif source == "OpenLibrary":
|
||||
importer = OpenLibraryImporter()
|
||||
elif source == "Calibre":
|
||||
importer = CalibreImporter()
|
||||
else:
|
||||
# Default : Goodreads
|
||||
importer = GoodreadsImporter()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
""" the good stuff! the books! """
|
||||
import logging
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.core.cache import cache
|
||||
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 load_date_in_user_tz_as_utc
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
# pylint: disable=too-many-return-statements
|
||||
|
@ -29,20 +32,24 @@ class ReadingStatus(View):
|
|||
"want": "want.html",
|
||||
"start": "start.html",
|
||||
"finish": "finish.html",
|
||||
"stop": "stop.html",
|
||||
}.get(status)
|
||||
if not template:
|
||||
return HttpResponseNotFound()
|
||||
# redirect if we're already on this shelf
|
||||
return TemplateResponse(request, f"reading_progress/{template}", {"book": book})
|
||||
|
||||
@transaction.atomic
|
||||
def post(self, request, status, book_id):
|
||||
"""Change the state of a book by shelving it and adding reading dates"""
|
||||
identifier = {
|
||||
"want": models.Shelf.TO_READ,
|
||||
"start": models.Shelf.READING,
|
||||
"finish": models.Shelf.READ_FINISHED,
|
||||
"stop": models.Shelf.STOPPED_READING,
|
||||
}.get(status)
|
||||
if not identifier:
|
||||
logger.exception("Invalid reading status type: %s", status)
|
||||
return HttpResponseBadRequest()
|
||||
|
||||
# invalidate related caches
|
||||
|
@ -85,6 +92,7 @@ class ReadingStatus(View):
|
|||
desired_shelf.identifier,
|
||||
start_date=request.POST.get("start_date"),
|
||||
finish_date=request.POST.get("finish_date"),
|
||||
stopped_date=request.POST.get("stopped_date"),
|
||||
)
|
||||
|
||||
# post about it (if you want)
|
||||
|
@ -153,8 +161,9 @@ class ReadThrough(View):
|
|||
|
||||
|
||||
@transaction.atomic
|
||||
# pylint: disable=too-many-arguments
|
||||
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"""
|
||||
# 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
|
||||
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.stopped_date = load_date_in_user_tz_as_utc(stopped_date, user)
|
||||
|
||||
active_readthrough.save()
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
""" what are we here for if not for posting """
|
||||
import re
|
||||
import logging
|
||||
from urllib.parse import urlparse
|
||||
|
||||
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 load_date_in_user_tz_as_utc
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# pylint: disable= no-self-use
|
||||
@method_decorator(login_required, name="dispatch")
|
||||
|
@ -72,11 +75,14 @@ class CreateStatus(View):
|
|||
form = getattr(forms, f"{status_type}Form")(
|
||||
request.POST, instance=existing_status
|
||||
)
|
||||
except AttributeError:
|
||||
except AttributeError as err:
|
||||
logger.exception(err)
|
||||
return HttpResponseBadRequest()
|
||||
|
||||
if not form.is_valid():
|
||||
if is_api_request(request):
|
||||
return HttpResponse(status=500)
|
||||
logger.exception(form.errors)
|
||||
return HttpResponseBadRequest()
|
||||
return redirect(request.headers.get("Referer", "/"))
|
||||
|
||||
status = form.save(commit=False)
|
||||
|
|
|
@ -106,7 +106,7 @@ class Followers(View):
|
|||
if is_api_request(request):
|
||||
return ActivitypubResponse(user.to_followers_activity(**request.GET))
|
||||
|
||||
if user.hide_follows:
|
||||
if user.hide_follows and user != request.user:
|
||||
raise PermissionDenied()
|
||||
|
||||
followers = annotate_if_follows(request.user, user.followers)
|
||||
|
@ -129,7 +129,7 @@ class Following(View):
|
|||
if is_api_request(request):
|
||||
return ActivitypubResponse(user.to_following_activity(**request.GET))
|
||||
|
||||
if user.hide_follows:
|
||||
if user.hide_follows and user != request.user:
|
||||
raise PermissionDenied()
|
||||
|
||||
following = annotate_if_follows(request.user, user.following)
|
||||
|
|
|
@ -1 +1 @@
|
|||
black==22.1.0
|
||||
black==22.3.0
|
||||
|
|
Binary file not shown.
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: 0.0.1\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"
|
||||
"Last-Translator: Mouse Reeve <mousereeve@riseup.net>\n"
|
||||
"Language-Team: English <LL@li.org>\n"
|
||||
|
@ -122,25 +122,25 @@ msgstr ""
|
|||
msgid "Automatically generated report"
|
||||
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/settings/link_domains/link_domains.html:19
|
||||
msgid "Pending"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/models/base_model.py:18
|
||||
#: bookwyrm/models/base_model.py:19
|
||||
msgid "Self deletion"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/models/base_model.py:19
|
||||
#: bookwyrm/models/base_model.py:20
|
||||
msgid "Moderator suspension"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/models/base_model.py:20
|
||||
#: bookwyrm/models/base_model.py:21
|
||||
msgid "Moderator deletion"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/models/base_model.py:21
|
||||
#: bookwyrm/models/base_model.py:22
|
||||
msgid "Domain block"
|
||||
msgstr ""
|
||||
|
||||
|
@ -735,7 +735,7 @@ msgstr ""
|
|||
|
||||
#: bookwyrm/templates/author/edit_author.html:115
|
||||
#: 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/edit_links.html:82
|
||||
#: bookwyrm/templates/groups/form.html:32
|
||||
|
@ -758,8 +758,8 @@ msgstr ""
|
|||
#: bookwyrm/templates/author/sync_modal.html:23
|
||||
#: bookwyrm/templates/book/book.html:203
|
||||
#: bookwyrm/templates/book/cover_add_modal.html:33
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:129
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:132
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:137
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:140
|
||||
#: bookwyrm/templates/book/file_links/add_link_modal.html:59
|
||||
#: bookwyrm/templates/book/file_links/verification_modal.html:25
|
||||
#: 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 ""
|
||||
|
||||
#: 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/groups/members.html:29
|
||||
#: bookwyrm/templates/landing/password_reset.html:42
|
||||
|
@ -950,42 +950,42 @@ msgstr ""
|
|||
msgid "Add Book"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:54
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:62
|
||||
msgid "Confirm Book Info"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:62
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:70
|
||||
#, python-format
|
||||
msgid "Is \"%(name)s\" one of these authors?"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:73
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:75
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:81
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:83
|
||||
msgid "Author of "
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:75
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:83
|
||||
msgid "Find more information at isni.org"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:85
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:93
|
||||
msgid "This is a new author"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:92
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:100
|
||||
#, python-format
|
||||
msgid "Creating a new author: %(name)s"
|
||||
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?"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:107
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:115
|
||||
msgid "This is a new work"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:116
|
||||
#: bookwyrm/templates/book/edit/edit_book.html:124
|
||||
#: bookwyrm/templates/feed/status.html:21
|
||||
msgid "Back"
|
||||
msgstr ""
|
||||
|
@ -1971,33 +1971,33 @@ msgstr ""
|
|||
msgid "Data source:"
|
||||
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."
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/templates/import/import.html:44
|
||||
#: bookwyrm/templates/import/import.html:47
|
||||
msgid "Data file:"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/templates/import/import.html:52
|
||||
#: bookwyrm/templates/import/import.html:55
|
||||
msgid "Include reviews"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/templates/import/import.html:57
|
||||
#: bookwyrm/templates/import/import.html:60
|
||||
msgid "Privacy setting for imported reviews:"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/templates/import/import.html:63
|
||||
#: bookwyrm/templates/import/import.html:66
|
||||
#: bookwyrm/templates/preferences/layout.html:31
|
||||
#: bookwyrm/templates/settings/federation/instance_blocklist.html:76
|
||||
msgid "Import"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/templates/import/import.html:68
|
||||
#: bookwyrm/templates/import/import.html:71
|
||||
msgid "Recent Imports"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/templates/import/import.html:70
|
||||
#: bookwyrm/templates/import/import.html:73
|
||||
msgid "No recent imports"
|
||||
msgstr ""
|
||||
|
||||
|
@ -5114,7 +5114,7 @@ msgstr ""
|
|||
msgid "%(title)s: %(subtitle)s"
|
||||
msgstr ""
|
||||
|
||||
#: bookwyrm/views/imports/import_data.py:67
|
||||
#: bookwyrm/views/imports/import_data.py:70
|
||||
msgid "Not a valid csv file"
|
||||
msgstr ""
|
||||
|
||||
|
|
Binary file not shown.
|
@ -3,7 +3,7 @@ msgstr ""
|
|||
"Project-Id-Version: bookwyrm\n"
|
||||
"Report-Msgid-Bugs-To: \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"
|
||||
"Language-Team: Romanian\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
|
||||
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!"
|
||||
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[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
|
||||
msgid "That’s great!"
|
||||
|
@ -532,7 +532,7 @@ msgstr "Asta înseamnă o medie de %(pages)s de pagini pe carte."
|
|||
#, python-format
|
||||
msgid "(%(no_page_number)s book doesn’t have pages)"
|
||||
msgid_plural "(%(no_page_number)s books don’t have pages)"
|
||||
msgstr[0] ""
|
||||
msgstr[0] "(cartea %(no_page_number)s nu are pagini)"
|
||||
msgstr[1] ""
|
||||
msgstr[2] "(cărțile %(no_page_number)s nu au pagini)"
|
||||
|
||||
|
@ -576,9 +576,9 @@ msgstr "Felicitări!"
|
|||
#, python-format
|
||||
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"
|
||||
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[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
|
||||
msgid "Their best rated review"
|
||||
|
@ -816,7 +816,7 @@ msgstr "Clic pentru a mări"
|
|||
#, python-format
|
||||
msgid "(%(review_count)s review)"
|
||||
msgid_plural "(%(review_count)s reviews)"
|
||||
msgstr[0] ""
|
||||
msgstr[0] "(%(review_count)s recenzie)"
|
||||
msgstr[1] ""
|
||||
msgstr[2] "(%(review_count)s recenzii)"
|
||||
|
||||
|
@ -834,7 +834,7 @@ msgstr "Descriere:"
|
|||
#, python-format
|
||||
msgid "%(count)s edition"
|
||||
msgid_plural "%(count)s editions"
|
||||
msgstr[0] ""
|
||||
msgstr[0] "%(count)s ediție"
|
||||
msgstr[1] ""
|
||||
msgstr[2] "%(count)s ediții"
|
||||
|
||||
|
@ -3379,7 +3379,7 @@ msgstr "Opere"
|
|||
#, python-format
|
||||
msgid "%(display_count)s open report"
|
||||
msgid_plural "%(display_count)s open reports"
|
||||
msgstr[0] ""
|
||||
msgstr[0] "%(display_count)s raport deschis"
|
||||
msgstr[1] ""
|
||||
msgstr[2] "%(display_count)s raporturi dechise"
|
||||
|
||||
|
|
Loading…
Reference in a new issue