From fbb4bbc437de5e5ce045220a86075e54b1352b34 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 4 Jul 2023 17:21:17 -0400 Subject: [PATCH] set username and login via email --- boofilsic/settings.py | 3 + boofilsic/urls.py | 11 +- catalog/management/commands/catalog.py | 2 +- catalog/templates/_item_comments.html | 2 +- .../templates/_item_comments_by_episode.html | 2 +- catalog/templates/_item_reviews.html | 2 +- catalog/templates/_item_user_pieces.html | 4 +- catalog/templates/item_mark_list.html | 2 +- catalog/templates/item_review_list.html | 2 +- common/templates/_header.html | 7 +- common/templates/_sidebar_anonymous.html | 4 +- common/templates/common/info.html | 29 +++ doc/configuration.md | 4 +- journal/forms.py | 4 +- journal/templates/_list_item.html | 4 +- journal/templates/collection.html | 2 +- journal/templates/comment.html | 2 +- journal/templates/mark.html | 4 +- journal/templates/review.html | 2 +- journal/templates/user_collection_list.html | 2 +- journal/tests.py | 16 +- journal/views.py | 4 +- mastodon/admin.py | 2 +- mastodon/api.py | 6 +- mastodon/decorators.py | 2 +- requirements.txt | 1 + .../activity/comment_child_item.html | 2 +- .../activity/comment_focus_item.html | 2 +- social/templates/activity/mark_item.html | 2 +- social/templates/activity/review_item.html | 2 +- users/account.py | 233 ++++++++++++++++-- users/data.py | 12 + users/migrations/0007_user_pending_email.py | 22 ++ .../0008_user_at_least_one_login_method.py | 24 ++ users/models.py | 33 ++- users/templates/users/account.html | 129 ++++++++++ users/templates/users/data.html | 55 +---- users/templates/users/login.html | 88 +++++-- users/templates/users/preferences.html | 207 ++++++++-------- users/templates/users/register.html | 79 ++++-- users/templates/users/verify_email.html | 30 +++ users/urls.py | 28 ++- 42 files changed, 786 insertions(+), 287 deletions(-) create mode 100644 common/templates/common/info.html create mode 100644 users/migrations/0007_user_pending_email.py create mode 100644 users/migrations/0008_user_at_least_one_login_method.py create mode 100644 users/templates/users/account.html create mode 100644 users/templates/users/verify_email.html diff --git a/boofilsic/settings.py b/boofilsic/settings.py index 995b8ecc..71429381 100644 --- a/boofilsic/settings.py +++ b/boofilsic/settings.py @@ -273,6 +273,9 @@ EXPORT_FILE_PATH_ROOT = "export/" # Allow user to login via any Mastodon/Pleroma sites MASTODON_ALLOW_ANY_SITE = False +# Allow user to create account with email (and link to Mastodon account later) +ALLOW_EMAIL_ONLY_ACCOUNT = False + # Timeout of requests to Mastodon, in seconds MASTODON_TIMEOUT = 30 diff --git a/boofilsic/urls.py b/boofilsic/urls.py index ff6f9e93..e666a94d 100644 --- a/boofilsic/urls.py +++ b/boofilsic/urls.py @@ -18,12 +18,21 @@ from django.urls import path, include from django.conf import settings from users.views import login from common.api import api +from django.views.generic import RedirectView urlpatterns = [ path("api/", api.urls), # type: ignore path("login/", login), path("markdownx/", include("markdownx.urls")), - path("users/", include("users.urls")), + path("account/", include("users.urls")), + path( + "users/connect/", + RedirectView.as_view(url="/account/connect", query_string=True), + ), + path( + "users/OAuth2_login/", + RedirectView.as_view(url="/account/login/oauth", query_string=True), + ), path("", include("catalog.urls")), path("", include("journal.urls")), path("timeline/", include("social.urls")), diff --git a/catalog/management/commands/catalog.py b/catalog/management/commands/catalog.py index 0171614b..663fd756 100644 --- a/catalog/management/commands/catalog.py +++ b/catalog/management/commands/catalog.py @@ -109,7 +109,7 @@ class Command(BaseCommand): else: self.stdout.write(f"! no season {i} : {i.absolute_url}?skipcheck=1") if self.fix: - i.recast_to(TVShow) + i.recast_to(i.merged_to_item.__class__) self.stdout.write(f"Checking TVSeason is child of other class...") for i in TVSeason.objects.filter(show__isnull=False).exclude( diff --git a/catalog/templates/_item_comments.html b/catalog/templates/_item_comments.html index c9607f14..ca8503f7 100644 --- a/catalog/templates/_item_comments.html +++ b/catalog/templates/_item_comments.html @@ -40,7 +40,7 @@ + {% if comment.metadata.shared_link %} href="{{ comment.metadata.shared_link }}" title="打开联邦宇宙分享链接" {% else %} class="disabled" {% endif %}> diff --git a/catalog/templates/_item_comments_by_episode.html b/catalog/templates/_item_comments_by_episode.html index e88b426e..47bfd7c8 100644 --- a/catalog/templates/_item_comments_by_episode.html +++ b/catalog/templates/_item_comments_by_episode.html @@ -58,7 +58,7 @@ + {% if comment.metadata.shared_link %} href="{{ comment.metadata.shared_link }}" title="打开联邦宇宙分享链接" {% else %} class="disabled" {% endif %}> diff --git a/catalog/templates/_item_reviews.html b/catalog/templates/_item_reviews.html index 018388df..c18590ce 100644 --- a/catalog/templates/_item_reviews.html +++ b/catalog/templates/_item_reviews.html @@ -18,7 +18,7 @@ + {% if review.metadata.shared_link %} href="{{ review.metadata.shared_link }}" title="打开联邦宇宙分享链接" {% else %} class="disabled" {% endif %}> diff --git a/catalog/templates/_item_user_pieces.html b/catalog/templates/_item_user_pieces.html index 8ad9570f..2f6e030f 100644 --- a/catalog/templates/_item_user_pieces.html +++ b/catalog/templates/_item_user_pieces.html @@ -60,7 +60,7 @@ + {% if mark.comment.metadata.shared_link %} href="{{ mark.comment.metadata.shared_link }}" title="打开联邦宇宙分享链接" {% else %} class="disabled" {% endif %}> {% comment %} {{ mark.comment.created_time|date }} {% endcomment %} @@ -83,7 +83,7 @@ + {% if comment.metadata.shared_link %} href="{{ comment.metadata.shared_link }}" title="打开联邦宇宙分享链接" {% else %} class="disabled" {% endif %}> {% comment %} {{ comment.created_time|date }} {% endcomment %} diff --git a/catalog/templates/item_mark_list.html b/catalog/templates/item_mark_list.html index ab073d50..edeea024 100644 --- a/catalog/templates/item_mark_list.html +++ b/catalog/templates/item_mark_list.html @@ -43,7 +43,7 @@ + {% if mark.metadata.shared_link %} href="{{ mark.metadata.shared_link }}" title="打开联邦宇宙分享链接" {% else %} class="disabled" {% endif %}> {{ mark.created_time|date }} diff --git a/catalog/templates/item_review_list.html b/catalog/templates/item_review_list.html index c8d44bd2..aa4d3c2b 100644 --- a/catalog/templates/item_review_list.html +++ b/catalog/templates/item_review_list.html @@ -31,7 +31,7 @@ + {% if review.metadata.shared_link %} href="{{ review.metadata.shared_link }}" title="打开联邦宇宙分享链接" {% else %} class="disabled" {% endif %}> {% liked_piece review as liked %} diff --git a/common/templates/_header.html b/common/templates/_header.html index c8fad133..c9eae5aa 100644 --- a/common/templates/_header.html +++ b/common/templates/_header.html @@ -65,10 +65,13 @@