diff --git a/bookwyrm/forms/books.py b/bookwyrm/forms/books.py index 72df1371..9b3c8401 100644 --- a/bookwyrm/forms/books.py +++ b/bookwyrm/forms/books.py @@ -4,6 +4,7 @@ from django import forms from bookwyrm import models from bookwyrm.models.fields import ClearableFileInputWithWarning from .custom_form import CustomForm +from .widgets import ArrayWidget, SelectDateWidget, Select # pylint: disable=missing-class-docstring @@ -14,14 +15,6 @@ class CoverForm(CustomForm): help_texts = {f: None for f in fields} -class ArrayWidget(forms.widgets.TextInput): - # pylint: disable=unused-argument - # pylint: disable=no-self-use - def value_from_datadict(self, data, files, name): - """get all values for this name""" - return [i for i in data.getlist(name) if i] - - class EditionForm(CustomForm): class Meta: model = models.Edition @@ -56,16 +49,16 @@ class EditionForm(CustomForm): "publishers": forms.TextInput( attrs={"aria-describedby": "desc_publishers_help desc_publishers"} ), - "first_published_date": forms.SelectDateWidget( + "first_published_date": SelectDateWidget( attrs={"aria-describedby": "desc_first_published_date"} ), - "published_date": forms.SelectDateWidget( + "published_date": SelectDateWidget( attrs={"aria-describedby": "desc_published_date"} ), "cover": ClearableFileInputWithWarning( attrs={"aria-describedby": "desc_cover"} ), - "physical_format": forms.Select( + "physical_format": Select( attrs={"aria-describedby": "desc_physical_format"} ), "physical_format_detail": forms.TextInput( @@ -85,3 +78,27 @@ class EditionForm(CustomForm): ), "ASIN": forms.TextInput(attrs={"aria-describedby": "desc_ASIN"}), } + + +class EditionFromWorkForm(CustomForm): + def __init__(self, *args, **kwargs): + super().__init__(*args, **kwargs) + # make all fields hidden + for visible in self.visible_fields(): + visible.field.widget = forms.HiddenInput() + + class Meta: + model = models.Work + fields = [ + "title", + "subtitle", + "authors", + "description", + "languages", + "series", + "series_number", + "subjects", + "subject_places", + "cover", + "first_published_date", + ] diff --git a/bookwyrm/forms/forms.py b/bookwyrm/forms/forms.py index 8af8fb81..9d8f9f39 100644 --- a/bookwyrm/forms/forms.py +++ b/bookwyrm/forms/forms.py @@ -45,7 +45,7 @@ class ReportForm(CustomForm): class ReadThroughForm(CustomForm): def clean(self): - """make sure the email isn't in use by a registered user""" + """don't let readthroughs end before they start""" cleaned_data = super().clean() start_date = cleaned_data.get("start_date") finish_date = cleaned_data.get("finish_date") diff --git a/bookwyrm/forms/landing.py b/bookwyrm/forms/landing.py index 61b92ee8..b01c2cc9 100644 --- a/bookwyrm/forms/landing.py +++ b/bookwyrm/forms/landing.py @@ -42,4 +42,4 @@ class InviteRequestForm(CustomForm): class Meta: model = models.InviteRequest - fields = ["email"] + fields = ["email", "answer"] diff --git a/bookwyrm/forms/widgets.py b/bookwyrm/forms/widgets.py new file mode 100644 index 00000000..ee9345aa --- /dev/null +++ b/bookwyrm/forms/widgets.py @@ -0,0 +1,70 @@ +""" using django model forms """ +from django import forms + + +class ArrayWidget(forms.widgets.TextInput): + """Inputs for postgres array fields""" + + # pylint: disable=unused-argument + # pylint: disable=no-self-use + def value_from_datadict(self, data, files, name): + """get all values for this name""" + return [i for i in data.getlist(name) if i] + + +class Select(forms.Select): + """custom template for select widget""" + + template_name = "widgets/select.html" + + +class SelectDateWidget(forms.SelectDateWidget): + """ + A widget that splits date input into two {% trans "This is a new work" %} @@ -119,7 +125,7 @@ {% if not confirm_mode %}
- {% if book %} + {% if book.id %} {% trans "Cancel" %} {% else %} diff --git a/bookwyrm/templates/book/edit/edit_book_form.html b/bookwyrm/templates/book/edit/edit_book_form.html index 42f1840d..bf5404be 100644 --- a/bookwyrm/templates/book/edit/edit_book_form.html +++ b/bookwyrm/templates/book/edit/edit_book_form.html @@ -10,6 +10,8 @@ {% csrf_token %} + +
@@ -153,8 +155,7 @@ - - + {{ form.first_published_date }} {% include 'snippets/form_errors.html' with errors_list=form.first_published_date.errors id="desc_first_published_date" %}
@@ -162,7 +163,7 @@ - + {{ form.published_date }} {% include 'snippets/form_errors.html' with errors_list=form.published_date.errors id="desc_published_date" %}
@@ -175,6 +176,8 @@
{% if book.authors.exists %} + {# preserve authors if the book is unsaved #} +
{% for author in book.authors.all %}
@@ -255,9 +258,7 @@ -
- {{ form.physical_format }} -
+ {{ form.physical_format }} {% include 'snippets/form_errors.html' with errors_list=form.physical_format.errors id="desc_physical_format" %}
diff --git a/bookwyrm/templates/book/editions/editions.html b/bookwyrm/templates/book/editions/editions.html index a3ff0802..e15e7a74 100644 --- a/bookwyrm/templates/book/editions/editions.html +++ b/bookwyrm/templates/book/editions/editions.html @@ -46,7 +46,36 @@ {% endfor %}
-
+
{% include 'snippets/pagination.html' with page=editions path=request.path %}
+ +
+

+ {% trans "Can't find the edition you're looking for?" %} +

+ +
+ {% csrf_token %} + {{ work_form.title }} + {{ work_form.subtitle }} + {{ work_form.authors }} + {{ work_form.description }} + {{ work_form.languages }} + {{ work_form.series }} + {{ work_form.cover }} + {{ work_form.first_published_date }} + {% for subject in work.subjects %} + + {% endfor %} + + +
+ +
+
+
+ {% endblock %} diff --git a/bookwyrm/templates/book/file_links/edit_links.html b/bookwyrm/templates/book/file_links/edit_links.html index 9048ce7a..a088a40d 100644 --- a/bookwyrm/templates/book/file_links/edit_links.html +++ b/bookwyrm/templates/book/file_links/edit_links.html @@ -8,7 +8,7 @@

- {% blocktrans with title=book|book_title %} + {% blocktrans trimmed with title=book|book_title %} Links for "{{ title }}" {% endblocktrans %}

diff --git a/bookwyrm/templates/components/tooltip.html b/bookwyrm/templates/components/tooltip.html deleted file mode 100644 index 3176a639..00000000 --- a/bookwyrm/templates/components/tooltip.html +++ /dev/null @@ -1,11 +0,0 @@ -{% load i18n %} - -{% trans "Help" as button_text %} -{% include 'snippets/toggle/open_button.html' with text=button_text class="ml-3 is-rounded is-small has-background-body p-0 pb-1" icon="question-circle is-size-6" controls_text=controls_text controls_uid=controls_uid %} - - diff --git a/bookwyrm/templates/confirm_email/confirm_email.html b/bookwyrm/templates/confirm_email/confirm_email.html index 8c8adcdd..abdd3a73 100644 --- a/bookwyrm/templates/confirm_email/confirm_email.html +++ b/bookwyrm/templates/confirm_email/confirm_email.html @@ -29,9 +29,16 @@
- {% trans "Can't find your code?" as button_text %} - {% include "snippets/toggle/open_button.html" with text=button_text controls_text="resend_form" focus="resend_form_header" %} - {% include "confirm_email/resend_form.html" with controls_text="resend_form" %} +
+ +
+ {% include "confirm_email/resend_modal.html" with id="resend_form" %}
diff --git a/bookwyrm/templates/confirm_email/resend.html b/bookwyrm/templates/confirm_email/resend.html new file mode 100644 index 00000000..221f0756 --- /dev/null +++ b/bookwyrm/templates/confirm_email/resend.html @@ -0,0 +1,10 @@ +{% extends 'landing/layout.html' %} +{% load i18n %} + +{% block title %} +{% trans "Resend confirmation link" %} +{% endblock %} + +{% block content %} +{% include "confirm_email/resend_modal.html" with active=True static=True id="resend-modal" %} +{% endblock %} diff --git a/bookwyrm/templates/confirm_email/resend_form.html b/bookwyrm/templates/confirm_email/resend_form.html deleted file mode 100644 index 7c0c1098..00000000 --- a/bookwyrm/templates/confirm_email/resend_form.html +++ /dev/null @@ -1,20 +0,0 @@ -{% extends "components/inline_form.html" %} -{% load i18n %} -{% block header %} -{% trans "Resend confirmation link" %} -{% endblock %} - -{% block form %} -
- {% csrf_token %} -
- -
- -
-
-
- -
-
-{% endblock %} diff --git a/bookwyrm/templates/confirm_email/resend_modal.html b/bookwyrm/templates/confirm_email/resend_modal.html new file mode 100644 index 00000000..beb9318a --- /dev/null +++ b/bookwyrm/templates/confirm_email/resend_modal.html @@ -0,0 +1,44 @@ +{% extends "components/modal.html" %} +{% load i18n %} + +{% block modal-title %} +{% trans "Resend confirmation link" %} +{% endblock %} + +{% block modal-form-open %} +
+{% endblock %} + +{% block modal-body %} +{% csrf_token %} +
+ +
+ + {% if error %} +
+

+ {% trans "No user matching this email address found." %} +

+
+ {% endif %} +
+
+{% endblock %} + +{% block modal-footer %} +
+ +
+{% endblock %} + +{% block modal-form-close %} +
+{% endblock %} diff --git a/bookwyrm/templates/feed/suggested_books.html b/bookwyrm/templates/feed/suggested_books.html index 2582dcf0..12e47820 100644 --- a/bookwyrm/templates/feed/suggested_books.html +++ b/bookwyrm/templates/feed/suggested_books.html @@ -5,7 +5,19 @@

{% trans "Your Books" %}

{% if not suggested_books %} -

{% trans "There are no books here right now! Try searching for a book to get started" %}

+ +
+

{% trans "There are no books here right now! Try searching for a book to get started" %}

+ +
+
+ {% else %} {% with active_book=request.GET.book %}
diff --git a/bookwyrm/templates/import/import.html b/bookwyrm/templates/import/import.html index fdeb0e55..6df7c084 100644 --- a/bookwyrm/templates/import/import.html +++ b/bookwyrm/templates/import/import.html @@ -14,28 +14,32 @@
-
-
- -
{{ import_form.csv_file }} @@ -63,7 +67,7 @@

{% trans "Recent Imports" %}

{% if not jobs %} -

{% trans "No recent imports" %}

+

{% trans "No recent imports" %}

{% endif %}
    {% for job in jobs %} diff --git a/bookwyrm/templates/import/tooltip.html b/bookwyrm/templates/import/tooltip.html deleted file mode 100644 index f2712b7e..00000000 --- a/bookwyrm/templates/import/tooltip.html +++ /dev/null @@ -1,8 +0,0 @@ -{% extends 'components/tooltip.html' %} -{% load i18n %} - -{% block tooltip_content %} - -{% trans 'You can download your Goodreads data from the Import/Export page of your Goodreads account.' %} - -{% endblock %} diff --git a/bookwyrm/templates/landing/layout.html b/bookwyrm/templates/landing/layout.html index 6d69cafc..bf0a6b2a 100644 --- a/bookwyrm/templates/landing/layout.html +++ b/bookwyrm/templates/landing/layout.html @@ -70,6 +70,14 @@ {% include 'snippets/form_errors.html' with errors_list=request_form.email.errors id="desc_request_email" %}
+ {% if site.invite_request_question %} +
+ + + {% include 'snippets/form_errors.html' with errors_list=request_form.answer.errors id="desc_answer_register" %} +
+ {% endif %} + {% endif %} diff --git a/bookwyrm/templates/preferences/export.html b/bookwyrm/templates/preferences/export.html new file mode 100644 index 00000000..86505144 --- /dev/null +++ b/bookwyrm/templates/preferences/export.html @@ -0,0 +1,22 @@ +{% extends 'preferences/layout.html' %} +{% load i18n %} + +{% block title %}{% trans "CSV Export" %}{% endblock %} + +{% block header %} +{% trans "CSV Export" %} +{% endblock %} + +{% block panel %} +
+

+ {% trans "Your export will include all the books on your shelves, books you have reviewed, and books with reading activity." %} +

+

+ + + Download file + +

+
+{% endblock %} diff --git a/bookwyrm/templates/preferences/layout.html b/bookwyrm/templates/preferences/layout.html index bf4fed7d..27d91c48 100644 --- a/bookwyrm/templates/preferences/layout.html +++ b/bookwyrm/templates/preferences/layout.html @@ -24,6 +24,17 @@ {% trans "Delete Account" %} + +