phase2: add modular apps, auth scaffolding, and base template routing
This commit is contained in:
0
apps/competitions/__init__.py
Normal file
0
apps/competitions/__init__.py
Normal file
6
apps/competitions/apps.py
Normal file
6
apps/competitions/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class CompetitionsConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.competitions"
|
||||
0
apps/competitions/migrations/__init__.py
Normal file
0
apps/competitions/migrations/__init__.py
Normal file
9
apps/competitions/urls.py
Normal file
9
apps/competitions/urls.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import CompetitionsHomeView
|
||||
|
||||
app_name = "competitions"
|
||||
|
||||
urlpatterns = [
|
||||
path("", CompetitionsHomeView.as_view(), name="index"),
|
||||
]
|
||||
5
apps/competitions/views.py
Normal file
5
apps/competitions/views.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class CompetitionsHomeView(TemplateView):
|
||||
template_name = "competitions/index.html"
|
||||
@ -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"),
|
||||
]
|
||||
|
||||
@ -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
apps/ingestion/__init__.py
Normal file
0
apps/ingestion/__init__.py
Normal file
6
apps/ingestion/apps.py
Normal file
6
apps/ingestion/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class IngestionConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.ingestion"
|
||||
0
apps/ingestion/migrations/__init__.py
Normal file
0
apps/ingestion/migrations/__init__.py
Normal file
9
apps/ingestion/urls.py
Normal file
9
apps/ingestion/urls.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import IngestionHomeView
|
||||
|
||||
app_name = "ingestion"
|
||||
|
||||
urlpatterns = [
|
||||
path("", IngestionHomeView.as_view(), name="index"),
|
||||
]
|
||||
5
apps/ingestion/views.py
Normal file
5
apps/ingestion/views.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class IngestionHomeView(TemplateView):
|
||||
template_name = "ingestion/index.html"
|
||||
0
apps/players/__init__.py
Normal file
0
apps/players/__init__.py
Normal file
6
apps/players/apps.py
Normal file
6
apps/players/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class PlayersConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.players"
|
||||
0
apps/players/migrations/__init__.py
Normal file
0
apps/players/migrations/__init__.py
Normal file
9
apps/players/urls.py
Normal file
9
apps/players/urls.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import PlayersHomeView
|
||||
|
||||
app_name = "players"
|
||||
|
||||
urlpatterns = [
|
||||
path("", PlayersHomeView.as_view(), name="index"),
|
||||
]
|
||||
5
apps/players/views.py
Normal file
5
apps/players/views.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class PlayersHomeView(TemplateView):
|
||||
template_name = "players/index.html"
|
||||
0
apps/providers/__init__.py
Normal file
0
apps/providers/__init__.py
Normal file
6
apps/providers/apps.py
Normal file
6
apps/providers/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ProvidersConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.providers"
|
||||
0
apps/providers/migrations/__init__.py
Normal file
0
apps/providers/migrations/__init__.py
Normal file
9
apps/providers/urls.py
Normal file
9
apps/providers/urls.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import ProvidersHomeView
|
||||
|
||||
app_name = "providers"
|
||||
|
||||
urlpatterns = [
|
||||
path("", ProvidersHomeView.as_view(), name="index"),
|
||||
]
|
||||
5
apps/providers/views.py
Normal file
5
apps/providers/views.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class ProvidersHomeView(TemplateView):
|
||||
template_name = "providers/index.html"
|
||||
0
apps/scouting/__init__.py
Normal file
0
apps/scouting/__init__.py
Normal file
6
apps/scouting/apps.py
Normal file
6
apps/scouting/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class ScoutingConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.scouting"
|
||||
0
apps/scouting/migrations/__init__.py
Normal file
0
apps/scouting/migrations/__init__.py
Normal file
9
apps/scouting/urls.py
Normal file
9
apps/scouting/urls.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import ScoutingHomeView
|
||||
|
||||
app_name = "scouting"
|
||||
|
||||
urlpatterns = [
|
||||
path("", ScoutingHomeView.as_view(), name="index"),
|
||||
]
|
||||
5
apps/scouting/views.py
Normal file
5
apps/scouting/views.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class ScoutingHomeView(TemplateView):
|
||||
template_name = "scouting/index.html"
|
||||
0
apps/stats/__init__.py
Normal file
0
apps/stats/__init__.py
Normal file
6
apps/stats/apps.py
Normal file
6
apps/stats/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class StatsConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.stats"
|
||||
0
apps/stats/migrations/__init__.py
Normal file
0
apps/stats/migrations/__init__.py
Normal file
9
apps/stats/urls.py
Normal file
9
apps/stats/urls.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import StatsHomeView
|
||||
|
||||
app_name = "stats"
|
||||
|
||||
urlpatterns = [
|
||||
path("", StatsHomeView.as_view(), name="index"),
|
||||
]
|
||||
5
apps/stats/views.py
Normal file
5
apps/stats/views.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class StatsHomeView(TemplateView):
|
||||
template_name = "stats/index.html"
|
||||
0
apps/teams/__init__.py
Normal file
0
apps/teams/__init__.py
Normal file
6
apps/teams/apps.py
Normal file
6
apps/teams/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class TeamsConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.teams"
|
||||
0
apps/teams/migrations/__init__.py
Normal file
0
apps/teams/migrations/__init__.py
Normal file
9
apps/teams/urls.py
Normal file
9
apps/teams/urls.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
|
||||
from .views import TeamsHomeView
|
||||
|
||||
app_name = "teams"
|
||||
|
||||
urlpatterns = [
|
||||
path("", TeamsHomeView.as_view(), name="index"),
|
||||
]
|
||||
5
apps/teams/views.py
Normal file
5
apps/teams/views.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
|
||||
class TeamsHomeView(TemplateView):
|
||||
template_name = "teams/index.html"
|
||||
0
apps/users/__init__.py
Normal file
0
apps/users/__init__.py
Normal file
6
apps/users/apps.py
Normal file
6
apps/users/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class UsersConfig(AppConfig):
|
||||
default_auto_field = "django.db.models.BigAutoField"
|
||||
name = "apps.users"
|
||||
18
apps/users/forms.py
Normal file
18
apps/users/forms.py
Normal file
@ -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
apps/users/migrations/__init__.py
Normal file
0
apps/users/migrations/__init__.py
Normal file
12
apps/users/urls.py
Normal file
12
apps/users/urls.py
Normal file
@ -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"),
|
||||
]
|
||||
31
apps/users/views.py
Normal file
31
apps/users/views.py
Normal file
@ -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