new _applets partial to govern applet list; home.html updated accordingly to incl partial; fixed seed migrations for palette convention from last commit; new text_view ITs & views to govern applet visibility/toggling
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:
@@ -16,12 +16,18 @@ PALETTES = [
|
||||
]
|
||||
|
||||
|
||||
def _applet_context(user):
|
||||
ua_map = {ua.applet_id: ua.visible for ua in user.user_applets.all()}
|
||||
return [
|
||||
{"applet": applet, "visible": ua_map.get(applet.pk, applet.default_visible)}
|
||||
for applet in Applet.objects.all()
|
||||
]
|
||||
|
||||
def home_page(request):
|
||||
return render(
|
||||
request, "apps/dashboard/home.html", {
|
||||
"form": ItemForm(),
|
||||
"palettes": PALETTES,
|
||||
})
|
||||
context = {"form": ItemForm(), "palettes": PALETTES}
|
||||
if request.user.is_authenticated:
|
||||
context["applets"] = _applet_context(request.user)
|
||||
return render(request, "apps/dashboard/home.html", context)
|
||||
|
||||
def new_list(request):
|
||||
form = ItemForm(data=request.POST)
|
||||
@@ -100,5 +106,8 @@ def toggle_applets(request):
|
||||
defaults={"visible": applet.slug in checked},
|
||||
)
|
||||
if request.headers.get("HX-Request"):
|
||||
return HttpResponse("")
|
||||
return render(request, "apps/dashboard/_partials/_applets.html", {
|
||||
"applets": _applet_context(request.user),
|
||||
"palettes": PALETTES,
|
||||
})
|
||||
return redirect("home")
|
||||
|
||||
Reference in New Issue
Block a user