fixed applet seeding in 0005 migration; many FTs & ITs now require authentication before they pass; New List & My Lists converted to dash applets; home.html offloaded and _applets.html onboarded w. these applets
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:
@@ -8,6 +8,7 @@ from apps.dashboard.models import Applet, Item, List, UserApplet
|
||||
from apps.lyric.models import User
|
||||
|
||||
|
||||
APPLET_ORDER = ["new-list", "my-lists", "username", "palette"]
|
||||
UNLOCKED_PALETTES = frozenset(["palette-default"])
|
||||
PALETTES = [
|
||||
{"name": "palette-default", "label": "Earthman", "locked": False},
|
||||
@@ -18,9 +19,11 @@ PALETTES = [
|
||||
|
||||
def _applet_context(user):
|
||||
ua_map = {ua.applet_id: ua.visible for ua in user.user_applets.all()}
|
||||
applets = {a.slug: a for a in Applet.objects.all()}
|
||||
return [
|
||||
{"applet": applet, "visible": ua_map.get(applet.pk, applet.default_visible)}
|
||||
for applet in Applet.objects.all()
|
||||
{"applet": applets[slug], "visible": ua_map.get(applets[slug].pk, applets[slug].default_visible)}
|
||||
for slug in APPLET_ORDER
|
||||
if slug in applets
|
||||
]
|
||||
|
||||
def home_page(request):
|
||||
@@ -39,7 +42,10 @@ def new_list(request):
|
||||
form.save(for_list=nulist)
|
||||
return redirect(nulist)
|
||||
else:
|
||||
return render(request, "apps/dashboard/home.html", {"form": form})
|
||||
context = {"form": form, "palettes": PALETTES, "page_class": "page-dashboard"}
|
||||
if request.user.is_authenticated:
|
||||
context["applets"] = _applet_context(request.user)
|
||||
return render(request, "apps/dashboard/home.html", context)
|
||||
|
||||
def view_list(request, list_id):
|
||||
our_list = List.objects.get(id=list_id)
|
||||
@@ -109,5 +115,6 @@ def toggle_applets(request):
|
||||
return render(request, "apps/dashboard/_partials/_applets.html", {
|
||||
"applets": _applet_context(request.user),
|
||||
"palettes": PALETTES,
|
||||
"form": ItemForm(),
|
||||
})
|
||||
return redirect("home")
|
||||
|
||||
Reference in New Issue
Block a user