Skip to content

Commit a04cd4f

Browse files
committed
feat: have V3AuthContextMixin extends V3Mixin
1 parent e8f9f18 commit a04cd4f

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

users/views.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from django.contrib.auth.mixins import LoginRequiredMixin
66
from django.contrib import auth
77
from django.contrib.messages.views import SuccessMessageMixin
8-
from django.http import HttpResponseRedirect
8+
from django.http import HttpResponseNotFound, HttpResponseRedirect
99
from django.urls import reverse_lazy
1010
from django.views.generic import DetailView, FormView
1111
from django.views.generic.base import TemplateView
@@ -21,7 +21,9 @@
2121
from rest_framework import generics
2222
from rest_framework import viewsets
2323
from rest_framework.permissions import IsAuthenticated, AllowAny
24+
from waffle import flag_is_active
2425

26+
from core.mixins import V3Mixin
2527
from libraries.models import CommitAuthorEmail
2628
from .forms import (
2729
PreferencesForm,
@@ -297,12 +299,17 @@ def get_context_data(self, **kwargs):
297299
return context
298300

299301

300-
class V3AuthContextMixin:
302+
class V3AuthContextMixin(V3Mixin):
301303
"""Shared context for all V3 auth pages (signup, login, password reset, etc.)."""
302304

303-
def get_context_data(self, **kwargs):
304-
context = super().get_context_data(**kwargs)
305-
context["page_title"] = "Account"
305+
def dispatch(self, request, *args, **kwargs):
306+
if not flag_is_active(request, "v3"):
307+
return HttpResponseNotFound()
308+
return super().dispatch(request, *args, **kwargs)
309+
310+
def get_v3_context_data(self, **kwargs):
311+
context = super().get_v3_context_data(**kwargs)
312+
context["page_title"] = getattr(self, "page_title", "Account")
306313
context["foreground_image_url"] = (
307314
f"{settings.STATIC_URL}img/v3/auth-page/auth-page-foreground.png"
308315
)
@@ -318,17 +325,17 @@ def get_context_data(self, **kwargs):
318325

319326

320327
class V3SignupView(V3AuthContextMixin, TemplateView):
321-
template_name = "v3/accounts/signup.html"
328+
v3_template_name = "v3/accounts/signup.html"
322329
page_title = "Create An Account"
323330

324-
def get_context_data(self, **kwargs):
325-
context = super().get_context_data(**kwargs)
331+
def get_v3_context_data(self, **kwargs):
332+
context = super().get_v3_context_data(**kwargs)
326333
context["password_rules"] = build_password_rules()
327334
return context
328335

329336

330337
class V3LoginView(V3AuthContextMixin, TemplateView):
331-
template_name = "v3/accounts/login.html"
338+
v3_template_name = "v3/accounts/login.html"
332339
page_title = "Login"
333340

334341

0 commit comments

Comments
 (0)