diff --git a/src/config/settings.py b/src/config/settings.py index 8ec6666d..c8f5dc3e 100644 --- a/src/config/settings.py +++ b/src/config/settings.py @@ -9,7 +9,7 @@ from django.utils.translation import gettext_lazy as _ from sentry_sdk.integrations.django import DjangoIntegration -from .storage_settings import * # noqa F403 F401 +from .storage_settings import * # noqa F403 F401 ROOT_DIR = environ.Path("/jandig/") BASE_DIR = "/jandig/src" @@ -196,10 +196,10 @@ def debug(request): DEFAULT_FROM_EMAIL = env("SMTP_SENDER_MAIL", default="jandig@memelab.com.br") -EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' +EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend" EMAIL_HOST = env("SMTP_SERVER", default="mailpit") EMAIL_USE_TLS = env("SMTP_USE_TLS", default=False) -EMAIL_PORT = env("SMTP_PORT", default=1025) +EMAIL_PORT = env("SMTP_PORT", default=1025) EMAIL_HOST_USER = env("SMTP_USER", default="jandig@jandig.com") EMAIL_HOST_PASSWORD = env("SMTP_PASSWORD", default="password") EMAIL_USE_SSL = False diff --git a/src/core/urls.py b/src/core/urls.py index 10353b61..766a916e 100644 --- a/src/core/urls.py +++ b/src/core/urls.py @@ -1,12 +1,11 @@ from django.conf import settings -from django.urls import include, path +from django.urls import include, path, re_path from rest_framework_nested.routers import DefaultRouter from core.views.artworks import ArtworkViewset from core.views.exhibits import ExhibitViewset from core.views.markers import MarkerViewset from core.views.objects import ObjectViewset -from django.urls import re_path from core.views.static_views import ( community, documentation, @@ -48,7 +47,11 @@ path("manifest.json", manifest, name="manifest"), path("upload", upload_image, name="upload-image"), path("i18n/", include("django.conf.urls.i18n")), - re_path(r"^see_all(?:/(?P[a-zA-Z]+))?(?:/(?P\d+))?/$", see_all, name="see_all"), + re_path( + r"^see_all(?:/(?P[a-zA-Z]+))?(?:/(?P\d+))?/$", + see_all, + name="see_all", + ), path("robots.txt", robots_txt), path("favicon.ico", favicon), path(settings.HEALTH_CHECK_URL, health_check), diff --git a/src/core/views/views.py b/src/core/views/views.py index 54c0f2e0..22e33593 100644 --- a/src/core/views/views.py +++ b/src/core/views/views.py @@ -77,7 +77,7 @@ def see_all(request, which="", page=1): if data: paginator = Paginator(data, per_page) if page > paginator.num_pages: - return redirect("see_all", request_type,paginator.num_pages) + return redirect("see_all", request_type, paginator.num_pages) paginated_data = paginator.get_page(page) paginated_data.adjusted_elided_pages = paginator.get_elided_page_range(page) ctx = { diff --git a/src/users/services/__init__.py b/src/users/services/__init__.py index f79e22ec..744f9d1c 100644 --- a/src/users/services/__init__.py +++ b/src/users/services/__init__.py @@ -1 +1 @@ -from .recaptcha_service import * \ No newline at end of file +from .recaptcha_service import * # noqa diff --git a/src/users/urls.py b/src/users/urls.py index b5ae643b..4315f6bc 100644 --- a/src/users/urls.py +++ b/src/users/urls.py @@ -3,6 +3,7 @@ from .forms import LoginForm from .views import ( + ResetPasswordView, create_artwork, create_exhibit, delete, @@ -14,20 +15,14 @@ edit_password, edit_profile, element_get, - invalid_recovering_email_or_username, marker_upload, mod, mod_delete, object_upload, permission_denied, profile, - recover_code, - recover_edit_password, - recover_password, related_content, signup, - wrong_verification_code, - ResetPasswordView, ) urlpatterns = [ @@ -41,26 +36,21 @@ name="login", ), path("logout/", auth_views.LogoutView.as_view(), name="logout"), - path('reset-password/', ResetPasswordView.as_view(), name='reset-password'), - path('password-reset-confirm///', - auth_views.PasswordResetConfirmView.as_view(template_name='users/reset-password/password_reset_confirm.jinja2'), - name='password_reset_confirm'), - path('password-reset-complete/', - auth_views.PasswordResetCompleteView.as_view(template_name='users/reset-password/password_reset_complete.jinja2'), - name='password_reset_complete'), - # path("recover/", recover_password, name="recover"), - # path("recover-code/", recover_code, name="recover-code"), - # path( - # "wrong-verification-code", - # wrong_verification_code, - # name="wrong-verification-code", - # ), - # path( - # "invalid-recovering-email", - # invalid_recovering_email_or_username, - # name="invalid_recovering_email_or_username", - # ), - # path("recover-edit-password", recover_edit_password, name="recover-edit-password"), + path("reset-password/", ResetPasswordView.as_view(), name="reset-password"), + path( + "password-reset-confirm///", + auth_views.PasswordResetConfirmView.as_view( + template_name="users/reset-password/password_reset_confirm.jinja2" + ), + name="password_reset_confirm", + ), + path( + "password-reset-complete/", + auth_views.PasswordResetCompleteView.as_view( + template_name="users/reset-password/password_reset_complete.jinja2" + ), + name="password_reset_complete", + ), path("profile/", profile, name="profile"), path("profile/edit/", edit_profile, name="edit-profile"), path("profile/edit-password/", edit_password, name="edit-password"), diff --git a/src/users/views.py b/src/users/views.py index fae3ee20..3b7609fb 100644 --- a/src/users/views.py +++ b/src/users/views.py @@ -8,12 +8,13 @@ login, update_session_auth_hash, ) - -from django.utils.translation import gettext_lazy as _ from django.contrib.auth.decorators import login_required -from django.contrib.auth.forms import SetPasswordForm +from django.contrib.auth.views import PasswordResetView +from django.contrib.messages.views import SuccessMessageMixin from django.http import Http404, JsonResponse from django.shortcuts import get_object_or_404, redirect, render +from django.urls import reverse_lazy +from django.utils.translation import gettext_lazy as _ from django.views.decorators.cache import cache_page from django.views.decorators.http import require_http_methods @@ -29,10 +30,7 @@ UploadObjectForm, ) from .models import Profile -from .services import (BOT_SCORE, create_assessment) -from django.urls import reverse_lazy -from django.contrib.auth.views import PasswordResetView -from django.contrib.messages.views import SuccessMessageMixin +from .services import BOT_SCORE, create_assessment log = logging.getLogger(__file__) @@ -75,14 +73,16 @@ def signup(request): class ResetPasswordView(SuccessMessageMixin, PasswordResetView): - template_name = 'users/reset-password/password_reset.jinja2' - email_template_name = 'users/reset-password/password_reset_email.html' - subject_template_name = 'users/reset-password/password_reset_subject.txt' - success_message = _("We've emailed you instructions for setting your password, " \ - "if an account exists with the email you entered. You should receive them shortly." \ - " If you don't receive an email, " \ - "please make sure you've entered the address you registered with, and check your spam folder.") - success_url = reverse_lazy('home') + template_name = "users/reset-password/password_reset.jinja2" + email_template_name = "users/reset-password/password_reset_email.html" + subject_template_name = "users/reset-password/password_reset_subject.txt" + success_message = _( + "We've emailed you instructions for setting your password, " + "if an account exists with the email you entered. You should receive them shortly." + " If you don't receive an email, " + "please make sure you've entered the address you registered with, and check your spam folder." + ) + success_url = reverse_lazy("home") @login_required