diff --git a/.css-config-sample/_instance-settings.scss b/.css-config-sample/_instance-settings.scss deleted file mode 100644 index e86c1ce00..000000000 --- a/.css-config-sample/_instance-settings.scss +++ /dev/null @@ -1,3 +0,0 @@ -@charset "utf-8"; - -// Copy this file to bookwyrm/static/css/ and set your instance custom styles. diff --git a/.gitignore b/.gitignore index bd23e38a6..ee82c650d 100644 --- a/.gitignore +++ b/.gitignore @@ -21,7 +21,8 @@ .env /images/ bookwyrm/static/css/bookwyrm.css -bookwyrm/static/css/_instance-settings.scss +bookwyrm/static/css/themes/ +!bookwyrm/static/css/themes/bookwyrm-*.scss # Testing .coverage diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..9fa808eed --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +**/vendor/* diff --git a/README.md b/README.md index 4b7d38439..cec05d45e 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Social reading and reviewing, decentralized with ActivityPub. This branch is a f - [Set up Bookwyrm](#set-up-bookwyrm) ## Joining BookWyrm -BookWyrm is still a young piece of software, and isn't at the level of stability and feature-richness that you'd find in a production-ready application. But it does what it says on the box! If you'd like to join an instance, you can check out the [instances](https://docs.joinbookwyrm.com/instances.html) list. +BookWyrm is still a young piece of software, and isn't at the level of stability and feature-richness that you'd find in a production-ready application. But it does what it says on the box! If you'd like to join an instance, you can check out the [instances](https://joinbookwyrm.com/instances/) list. You can request an invite by entering your email address at https://bookwyrm.social. diff --git a/bookwyrm/activitypub/person.py b/bookwyrm/activitypub/person.py index 576e7f9a6..61c15a579 100644 --- a/bookwyrm/activitypub/person.py +++ b/bookwyrm/activitypub/person.py @@ -39,4 +39,5 @@ class Person(ActivityObject): bookwyrmUser: bool = False manuallyApprovesFollowers: str = False discoverable: str = False + hideFollows: str = False type: str = "Person" diff --git a/bookwyrm/apps.py b/bookwyrm/apps.py index d494877d6..786f86e1c 100644 --- a/bookwyrm/apps.py +++ b/bookwyrm/apps.py @@ -19,11 +19,11 @@ def download_file(url, destination): with open(destination, "b+w") as outfile: outfile.write(stream.read()) except (urllib.error.HTTPError, urllib.error.URLError): - logger.error("Failed to download file %s", url) + logger.info("Failed to download file %s", url) except OSError: - logger.error("Couldn't open font file %s for writing", destination) + logger.info("Couldn't open font file %s for writing", destination) except: # pylint: disable=bare-except - logger.exception("Unknown error in file download") + logger.info("Unknown error in file download") class BookwyrmConfig(AppConfig): diff --git a/bookwyrm/connectors/abstract_connector.py b/bookwyrm/connectors/abstract_connector.py index d8b9c6300..56e273886 100644 --- a/bookwyrm/connectors/abstract_connector.py +++ b/bookwyrm/connectors/abstract_connector.py @@ -131,7 +131,7 @@ class AbstractConnector(AbstractMinimalConnector): try: work_data = self.get_work_from_edition_data(data) except (KeyError, ConnectorException) as err: - logger.exception(err) + logger.info(err) work_data = data if not work_data or not edition_data: @@ -270,7 +270,7 @@ def get_data(url, params=None, timeout=10): timeout=timeout, ) except RequestException as err: - logger.exception(err) + logger.info(err) raise ConnectorException(err) if not resp.ok: @@ -278,7 +278,7 @@ def get_data(url, params=None, timeout=10): try: data = resp.json() except ValueError as err: - logger.exception(err) + logger.info(err) raise ConnectorException(err) return data @@ -296,7 +296,7 @@ def get_image(url, timeout=10): timeout=timeout, ) except RequestException as err: - logger.exception(err) + logger.info(err) return None, None if not resp.ok: @@ -305,7 +305,7 @@ def get_image(url, timeout=10): image_content = ContentFile(resp.content) extension = imghdr.what(None, image_content.read()) if not extension: - logger.exception("File requested was not an image: %s", url) + logger.info("File requested was not an image: %s", url) return None, None return image_content, extension diff --git a/bookwyrm/connectors/connector_manager.py b/bookwyrm/connectors/connector_manager.py index 3bdd5cb41..14bb702cb 100644 --- a/bookwyrm/connectors/connector_manager.py +++ b/bookwyrm/connectors/connector_manager.py @@ -39,7 +39,7 @@ def search(query, min_confidence=0.1, return_first=False): try: result_set = connector.isbn_search(isbn) except Exception as err: # pylint: disable=broad-except - logger.exception(err) + logger.info(err) # if this fails, we can still try regular search # if no isbn search results, we fallback to generic search @@ -48,7 +48,7 @@ def search(query, min_confidence=0.1, return_first=False): result_set = connector.search(query, min_confidence=min_confidence) except Exception as err: # pylint: disable=broad-except # we don't want *any* error to crash the whole search page - logger.exception(err) + logger.info(err) continue if return_first and result_set: diff --git a/bookwyrm/context_processors.py b/bookwyrm/context_processors.py index 309e84ed1..0047bfce1 100644 --- a/bookwyrm/context_processors.py +++ b/bookwyrm/context_processors.py @@ -8,8 +8,20 @@ def site_settings(request): # pylint: disable=unused-argument if not request.is_secure(): request_protocol = "http://" + site = models.SiteSettings.objects.get() + theme = "css/themes/bookwyrm-light.scss" + if ( + hasattr(request, "user") + and request.user.is_authenticated + and request.user.theme + ): + theme = request.user.theme.path + elif site.default_theme: + theme = site.default_theme.path + return { - "site": models.SiteSettings.objects.get(), + "site": site, + "site_theme": theme, "active_announcements": models.Announcement.active_announcements(), "thumbnail_generation_enabled": settings.ENABLE_THUMBNAIL_GENERATION, "media_full_url": settings.MEDIA_FULL_URL, diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py deleted file mode 100644 index 7ae4e446f..000000000 --- a/bookwyrm/forms.py +++ /dev/null @@ -1,558 +0,0 @@ -""" using django model forms """ -import datetime -from collections import defaultdict -from urllib.parse import urlparse - -from django import forms -from django.forms import ModelForm, PasswordInput, widgets, ChoiceField -from django.forms.widgets import Textarea -from django.utils import timezone -from django.utils.translation import gettext_lazy as _ - -from bookwyrm import models -from bookwyrm.models.fields import ClearableFileInputWithWarning -from bookwyrm.models.user import FeedFilterChoices - - -class CustomForm(ModelForm): - """add css classes to the forms""" - - def __init__(self, *args, **kwargs): - css_classes = defaultdict(lambda: "") - css_classes["text"] = "input" - css_classes["password"] = "input" - css_classes["email"] = "input" - css_classes["number"] = "input" - css_classes["checkbox"] = "checkbox" - css_classes["textarea"] = "textarea" - # pylint: disable=super-with-arguments - super(CustomForm, self).__init__(*args, **kwargs) - for visible in self.visible_fields(): - if hasattr(visible.field.widget, "input_type"): - input_type = visible.field.widget.input_type - if isinstance(visible.field.widget, Textarea): - input_type = "textarea" - visible.field.widget.attrs["rows"] = 5 - visible.field.widget.attrs["class"] = css_classes[input_type] - - -# pylint: disable=missing-class-docstring -class LoginForm(CustomForm): - class Meta: - model = models.User - fields = ["localname", "password"] - help_texts = {f: None for f in fields} - widgets = { - "password": PasswordInput(), - } - - -class RegisterForm(CustomForm): - class Meta: - model = models.User - fields = ["localname", "email", "password"] - help_texts = {f: None for f in fields} - widgets = {"password": PasswordInput()} - - def clean(self): - """Check if the username is taken""" - cleaned_data = super().clean() - localname = cleaned_data.get("localname").strip() - if models.User.objects.filter(localname=localname).first(): - self.add_error("localname", _("User with this username already exists")) - - -class RatingForm(CustomForm): - class Meta: - model = models.ReviewRating - fields = ["user", "book", "rating", "privacy"] - - -class ReviewForm(CustomForm): - class Meta: - model = models.Review - fields = [ - "user", - "book", - "name", - "content", - "rating", - "content_warning", - "sensitive", - "privacy", - ] - - -class CommentForm(CustomForm): - class Meta: - model = models.Comment - fields = [ - "user", - "book", - "content", - "content_warning", - "sensitive", - "privacy", - "progress", - "progress_mode", - "reading_status", - ] - - -class QuotationForm(CustomForm): - class Meta: - model = models.Quotation - fields = [ - "user", - "book", - "quote", - "content", - "content_warning", - "sensitive", - "privacy", - "position", - "position_mode", - ] - - -class ReplyForm(CustomForm): - class Meta: - model = models.Status - fields = [ - "user", - "content", - "content_warning", - "sensitive", - "reply_parent", - "privacy", - ] - - -class StatusForm(CustomForm): - class Meta: - model = models.Status - fields = ["user", "content", "content_warning", "sensitive", "privacy"] - - -class DirectForm(CustomForm): - class Meta: - model = models.Status - fields = ["user", "content", "content_warning", "sensitive", "privacy"] - - -class EditUserForm(CustomForm): - class Meta: - model = models.User - fields = [ - "avatar", - "name", - "email", - "summary", - "show_goal", - "show_suggested_users", - "manually_approves_followers", - "default_post_privacy", - "discoverable", - "preferred_timezone", - "preferred_language", - ] - help_texts = {f: None for f in fields} - widgets = { - "avatar": ClearableFileInputWithWarning( - attrs={"aria-describedby": "desc_avatar"} - ), - "name": forms.TextInput(attrs={"aria-describedby": "desc_name"}), - "summary": forms.Textarea(attrs={"aria-describedby": "desc_summary"}), - "email": forms.EmailInput(attrs={"aria-describedby": "desc_email"}), - "discoverable": forms.CheckboxInput( - attrs={"aria-describedby": "desc_discoverable"} - ), - } - - -class LimitedEditUserForm(CustomForm): - class Meta: - model = models.User - fields = [ - "avatar", - "name", - "summary", - "manually_approves_followers", - "discoverable", - ] - help_texts = {f: None for f in fields} - widgets = { - "avatar": ClearableFileInputWithWarning( - attrs={"aria-describedby": "desc_avatar"} - ), - "name": forms.TextInput(attrs={"aria-describedby": "desc_name"}), - "summary": forms.Textarea(attrs={"aria-describedby": "desc_summary"}), - "discoverable": forms.CheckboxInput( - attrs={"aria-describedby": "desc_discoverable"} - ), - } - - -class DeleteUserForm(CustomForm): - class Meta: - model = models.User - fields = ["password"] - - -class UserGroupForm(CustomForm): - class Meta: - model = models.User - fields = ["groups"] - - -class FeedStatusTypesForm(CustomForm): - class Meta: - model = models.User - fields = ["feed_status_types"] - help_texts = {f: None for f in fields} - widgets = { - "feed_status_types": widgets.CheckboxSelectMultiple( - choices=FeedFilterChoices, - ), - } - - -class CoverForm(CustomForm): - class Meta: - model = models.Book - fields = ["cover"] - help_texts = {f: None for f in fields} - - -class LinkDomainForm(CustomForm): - class Meta: - model = models.LinkDomain - fields = ["name"] - - -class FileLinkForm(CustomForm): - class Meta: - model = models.FileLink - fields = ["url", "filetype", "availability", "book", "added_by"] - - def clean(self): - """make sure the domain isn't blocked or pending""" - cleaned_data = super().clean() - url = cleaned_data.get("url") - filetype = cleaned_data.get("filetype") - book = cleaned_data.get("book") - domain = urlparse(url).netloc - if models.LinkDomain.objects.filter(domain=domain).exists(): - status = models.LinkDomain.objects.get(domain=domain).status - if status == "blocked": - # pylint: disable=line-too-long - self.add_error( - "url", - _( - "This domain is blocked. Please contact your administrator if you think this is an error." - ), - ) - elif models.FileLink.objects.filter( - url=url, book=book, filetype=filetype - ).exists(): - # pylint: disable=line-too-long - self.add_error( - "url", - _( - "This link with file type has already been added for this book. If it is not visible, the domain is still pending." - ), - ) - - -class EditionForm(CustomForm): - class Meta: - model = models.Edition - exclude = [ - "remote_id", - "origin_id", - "created_date", - "updated_date", - "edition_rank", - "authors", - "parent_work", - "shelves", - "connector", - "search_vector", - "links", - "file_links", - ] - widgets = { - "title": forms.TextInput(attrs={"aria-describedby": "desc_title"}), - "subtitle": forms.TextInput(attrs={"aria-describedby": "desc_subtitle"}), - "description": forms.Textarea( - attrs={"aria-describedby": "desc_description"} - ), - "series": forms.TextInput(attrs={"aria-describedby": "desc_series"}), - "series_number": forms.TextInput( - attrs={"aria-describedby": "desc_series_number"} - ), - "languages": forms.TextInput( - attrs={"aria-describedby": "desc_languages_help desc_languages"} - ), - "publishers": forms.TextInput( - attrs={"aria-describedby": "desc_publishers_help desc_publishers"} - ), - "first_published_date": forms.SelectDateWidget( - attrs={"aria-describedby": "desc_first_published_date"} - ), - "published_date": forms.SelectDateWidget( - attrs={"aria-describedby": "desc_published_date"} - ), - "cover": ClearableFileInputWithWarning( - attrs={"aria-describedby": "desc_cover"} - ), - "physical_format": forms.Select( - attrs={"aria-describedby": "desc_physical_format"} - ), - "physical_format_detail": forms.TextInput( - attrs={"aria-describedby": "desc_physical_format_detail"} - ), - "pages": forms.NumberInput(attrs={"aria-describedby": "desc_pages"}), - "isbn_13": forms.TextInput(attrs={"aria-describedby": "desc_isbn_13"}), - "isbn_10": forms.TextInput(attrs={"aria-describedby": "desc_isbn_10"}), - "openlibrary_key": forms.TextInput( - attrs={"aria-describedby": "desc_openlibrary_key"} - ), - "inventaire_id": forms.TextInput( - attrs={"aria-describedby": "desc_inventaire_id"} - ), - "oclc_number": forms.TextInput( - attrs={"aria-describedby": "desc_oclc_number"} - ), - "ASIN": forms.TextInput(attrs={"aria-describedby": "desc_ASIN"}), - } - - -class AuthorForm(CustomForm): - class Meta: - model = models.Author - fields = [ - "last_edited_by", - "name", - "aliases", - "bio", - "wikipedia_link", - "born", - "died", - "openlibrary_key", - "inventaire_id", - "librarything_key", - "goodreads_key", - "isni", - ] - widgets = { - "name": forms.TextInput(attrs={"aria-describedby": "desc_name"}), - "aliases": forms.TextInput(attrs={"aria-describedby": "desc_aliases"}), - "bio": forms.Textarea(attrs={"aria-describedby": "desc_bio"}), - "wikipedia_link": forms.TextInput( - attrs={"aria-describedby": "desc_wikipedia_link"} - ), - "born": forms.SelectDateWidget(attrs={"aria-describedby": "desc_born"}), - "died": forms.SelectDateWidget(attrs={"aria-describedby": "desc_died"}), - "oepnlibrary_key": forms.TextInput( - attrs={"aria-describedby": "desc_oepnlibrary_key"} - ), - "inventaire_id": forms.TextInput( - attrs={"aria-describedby": "desc_inventaire_id"} - ), - "librarything_key": forms.TextInput( - attrs={"aria-describedby": "desc_librarything_key"} - ), - "goodreads_key": forms.TextInput( - attrs={"aria-describedby": "desc_goodreads_key"} - ), - } - - -class ImportForm(forms.Form): - csv_file = forms.FileField() - - -class ExpiryWidget(widgets.Select): - def value_from_datadict(self, data, files, name): - """human-readable exiration time buckets""" - selected_string = super().value_from_datadict(data, files, name) - - if selected_string == "day": - interval = datetime.timedelta(days=1) - elif selected_string == "week": - interval = datetime.timedelta(days=7) - elif selected_string == "month": - interval = datetime.timedelta(days=31) # Close enough? - elif selected_string == "forever": - return None - else: - return selected_string # This will raise - - return timezone.now() + interval - - -class InviteRequestForm(CustomForm): - def clean(self): - """make sure the email isn't in use by a registered user""" - cleaned_data = super().clean() - email = cleaned_data.get("email") - if email and models.User.objects.filter(email=email).exists(): - self.add_error("email", _("A user with this email already exists.")) - - class Meta: - model = models.InviteRequest - fields = ["email"] - - -class CreateInviteForm(CustomForm): - class Meta: - model = models.SiteInvite - exclude = ["code", "user", "times_used", "invitees"] - widgets = { - "expiry": ExpiryWidget( - choices=[ - ("day", _("One Day")), - ("week", _("One Week")), - ("month", _("One Month")), - ("forever", _("Does Not Expire")), - ] - ), - "use_limit": widgets.Select( - choices=[(i, _(f"{i} uses")) for i in [1, 5, 10, 25, 50, 100]] - + [(None, _("Unlimited"))] - ), - } - - -class ShelfForm(CustomForm): - class Meta: - model = models.Shelf - fields = ["user", "name", "privacy", "description"] - - -class GoalForm(CustomForm): - class Meta: - model = models.AnnualGoal - fields = ["user", "year", "goal", "privacy"] - - -class SiteForm(CustomForm): - class Meta: - model = models.SiteSettings - exclude = ["admin_code", "install_mode"] - widgets = { - "instance_short_description": forms.TextInput( - attrs={"aria-describedby": "desc_instance_short_description"} - ), - "require_confirm_email": forms.CheckboxInput( - attrs={"aria-describedby": "desc_require_confirm_email"} - ), - "invite_request_text": forms.Textarea( - attrs={"aria-describedby": "desc_invite_request_text"} - ), - } - - -class AnnouncementForm(CustomForm): - class Meta: - model = models.Announcement - exclude = ["remote_id"] - widgets = { - "preview": forms.TextInput(attrs={"aria-describedby": "desc_preview"}), - "content": forms.Textarea(attrs={"aria-describedby": "desc_content"}), - "event_date": forms.SelectDateWidget( - attrs={"aria-describedby": "desc_event_date"} - ), - "start_date": forms.SelectDateWidget( - attrs={"aria-describedby": "desc_start_date"} - ), - "end_date": forms.SelectDateWidget( - attrs={"aria-describedby": "desc_end_date"} - ), - "active": forms.CheckboxInput(attrs={"aria-describedby": "desc_active"}), - } - - -class ListForm(CustomForm): - class Meta: - model = models.List - fields = ["user", "name", "description", "curation", "privacy", "group"] - - -class ListItemForm(CustomForm): - class Meta: - model = models.ListItem - fields = ["user", "book", "book_list", "notes"] - - -class GroupForm(CustomForm): - class Meta: - model = models.Group - fields = ["user", "privacy", "name", "description"] - - -class ReportForm(CustomForm): - class Meta: - model = models.Report - fields = ["user", "reporter", "status", "links", "note"] - - -class EmailBlocklistForm(CustomForm): - class Meta: - model = models.EmailBlocklist - fields = ["domain"] - widgets = { - "avatar": forms.TextInput(attrs={"aria-describedby": "desc_domain"}), - } - - -class IPBlocklistForm(CustomForm): - class Meta: - model = models.IPBlocklist - fields = ["address"] - - -class ServerForm(CustomForm): - class Meta: - model = models.FederatedServer - exclude = ["remote_id"] - - -class SortListForm(forms.Form): - sort_by = ChoiceField( - choices=( - ("order", _("List Order")), - ("title", _("Book Title")), - ("rating", _("Rating")), - ), - label=_("Sort By"), - ) - direction = ChoiceField( - choices=( - ("ascending", _("Ascending")), - ("descending", _("Descending")), - ), - ) - - -class ReadThroughForm(CustomForm): - def clean(self): - """make sure the email isn't in use by a registered user""" - cleaned_data = super().clean() - start_date = cleaned_data.get("start_date") - finish_date = cleaned_data.get("finish_date") - if start_date and finish_date and start_date > finish_date: - self.add_error( - "finish_date", _("Reading finish date cannot be before start date.") - ) - - class Meta: - model = models.ReadThrough - fields = ["user", "book", "start_date", "finish_date"] - - -class AutoModRuleForm(CustomForm): - class Meta: - model = models.AutoMod - fields = ["string_match", "flag_users", "flag_statuses", "created_by"] diff --git a/bookwyrm/forms/__init__.py b/bookwyrm/forms/__init__.py new file mode 100644 index 000000000..075752936 --- /dev/null +++ b/bookwyrm/forms/__init__.py @@ -0,0 +1,12 @@ +""" make forms available to the app """ +# site admin +from .admin import * +from .author import * +from .books import * +from .edit_user import * +from .forms import * +from .groups import * +from .landing import * +from .links import * +from .lists import * +from .status import * diff --git a/bookwyrm/forms/admin.py b/bookwyrm/forms/admin.py new file mode 100644 index 000000000..4141327d3 --- /dev/null +++ b/bookwyrm/forms/admin.py @@ -0,0 +1,141 @@ +""" using django model forms """ +import datetime + +from django import forms +from django.forms import widgets +from django.utils import timezone +from django.utils.translation import gettext_lazy as _ +from django_celery_beat.models import IntervalSchedule + +from bookwyrm import models +from .custom_form import CustomForm + + +# pylint: disable=missing-class-docstring +class ExpiryWidget(widgets.Select): + def value_from_datadict(self, data, files, name): + """human-readable exiration time buckets""" + selected_string = super().value_from_datadict(data, files, name) + + if selected_string == "day": + interval = datetime.timedelta(days=1) + elif selected_string == "week": + interval = datetime.timedelta(days=7) + elif selected_string == "month": + interval = datetime.timedelta(days=31) # Close enough? + elif selected_string == "forever": + return None + else: + return selected_string # This will raise + + return timezone.now() + interval + + +class CreateInviteForm(CustomForm): + class Meta: + model = models.SiteInvite + exclude = ["code", "user", "times_used", "invitees"] + widgets = { + "expiry": ExpiryWidget( + choices=[ + ("day", _("One Day")), + ("week", _("One Week")), + ("month", _("One Month")), + ("forever", _("Does Not Expire")), + ] + ), + "use_limit": widgets.Select( + choices=[(i, _(f"{i} uses")) for i in [1, 5, 10, 25, 50, 100]] + + [(None, _("Unlimited"))] + ), + } + + +class SiteForm(CustomForm): + class Meta: + model = models.SiteSettings + exclude = ["admin_code", "install_mode"] + widgets = { + "instance_short_description": forms.TextInput( + attrs={"aria-describedby": "desc_instance_short_description"} + ), + "require_confirm_email": forms.CheckboxInput( + attrs={"aria-describedby": "desc_require_confirm_email"} + ), + "invite_request_text": forms.Textarea( + attrs={"aria-describedby": "desc_invite_request_text"} + ), + } + + +class ThemeForm(CustomForm): + class Meta: + model = models.Theme + fields = ["name", "path"] + widgets = { + "name": forms.TextInput(attrs={"aria-describedby": "desc_name"}), + "path": forms.TextInput( + attrs={ + "aria-describedby": "desc_path", + "placeholder": "css/themes/theme-name.scss", + } + ), + } + + +class AnnouncementForm(CustomForm): + class Meta: + model = models.Announcement + exclude = ["remote_id"] + widgets = { + "preview": forms.TextInput(attrs={"aria-describedby": "desc_preview"}), + "content": forms.Textarea(attrs={"aria-describedby": "desc_content"}), + "event_date": forms.SelectDateWidget( + attrs={"aria-describedby": "desc_event_date"} + ), + "start_date": forms.SelectDateWidget( + attrs={"aria-describedby": "desc_start_date"} + ), + "end_date": forms.SelectDateWidget( + attrs={"aria-describedby": "desc_end_date"} + ), + "active": forms.CheckboxInput(attrs={"aria-describedby": "desc_active"}), + } + + +class EmailBlocklistForm(CustomForm): + class Meta: + model = models.EmailBlocklist + fields = ["domain"] + widgets = { + "avatar": forms.TextInput(attrs={"aria-describedby": "desc_domain"}), + } + + +class IPBlocklistForm(CustomForm): + class Meta: + model = models.IPBlocklist + fields = ["address"] + + +class ServerForm(CustomForm): + class Meta: + model = models.FederatedServer + exclude = ["remote_id"] + + +class AutoModRuleForm(CustomForm): + class Meta: + model = models.AutoMod + fields = ["string_match", "flag_users", "flag_statuses", "created_by"] + + +class IntervalScheduleForm(CustomForm): + class Meta: + model = IntervalSchedule + fields = ["every", "period"] + + widgets = { + "every": forms.NumberInput(attrs={"aria-describedby": "desc_every"}), + "period": forms.Select(attrs={"aria-describedby": "desc_period"}), + } diff --git a/bookwyrm/forms/author.py b/bookwyrm/forms/author.py new file mode 100644 index 000000000..ca59426de --- /dev/null +++ b/bookwyrm/forms/author.py @@ -0,0 +1,47 @@ +""" using django model forms """ +from django import forms + +from bookwyrm import models +from .custom_form import CustomForm + + +# pylint: disable=missing-class-docstring +class AuthorForm(CustomForm): + class Meta: + model = models.Author + fields = [ + "last_edited_by", + "name", + "aliases", + "bio", + "wikipedia_link", + "born", + "died", + "openlibrary_key", + "inventaire_id", + "librarything_key", + "goodreads_key", + "isni", + ] + widgets = { + "name": forms.TextInput(attrs={"aria-describedby": "desc_name"}), + "aliases": forms.TextInput(attrs={"aria-describedby": "desc_aliases"}), + "bio": forms.Textarea(attrs={"aria-describedby": "desc_bio"}), + "wikipedia_link": forms.TextInput( + attrs={"aria-describedby": "desc_wikipedia_link"} + ), + "born": forms.SelectDateWidget(attrs={"aria-describedby": "desc_born"}), + "died": forms.SelectDateWidget(attrs={"aria-describedby": "desc_died"}), + "oepnlibrary_key": forms.TextInput( + attrs={"aria-describedby": "desc_oepnlibrary_key"} + ), + "inventaire_id": forms.TextInput( + attrs={"aria-describedby": "desc_inventaire_id"} + ), + "librarything_key": forms.TextInput( + attrs={"aria-describedby": "desc_librarything_key"} + ), + "goodreads_key": forms.TextInput( + attrs={"aria-describedby": "desc_goodreads_key"} + ), + } diff --git a/bookwyrm/forms/books.py b/bookwyrm/forms/books.py new file mode 100644 index 000000000..9b3c84010 --- /dev/null +++ b/bookwyrm/forms/books.py @@ -0,0 +1,104 @@ +""" using django model forms """ +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 +class CoverForm(CustomForm): + class Meta: + model = models.Book + fields = ["cover"] + help_texts = {f: None for f in fields} + + +class EditionForm(CustomForm): + class Meta: + model = models.Edition + exclude = [ + "remote_id", + "origin_id", + "created_date", + "updated_date", + "edition_rank", + "authors", + "parent_work", + "shelves", + "connector", + "search_vector", + "links", + "file_links", + ] + widgets = { + "title": forms.TextInput(attrs={"aria-describedby": "desc_title"}), + "subtitle": forms.TextInput(attrs={"aria-describedby": "desc_subtitle"}), + "description": forms.Textarea( + attrs={"aria-describedby": "desc_description"} + ), + "series": forms.TextInput(attrs={"aria-describedby": "desc_series"}), + "series_number": forms.TextInput( + attrs={"aria-describedby": "desc_series_number"} + ), + "subjects": ArrayWidget(), + "languages": forms.TextInput( + attrs={"aria-describedby": "desc_languages_help desc_languages"} + ), + "publishers": forms.TextInput( + attrs={"aria-describedby": "desc_publishers_help desc_publishers"} + ), + "first_published_date": SelectDateWidget( + attrs={"aria-describedby": "desc_first_published_date"} + ), + "published_date": SelectDateWidget( + attrs={"aria-describedby": "desc_published_date"} + ), + "cover": ClearableFileInputWithWarning( + attrs={"aria-describedby": "desc_cover"} + ), + "physical_format": Select( + attrs={"aria-describedby": "desc_physical_format"} + ), + "physical_format_detail": forms.TextInput( + attrs={"aria-describedby": "desc_physical_format_detail"} + ), + "pages": forms.NumberInput(attrs={"aria-describedby": "desc_pages"}), + "isbn_13": forms.TextInput(attrs={"aria-describedby": "desc_isbn_13"}), + "isbn_10": forms.TextInput(attrs={"aria-describedby": "desc_isbn_10"}), + "openlibrary_key": forms.TextInput( + attrs={"aria-describedby": "desc_openlibrary_key"} + ), + "inventaire_id": forms.TextInput( + attrs={"aria-describedby": "desc_inventaire_id"} + ), + "oclc_number": forms.TextInput( + attrs={"aria-describedby": "desc_oclc_number"} + ), + "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/custom_form.py b/bookwyrm/forms/custom_form.py new file mode 100644 index 000000000..74a3417a2 --- /dev/null +++ b/bookwyrm/forms/custom_form.py @@ -0,0 +1,26 @@ +""" Overrides django's default form class """ +from collections import defaultdict +from django.forms import ModelForm +from django.forms.widgets import Textarea + + +class CustomForm(ModelForm): + """add css classes to the forms""" + + def __init__(self, *args, **kwargs): + css_classes = defaultdict(lambda: "") + css_classes["text"] = "input" + css_classes["password"] = "input" + css_classes["email"] = "input" + css_classes["number"] = "input" + css_classes["checkbox"] = "checkbox" + css_classes["textarea"] = "textarea" + # pylint: disable=super-with-arguments + super(CustomForm, self).__init__(*args, **kwargs) + for visible in self.visible_fields(): + if hasattr(visible.field.widget, "input_type"): + input_type = visible.field.widget.input_type + if isinstance(visible.field.widget, Textarea): + input_type = "textarea" + visible.field.widget.attrs["rows"] = 5 + visible.field.widget.attrs["class"] = css_classes[input_type] diff --git a/bookwyrm/forms/edit_user.py b/bookwyrm/forms/edit_user.py new file mode 100644 index 000000000..d609f15dc --- /dev/null +++ b/bookwyrm/forms/edit_user.py @@ -0,0 +1,68 @@ +""" using django model forms """ +from django import forms + +from bookwyrm import models +from bookwyrm.models.fields import ClearableFileInputWithWarning +from .custom_form import CustomForm + + +# pylint: disable=missing-class-docstring +class EditUserForm(CustomForm): + class Meta: + model = models.User + fields = [ + "avatar", + "name", + "email", + "summary", + "show_goal", + "show_suggested_users", + "manually_approves_followers", + "default_post_privacy", + "discoverable", + "hide_follows", + "preferred_timezone", + "preferred_language", + "theme", + ] + help_texts = {f: None for f in fields} + widgets = { + "avatar": ClearableFileInputWithWarning( + attrs={"aria-describedby": "desc_avatar"} + ), + "name": forms.TextInput(attrs={"aria-describedby": "desc_name"}), + "summary": forms.Textarea(attrs={"aria-describedby": "desc_summary"}), + "email": forms.EmailInput(attrs={"aria-describedby": "desc_email"}), + "discoverable": forms.CheckboxInput( + attrs={"aria-describedby": "desc_discoverable"} + ), + } + + +class LimitedEditUserForm(CustomForm): + class Meta: + model = models.User + fields = [ + "avatar", + "name", + "summary", + "manually_approves_followers", + "discoverable", + ] + help_texts = {f: None for f in fields} + widgets = { + "avatar": ClearableFileInputWithWarning( + attrs={"aria-describedby": "desc_avatar"} + ), + "name": forms.TextInput(attrs={"aria-describedby": "desc_name"}), + "summary": forms.Textarea(attrs={"aria-describedby": "desc_summary"}), + "discoverable": forms.CheckboxInput( + attrs={"aria-describedby": "desc_discoverable"} + ), + } + + +class DeleteUserForm(CustomForm): + class Meta: + model = models.User + fields = ["password"] diff --git a/bookwyrm/forms/forms.py b/bookwyrm/forms/forms.py new file mode 100644 index 000000000..9d8f9f392 --- /dev/null +++ b/bookwyrm/forms/forms.py @@ -0,0 +1,59 @@ +""" using django model forms """ +from django import forms +from django.forms import widgets +from django.utils.translation import gettext_lazy as _ + +from bookwyrm import models +from bookwyrm.models.user import FeedFilterChoices +from .custom_form import CustomForm + + +# pylint: disable=missing-class-docstring +class FeedStatusTypesForm(CustomForm): + class Meta: + model = models.User + fields = ["feed_status_types"] + help_texts = {f: None for f in fields} + widgets = { + "feed_status_types": widgets.CheckboxSelectMultiple( + choices=FeedFilterChoices, + ), + } + + +class ImportForm(forms.Form): + csv_file = forms.FileField() + + +class ShelfForm(CustomForm): + class Meta: + model = models.Shelf + fields = ["user", "name", "privacy", "description"] + + +class GoalForm(CustomForm): + class Meta: + model = models.AnnualGoal + fields = ["user", "year", "goal", "privacy"] + + +class ReportForm(CustomForm): + class Meta: + model = models.Report + fields = ["user", "reporter", "status", "links", "note"] + + +class ReadThroughForm(CustomForm): + def clean(self): + """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") + if start_date and finish_date and start_date > finish_date: + self.add_error( + "finish_date", _("Reading finish date cannot be before start date.") + ) + + class Meta: + model = models.ReadThrough + fields = ["user", "book", "start_date", "finish_date"] diff --git a/bookwyrm/forms/groups.py b/bookwyrm/forms/groups.py new file mode 100644 index 000000000..15b27c0ae --- /dev/null +++ b/bookwyrm/forms/groups.py @@ -0,0 +1,16 @@ +""" using django model forms """ +from bookwyrm import models +from .custom_form import CustomForm + + +# pylint: disable=missing-class-docstring +class UserGroupForm(CustomForm): + class Meta: + model = models.User + fields = ["groups"] + + +class GroupForm(CustomForm): + class Meta: + model = models.Group + fields = ["user", "privacy", "name", "description"] diff --git a/bookwyrm/forms/landing.py b/bookwyrm/forms/landing.py new file mode 100644 index 000000000..b01c2cc98 --- /dev/null +++ b/bookwyrm/forms/landing.py @@ -0,0 +1,45 @@ +""" Forms for the landing pages """ +from django.forms import PasswordInput +from django.utils.translation import gettext_lazy as _ + +from bookwyrm import models +from .custom_form import CustomForm + + +# pylint: disable=missing-class-docstring +class LoginForm(CustomForm): + class Meta: + model = models.User + fields = ["localname", "password"] + help_texts = {f: None for f in fields} + widgets = { + "password": PasswordInput(), + } + + +class RegisterForm(CustomForm): + class Meta: + model = models.User + fields = ["localname", "email", "password"] + help_texts = {f: None for f in fields} + widgets = {"password": PasswordInput()} + + def clean(self): + """Check if the username is taken""" + cleaned_data = super().clean() + localname = cleaned_data.get("localname").strip() + if models.User.objects.filter(localname=localname).first(): + self.add_error("localname", _("User with this username already exists")) + + +class InviteRequestForm(CustomForm): + def clean(self): + """make sure the email isn't in use by a registered user""" + cleaned_data = super().clean() + email = cleaned_data.get("email") + if email and models.User.objects.filter(email=email).exists(): + self.add_error("email", _("A user with this email already exists.")) + + class Meta: + model = models.InviteRequest + fields = ["email", "answer"] diff --git a/bookwyrm/forms/links.py b/bookwyrm/forms/links.py new file mode 100644 index 000000000..de229bc2d --- /dev/null +++ b/bookwyrm/forms/links.py @@ -0,0 +1,48 @@ +""" using django model forms """ +from urllib.parse import urlparse + +from django.utils.translation import gettext_lazy as _ + +from bookwyrm import models +from .custom_form import CustomForm + + +# pylint: disable=missing-class-docstring +class LinkDomainForm(CustomForm): + class Meta: + model = models.LinkDomain + fields = ["name"] + + +class FileLinkForm(CustomForm): + class Meta: + model = models.FileLink + fields = ["url", "filetype", "availability", "book", "added_by"] + + def clean(self): + """make sure the domain isn't blocked or pending""" + cleaned_data = super().clean() + url = cleaned_data.get("url") + filetype = cleaned_data.get("filetype") + book = cleaned_data.get("book") + domain = urlparse(url).netloc + if models.LinkDomain.objects.filter(domain=domain).exists(): + status = models.LinkDomain.objects.get(domain=domain).status + if status == "blocked": + # pylint: disable=line-too-long + self.add_error( + "url", + _( + "This domain is blocked. Please contact your administrator if you think this is an error." + ), + ) + elif models.FileLink.objects.filter( + url=url, book=book, filetype=filetype + ).exists(): + # pylint: disable=line-too-long + self.add_error( + "url", + _( + "This link with file type has already been added for this book. If it is not visible, the domain is still pending." + ), + ) diff --git a/bookwyrm/forms/lists.py b/bookwyrm/forms/lists.py new file mode 100644 index 000000000..647db3bfe --- /dev/null +++ b/bookwyrm/forms/lists.py @@ -0,0 +1,37 @@ +""" using django model forms """ +from django import forms +from django.forms import ChoiceField +from django.utils.translation import gettext_lazy as _ + +from bookwyrm import models +from .custom_form import CustomForm + + +# pylint: disable=missing-class-docstring +class ListForm(CustomForm): + class Meta: + model = models.List + fields = ["user", "name", "description", "curation", "privacy", "group"] + + +class ListItemForm(CustomForm): + class Meta: + model = models.ListItem + fields = ["user", "book", "book_list", "notes"] + + +class SortListForm(forms.Form): + sort_by = ChoiceField( + choices=( + ("order", _("List Order")), + ("title", _("Book Title")), + ("rating", _("Rating")), + ), + label=_("Sort By"), + ) + direction = ChoiceField( + choices=( + ("ascending", _("Ascending")), + ("descending", _("Descending")), + ), + ) diff --git a/bookwyrm/forms/status.py b/bookwyrm/forms/status.py new file mode 100644 index 000000000..0800166bf --- /dev/null +++ b/bookwyrm/forms/status.py @@ -0,0 +1,82 @@ +""" using django model forms """ +from bookwyrm import models +from .custom_form import CustomForm + + +# pylint: disable=missing-class-docstring +class RatingForm(CustomForm): + class Meta: + model = models.ReviewRating + fields = ["user", "book", "rating", "privacy"] + + +class ReviewForm(CustomForm): + class Meta: + model = models.Review + fields = [ + "user", + "book", + "name", + "content", + "rating", + "content_warning", + "sensitive", + "privacy", + ] + + +class CommentForm(CustomForm): + class Meta: + model = models.Comment + fields = [ + "user", + "book", + "content", + "content_warning", + "sensitive", + "privacy", + "progress", + "progress_mode", + "reading_status", + ] + + +class QuotationForm(CustomForm): + class Meta: + model = models.Quotation + fields = [ + "user", + "book", + "quote", + "content", + "content_warning", + "sensitive", + "privacy", + "position", + "position_mode", + ] + + +class ReplyForm(CustomForm): + class Meta: + model = models.Status + fields = [ + "user", + "content", + "content_warning", + "sensitive", + "reply_parent", + "privacy", + ] + + +class StatusForm(CustomForm): + class Meta: + model = models.Status + fields = ["user", "content", "content_warning", "sensitive", "privacy"] + + +class DirectForm(CustomForm): + class Meta: + model = models.Status + fields = ["user", "content", "content_warning", "sensitive", "privacy"] diff --git a/bookwyrm/forms/widgets.py b/bookwyrm/forms/widgets.py new file mode 100644 index 000000000..ee9345aa0 --- /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 @@ -361,7 +378,7 @@
@@ -386,6 +403,6 @@ {% endblock %} {% block scripts %} - + {% endblock %} diff --git a/bookwyrm/templates/book/cover_add_modal.html b/bookwyrm/templates/book/cover_add_modal.html index e8207ff44..8ca5bf2a8 100644 --- a/bookwyrm/templates/book/cover_add_modal.html +++ b/bookwyrm/templates/book/cover_add_modal.html @@ -28,8 +28,10 @@ {% endblock %} {% block modal-footer %} - - +
+ + +
{% endblock %} {% block modal-form-close %}{% endblock %} diff --git a/bookwyrm/templates/book/edit/edit_book.html b/bookwyrm/templates/book/edit/edit_book.html index 3d41058e3..b088c1e87 100644 --- a/bookwyrm/templates/book/edit/edit_book.html +++ b/bookwyrm/templates/book/edit/edit_book.html @@ -3,18 +3,24 @@ {% load humanize %} {% load utilities %} -{% block title %}{% if book %}{% blocktrans with book_title=book.title %}Edit "{{ book_title }}"{% endblocktrans %}{% else %}{% trans "Add Book" %}{% endif %}{% endblock %} +{% block title %} + {% if book.title %} + {% blocktrans with book_title=book.title %}Edit "{{ book_title }}"{% endblocktrans %} + {% else %} + {% trans "Add Book" %} + {% endif %} +{% endblock %} {% block content %}

