improve trainee management

This commit is contained in:
Ross
2024-09-09 10:02:51 +01:00
parent 4d8d6b2a06
commit b8ee207061
3 changed files with 63 additions and 9 deletions
+17 -1
View File
@@ -2853,6 +2853,17 @@ def users_bulk_edit(request):
]
)
# TODO: work out how to actually use hyperscript
html = (
html
+
f"""<button class='change-grade-button' id='add-grade--remove'
hx-post="{reverse('generic:users_bulk_edit')}"
hx-include="[name='selection']"
hx-confirm="This will remove grades of all selected users, are you sure you wish to continue?"
hx-target="#htmx-info"
_='on click put "" into #htmx-options'
>Remove</button>"""
)
html = (
html
+ "<button class='cancel-button' _='on click for el in .change-grade-button remove el end then remove me'>Cancel</button>"
@@ -2861,9 +2872,14 @@ def users_bulk_edit(request):
case r if r.startswith("add-grade"):
user_models = get_user_selection_from_request(request)
grade = r.split("--")[-1]
if grade == "remove":
grade = None
# u: User
for u in user_models:
u.userprofile.grade_id = r.split("--")[-1]
u.userprofile.grade_id = grade
u.save()
html = "Grades updated"
case "bulk-add-group-button":