12 lines
416 B
Python
12 lines
416 B
Python
from apps.applets.models import Applet, UserApplet
|
|
|
|
|
|
def applet_context(user, context):
|
|
ua_map = {ua.applet_id: ua.visible for ua in user.user_applets.all()}
|
|
applets = {a.slug: a for a in Applet.objects.filter(context=context)}
|
|
return [
|
|
{"applet": applets[slug], "visible": ua_map.get(applets[slug].pk, applets[slug].default_visible)}
|
|
for slug in applets
|
|
if slug in applets
|
|
]
|