Files
kakebo/app/public/views.py
Andros Fenollosa 7d6197cc17 Translate all UI text and seed data from Spanish to English
- Translate all templates: login, dashboard, expense success, categories
  CRUD, subcategory CRUD, month start page, nav bar, partials
- Translate seed categories: Survival, Leisure & vice, Culture, Extras
  with all subcategories in English
- Translate form placeholders and view titles
- Translate error messages (login, delete confirmations)
- Change LANGUAGE_CODE from "es" to "en-us"
- Change html lang from "es" to "en"
- Format all Python files with Ruff (tabs)
2026-03-12 08:20:59 +01:00

26 lines
714 B
Python

from django.shortcuts import render, redirect
from django.contrib.auth import authenticate, login, logout
from django.contrib import messages
def login_view(request):
if request.user.is_authenticated:
return redirect("expenses:dashboard")
if request.method == "POST":
username = request.POST.get("username")
password = request.POST.get("password")
user = authenticate(request, username=username, password=password)
if user is not None:
login(request, user)
return redirect("expenses:dashboard")
else:
messages.error(request, "Invalid username or password.")
return render(request, "pages/public/login.html")
def logout_view(request):
logout(request)
return redirect("public:login")