kumify/frontend/views.py
Kumi 725f566d97
feat: Enhances asset management for dashboard sections
Introduces methods to manage styles and scripts in dashboard
sections, promoting modularity and reusability.

Updates templates to dynamically render styles and scripts
directly from context, ensuring better integration with
existing features system.

Migrates related static assets to 'mood' section to streamline
the module structure.

These changes enable smoother customization and extendability
of the dashboard's look and feel.

Relates to improved frontend architecture.
2024-11-20 07:41:50 +01:00

35 lines
1.2 KiB
Python

from django.views.generic import TemplateView, CreateView
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.auth.forms import UserCreationForm
from django.contrib.auth import get_user_model, login
from django.urls import reverse_lazy
from .templatetags.dashboard import dashboard_styles, dashboard_scripts
class DashboardView(LoginRequiredMixin, TemplateView):
template_name = "frontend/dashboard.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["title"] = "Dashboard"
context["subtitle"] = (
"An overview of everything going on in your Kumify account."
)
context["scripts"] = dashboard_scripts()
context["styles"] = dashboard_styles()
return context
class UserRegistrationView(CreateView):
form_class = UserCreationForm
model = get_user_model()
template_name = "registration/registration_form.html"
def form_valid(self, form):
ret = super().form_valid(form)
login(self.request, self.object)
return ret
def get_success_url(self):
return reverse_lazy("frontend:dashboard")