phase2: add modular apps, auth scaffolding, and base template routing
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CompetitionsConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.competitions"
|
||||
@@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import CompetitionsHomeView
|
||||
|
||||
app_name = "competitions"
|
||||
|
||||
urlpatterns = [
|
||||
path("", CompetitionsHomeView.as_view(), name="index"),
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class CompetitionsHomeView(TemplateView):
|
||||
template_name = "competitions/index.html"
|
||||
+5
-2
@@ -1,8 +1,11 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import health, home
|
||||
from .views import DashboardView, HomeView, health
|
||||
|
||||
app_name = "core"
|
||||
|
||||
urlpatterns = [
|
||||
path("", home, name="home"),
|
||||
path("", HomeView.as_view(), name="home"),
|
||||
path("dashboard/", DashboardView.as_view(), name="dashboard"),
|
||||
path("health/", health, name="health"),
|
||||
]
|
||||
|
||||
+8
-3
@@ -1,9 +1,14 @@
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.views.generic import TemplateView
|
||||
from django.http import JsonResponse
|
||||
from django.shortcuts import render
|
||||
|
||||
|
||||
def home(request):
|
||||
return render(request, "home.html")
|
||||
class HomeView(TemplateView):
|
||||
template_name = "core/home.html"
|
||||
|
||||
|
||||
class DashboardView(LoginRequiredMixin, TemplateView):
|
||||
template_name = "core/dashboard.html"
|
||||
|
||||
|
||||
def health(request):
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class IngestionConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.ingestion"
|
||||
@@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import IngestionHomeView
|
||||
|
||||
app_name = "ingestion"
|
||||
|
||||
urlpatterns = [
|
||||
path("", IngestionHomeView.as_view(), name="index"),
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class IngestionHomeView(TemplateView):
|
||||
template_name = "ingestion/index.html"
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PlayersConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.players"
|
||||
@@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import PlayersHomeView
|
||||
|
||||
app_name = "players"
|
||||
|
||||
urlpatterns = [
|
||||
path("", PlayersHomeView.as_view(), name="index"),
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class PlayersHomeView(TemplateView):
|
||||
template_name = "players/index.html"
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ProvidersConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.providers"
|
||||
@@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import ProvidersHomeView
|
||||
|
||||
app_name = "providers"
|
||||
|
||||
urlpatterns = [
|
||||
path("", ProvidersHomeView.as_view(), name="index"),
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class ProvidersHomeView(TemplateView):
|
||||
template_name = "providers/index.html"
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ScoutingConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.scouting"
|
||||
@@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import ScoutingHomeView
|
||||
|
||||
app_name = "scouting"
|
||||
|
||||
urlpatterns = [
|
||||
path("", ScoutingHomeView.as_view(), name="index"),
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class ScoutingHomeView(TemplateView):
|
||||
template_name = "scouting/index.html"
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class StatsConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.stats"
|
||||
@@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import StatsHomeView
|
||||
|
||||
app_name = "stats"
|
||||
|
||||
urlpatterns = [
|
||||
path("", StatsHomeView.as_view(), name="index"),
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class StatsHomeView(TemplateView):
|
||||
template_name = "stats/index.html"
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class TeamsConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.teams"
|
||||
@@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import TeamsHomeView
|
||||
|
||||
app_name = "teams"
|
||||
|
||||
urlpatterns = [
|
||||
path("", TeamsHomeView.as_view(), name="index"),
|
||||
]
|
||||
@@ -0,0 +1,5 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class TeamsHomeView(TemplateView):
|
||||
template_name = "teams/index.html"
|
||||
@@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class UsersConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.users"
|
||||
@@ -0,0 +1,18 @@
|
||||
from django import forms
|
||||
from django.contrib.auth.forms import UserCreationForm
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
class SignupForm(UserCreationForm):
|
||||
email = forms.EmailField(required=True)
|
||||
|
||||
class Meta:
|
||||
model = User
|
||||
fields = ("username", "email", "password1", "password2")
|
||||
|
||||
def save(self, commit=True):
|
||||
user = super().save(commit=False)
|
||||
user.email = self.cleaned_data["email"]
|
||||
if commit:
|
||||
user.save()
|
||||
return user
|
||||
@@ -0,0 +1,12 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import ProfileView, SignupView, UserLoginView, UserLogoutView
|
||||
|
||||
app_name = "users"
|
||||
|
||||
urlpatterns = [
|
||||
path("signup/", SignupView.as_view(), name="signup"),
|
||||
path("login/", UserLoginView.as_view(), name="login"),
|
||||
path("logout/", UserLogoutView.as_view(), name="logout"),
|
||||
path("profile/", ProfileView.as_view(), name="profile"),
|
||||
]
|
||||
@@ -0,0 +1,31 @@
|
||||
from django.contrib.auth import login
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.auth.views import LoginView, LogoutView
|
||||
from django.urls import reverse_lazy
|
||||
from django.views.generic import CreateView, TemplateView
|
||||
|
||||
from .forms import SignupForm
|
||||
|
||||
|
||||
class SignupView(CreateView):
|
||||
form_class = SignupForm
|
||||
template_name = "users/signup.html"
|
||||
success_url = reverse_lazy("core:dashboard")
|
||||
|
||||
def form_valid(self, form):
|
||||
response = super().form_valid(form)
|
||||
login(self.request, self.object)
|
||||
return response
|
||||
|
||||
|
||||
class UserLoginView(LoginView):
|
||||
template_name = "users/login.html"
|
||||
redirect_authenticated_user = True
|
||||
|
||||
|
||||
class UserLogoutView(LogoutView):
|
||||
next_page = reverse_lazy("core:home")
|
||||
|
||||
|
||||
class ProfileView(LoginRequiredMixin, TemplateView):
|
||||
template_name = "users/profile.html"
|
||||
Reference in New Issue
Block a user