new test_dashboard FT (part 1) for username applet on dashboard; apps/dashboard/home.html gained new applet section to support additions; new urlpatterns in apps.dash.urls; tweaks to .views, including the @login_required decorator and set_profile() FBV; new ITs in .tests.integrated.test_views
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from django.contrib import messages
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.http import HttpResponseForbidden
|
||||
from django.shortcuts import redirect, render
|
||||
|
||||
@@ -51,7 +52,7 @@ def view_list(request, list_id):
|
||||
form.save()
|
||||
return redirect(our_list)
|
||||
return render(request, "apps/dashboard/list.html", {"list": our_list, "form": form})
|
||||
|
||||
|
||||
def my_lists(request, user_id):
|
||||
owner = User.objects.get(id=user_id)
|
||||
if not request.user.is_authenticated:
|
||||
@@ -72,12 +73,19 @@ def share_list(request, list_id):
|
||||
messages.success(request, "An invite has been sent if that address is registered.")
|
||||
return redirect(our_list)
|
||||
|
||||
@login_required(login_url="/")
|
||||
def set_theme(request):
|
||||
if not request.user.is_authenticated:
|
||||
return redirect("home")
|
||||
if request.method == "POST":
|
||||
theme = request.POST.get("theme", "")
|
||||
if theme in UNLOCKED_THEMES:
|
||||
request.user.theme = theme
|
||||
request.user.save(update_fields=["theme"])
|
||||
return redirect("home")
|
||||
|
||||
@login_required(login_url="/")
|
||||
def set_profile(request):
|
||||
if request.method == "POST":
|
||||
username = request.POST.get("username", "")
|
||||
request.user.username = username
|
||||
request.user.save(update_fields=["username"])
|
||||
return redirect("/")
|
||||
|
||||
Reference in New Issue
Block a user