Skip to content

Commit

Permalink
Resolve merge issues
Browse files Browse the repository at this point in the history
Fix accidental removal of the (unused) NewsletterView
Remove duplicate LoginView
  • Loading branch information
EricTRL committed Nov 2, 2024
1 parent 0119101 commit bc38dae
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/tests/tests_frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def test_form_incorrect(self):
# Ensure that only one (general) error was given
self.assertEqual(len(form.errors.as_data()), 1)
self.assertEqual(len(form.non_field_errors().as_data()), 1)
self.assertEqual(form.non_field_errors().as_data()[0].code, "ERROR_INVALID_LOGIN")
self.assertEqual(form.non_field_errors().as_data()[0].code, "invalid_login")

def test_form_username_missing(self):
"""Test if a login is disallowed if the username is missing"""
Expand Down
1 change: 1 addition & 0 deletions core/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
name='user_accounts/password_reset/success'),
path('register', views.RegisterUserView.as_view(), name='user_accounts/register'),
path('register/success', views.RegisterSuccessView.as_view(), name='user_accounts/register/success'),
path('newsletters/', views.NewsletterView.as_view(), name='newsletters'),
path('status/', registry.get_urls()),
# Mock 403 and 404 views for display testing in development
path('mock/', include([
Expand Down
14 changes: 6 additions & 8 deletions core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from django.http import HttpResponse, HttpResponseRedirect, JsonResponse, HttpRequest
from django.http.response import Http404
from django.shortcuts import render
from django.urls import reverse, reverse_lazy
from django.urls import reverse_lazy
from django.utils.translation import gettext_lazy as _
from django.shortcuts import get_object_or_404
from django.views import View
Expand All @@ -21,6 +21,7 @@

from core.forms import LoginForm, RegisterForm
from core.models import MarkdownImage, Shortcut
from membership_file.util import MembershipRequiredMixin

global_preferences = global_preferences_registry.manager()
User = get_user_model()
Expand Down Expand Up @@ -135,14 +136,11 @@ def setup(self, request: HttpRequest, *args, **kwargs) -> None:
raise Http404()


class LoginView(DjangoLoginView):
"""View for users logging in."""
class NewsletterView(GlobalPreferenceRequiredMixin, MembershipRequiredMixin, TemplateView):
"""Page for viewing newsletters"""

template_name = "core/user_accounts/login.html"
authentication_form = LoginForm
redirect_authenticated_user = False
# Setting to True will enable Social Media Fingerprinting.
# See: https://docs.djangoproject.com/en/3.2/topics/auth/default/#all-authentication-views
global_preference = "newsletter__share_link"
template_name = "core/newsletters.html"


class RegisterSuccessView(TemplateView):
Expand Down

0 comments on commit bc38dae

Please sign in to comment.