- {% if book %} + {% if book.title %} {% blocktrans with book_title=book.title %}Edit "{{ book_title }}"{% endblocktrans %} {% else %} {% trans "Add Book" %} {% endif %}

- {% if book %} + {% if book.created_date %}
{% trans "Added:" %}
{{ book.created_date | naturaltime }}
@@ -33,7 +39,7 @@
{{ match.parent_work.title }} {% endfor %} -
@@ -60,7 +63,7 @@ {% trans "Series number:" %} {{ form.series_number }} - + {% include 'snippets/form_errors.html' with errors_list=form.series_number.errors id="desc_series_number" %}
@@ -74,9 +77,60 @@ {% trans "Separate multiple values with commas." %} - + {% include 'snippets/form_errors.html' with errors_list=form.languages.errors id="desc_languages" %} + +
+ + {% for subject in book.subjects %} + +
+
+ +
+
+ +
+
+ {% endfor %} + + + {% include 'snippets/form_errors.html' with errors_list=form.subjects.errors id="desc_subjects" %} +
+ + + + @@ -93,7 +147,7 @@ {% trans "Separate multiple values with commas." %} - + {% include 'snippets/form_errors.html' with errors_list=form.publishers.errors id="desc_publishers" %} @@ -101,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" %} @@ -110,8 +163,8 @@ - - + {{ form.published_date }} + {% include 'snippets/form_errors.html' with errors_list=form.published_date.errors id="desc_published_date" %} @@ -123,6 +176,8 @@
{% if book.authors.exists %} + {# preserve authors if the book is unsaved #} +
{% for author in book.authors.all %}
@@ -149,7 +204,12 @@ {% endfor %}
- + + +
@@ -180,7 +240,7 @@ - + {% include 'snippets/form_errors.html' with errors_list=form.cover.errors id="desc_cover" %} @@ -198,10 +258,8 @@ -
- {{ form.physical_format }} -
- + {{ form.physical_format }} + {% include 'snippets/form_errors.html' with errors_list=form.physical_format.errors id="desc_physical_format" %} @@ -211,7 +269,7 @@ {% trans "Format details:" %} {{ form.physical_format_detail }} - + {% include 'snippets/form_errors.html' with errors_list=form.physical_format_detail.errors id="desc_physical_format_detail" %} @@ -222,7 +280,7 @@ {% trans "Pages:" %} {{ form.pages }} - + {% include 'snippets/form_errors.html' with errors_list=form.pages.errors id="desc_pages" %} @@ -238,7 +296,7 @@ {% trans "ISBN 13:" %} {{ form.isbn_13 }} - + {% include 'snippets/form_errors.html' with errors_list=form.isbn_13.errors id="desc_isbn_13" %} @@ -247,7 +305,7 @@ {% trans "ISBN 10:" %} {{ form.isbn_10 }} - + {% include 'snippets/form_errors.html' with errors_list=form.isbn_10.errors id="desc_isbn_10" %} @@ -256,7 +314,7 @@ {% trans "Openlibrary ID:" %} {{ form.openlibrary_key }} - + {% include 'snippets/form_errors.html' with errors_list=form.openlibrary_key.errors id="desc_openlibrary_key" %} @@ -265,7 +323,7 @@ {% trans "Inventaire ID:" %} {{ form.inventaire_id }} - + {% include 'snippets/form_errors.html' with errors_list=form.inventaire_id.errors id="desc_inventaire_id" %} @@ -274,7 +332,7 @@ {% trans "OCLC Number:" %} {{ form.oclc_number }} - + {% include 'snippets/form_errors.html' with errors_list=form.oclc_number.errors id="desc_oclc_number" %} @@ -283,10 +341,14 @@ {% trans "ASIN:" %} {{ form.asin }} - + {% include 'snippets/form_errors.html' with errors_list=form.ASIN.errors id="desc_ASIN" %} + +{% block scripts %} + +{% endblock %} diff --git a/bookwyrm/templates/book/editions/editions.html b/bookwyrm/templates/book/editions/editions.html index a3ff08022..e15e7a74d 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/add_link_modal.html b/bookwyrm/templates/book/file_links/add_link_modal.html index d5b3fcd0d..67b437bd7 100644 --- a/bookwyrm/templates/book/file_links/add_link_modal.html +++ b/bookwyrm/templates/book/file_links/add_link_modal.html @@ -55,8 +55,10 @@ {% endblock %} {% block modal-footer %} - - - +
+ + +
{% endblock %} + {% block modal-form-close %}{% endblock %} diff --git a/bookwyrm/templates/book/file_links/edit_links.html b/bookwyrm/templates/book/file_links/edit_links.html index 9048ce7a2..a088a40d5 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/book/file_links/verification_modal.html b/bookwyrm/templates/book/file_links/verification_modal.html index 81685da0f..01f17f965 100644 --- a/bookwyrm/templates/book/file_links/verification_modal.html +++ b/bookwyrm/templates/book/file_links/verification_modal.html @@ -17,13 +17,13 @@ Is that where you'd like to go? {% block modal-footer %} -
{% trans "Continue" %} - - {% if request.user.is_authenticated %} -
+ + + +{% trans "Continue" %} {% endif %} {% endblock %} diff --git a/bookwyrm/templates/book/sync_modal.html b/bookwyrm/templates/book/sync_modal.html index 6e5df0c0f..81ad8db92 100644 --- a/bookwyrm/templates/book/sync_modal.html +++ b/bookwyrm/templates/book/sync_modal.html @@ -19,8 +19,10 @@ {% endblock %} {% block modal-footer %} - - +
+ + +
{% endblock %} {% block modal-form-close %}{% endblock %} diff --git a/bookwyrm/templates/components/tooltip.html b/bookwyrm/templates/components/tooltip.html deleted file mode 100644 index 3176a6399..000000000 --- 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 8c8adcdd9..abdd3a734 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 000000000..221f07565 --- /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 7c0c10980..000000000 --- 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 000000000..beb9318a9 --- /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/directory/user_card.html b/bookwyrm/templates/directory/user_card.html index ccae925a1..5a17dbe42 100644 --- a/bookwyrm/templates/directory/user_card.html +++ b/bookwyrm/templates/directory/user_card.html @@ -33,7 +33,7 @@