extensive refactor push to continue to liberate applets from dashboard; new _applets.html & .gear.html template partials for use across all -board views; all applets.html sections have been liberated into their own _applet-<applet-name>.html template partials in their respective templates/apps/*board/_partials/ dirs; gameboard.html & home.html greatly simplified; .gear-btn describes gear menu now, #id_<*board nickname>*gear IDs abandoned; as such, .gear-btn styling moved from _dashboard.scss to _base.scss; new applets.js file contains related initGearMenus scripts, which no longer waits for window reload; new apps.applets.utils file manages applet_context() fn; new gameboard.js file but currently empty (false start); updates across all sorts of ITs & dash- & gameboard FTs
This commit is contained in:
@@ -1,9 +1,18 @@
|
||||
from django.contrib.auth.decorators import login_required
|
||||
from django.shortcuts import render
|
||||
from django.shortcuts import redirect, render
|
||||
|
||||
from apps.applets.utils import applet_context
|
||||
from apps.applets.models import Applet, UserApplet
|
||||
from apps.lyric.models import Token
|
||||
|
||||
|
||||
GAMEBOARD_APPLET_ORDER = [
|
||||
"new-game",
|
||||
"my-games",
|
||||
"game-kit",
|
||||
]
|
||||
|
||||
|
||||
@login_required(login_url="/")
|
||||
def gameboard(request):
|
||||
coin = request.user.tokens.filter(token_type=Token.COIN).first()
|
||||
@@ -12,5 +21,23 @@ def gameboard(request):
|
||||
request, "apps/gameboard/gameboard.html", {
|
||||
"coin": coin,
|
||||
"free_tokens": free_tokens,
|
||||
"applets": applet_context(request.user, "gameboard"),
|
||||
}
|
||||
)
|
||||
|
||||
@login_required(login_url="/")
|
||||
def toggle_game_applets(request):
|
||||
checked = request.POST.getlist("applets")
|
||||
for applet in Applet.objects.filter(context="gameboard"):
|
||||
UserApplet.objects.update_or_create(
|
||||
user=request.user,
|
||||
applet=applet,
|
||||
defaults={"visible": applet.slug in checked},
|
||||
)
|
||||
if request.headers.get("HX-Request"):
|
||||
return render(request, "apps/gameboard/_partials/_applets.html", {
|
||||
"applets": applet_context(request.user, "gameboard"),
|
||||
"coin": request.user.tokens.filter(token_type=Token.COIN).first(),
|
||||
"free_tokens": list(request.user.tokens.filter(token_type=Token.FREE)),
|
||||
})
|
||||
return redirect("gameboard")
|
||||
|
||||
Reference in New Issue
Block a user