diff --git a/core/admin.py b/core/admin.py index 70cd816..500404f 100644 --- a/core/admin.py +++ b/core/admin.py @@ -1,32 +1,11 @@ -from django.contrib import admin, messages +from django.contrib import messages from django.contrib.auth.admin import UserAdmin as UserAdmin_ -from django.contrib.auth.models import Group -from django.db.models import QuerySet from django.urls import reverse from django.utils.safestring import mark_safe from django.utils.translation import gettext_lazy as _ from .forms import * - - -@admin.action( - permissions=["change"], - description=_("Set selected users as a Logic Puzzle Setter"), -) -def set_as_logic_setter(modeladmin, request, queryset: QuerySet[User]): - for user in queryset: - user.is_staff = True - # set their group to location setter - user.groups.add(Group.objects.get_or_create(name="Logic Logic Puzzle Setters")) - - -@admin.action( - permissions=["change"], - description=_("Remove selected users as a Logic Puzzle Setter"), -) -def remove_as_logic_setter(modeladmin, request, queryset: QuerySet[User]): - for user in queryset: - user.groups.remove(Group.objects.get(name="Logic Logic Puzzle Setters")) +from .utils.actions import * class HintsInLine(admin.StackedInline): @@ -123,7 +102,12 @@ class UserAdmin(UserAdmin_): "last_name", "email", ) - actions = [set_as_logic_setter, remove_as_logic_setter] + actions = [ + set_as_logic_setter, + remove_as_logic_setter, + set_as_location_setter, + remove_as_location_setter, + ] admin_field = list(UserAdmin_.fieldsets) admin_field[0][1]["fields"] = ( "username", diff --git a/core/management/commands/init.py b/core/management/commands/init.py index a26ae08..1c9725b 100644 --- a/core/management/commands/init.py +++ b/core/management/commands/init.py @@ -1,18 +1,21 @@ +from django.conf import settings from django.contrib.auth.models import Group, Permission from django.core.management import BaseCommand from core import models GROUPS_PERMISSIONS = { - "Location Setter": { + settings.LOCATION_SETTERS_NAME: { models.QrCode: ["add", "change", "delete"], models.Hint: ["add", "change", "delete", "view"], models.LogicPuzzleHint: ["view"], + models.Hunt: ["view"], }, - "Logic Puzzle Setters": { + settings.LOGIC_PUZZLE_SETTERS_NAME: { models.QrCode: ["view"], models.Hint: ["view"], models.LogicPuzzleHint: ["add", "change", "delete", "view"], + models.Hunt: ["view"], }, } diff --git a/core/models.py b/core/models.py index 7ab4524..303783a 100644 --- a/core/models.py +++ b/core/models.py @@ -137,6 +137,7 @@ class Hint(models.Model): def __str__(self): return self.hint + class Team(models.Model): # owner = models.ForeignKey(User, on_delete=models.PROTECT, related_name="teams_ownership") potentially add this later id = models.AutoField(primary_key=True) diff --git a/core/templates/core/credits.html b/core/templates/core/credits.html index 51e625f..cd32fe2 100644 --- a/core/templates/core/credits.html +++ b/core/templates/core/credits.html @@ -44,7 +44,12 @@

{% translate 'hints' %}

  • {{ hs.get_full_name }}
  • {% endfor %} - +

    {% translate 'logic puzzle' %}

    +

    {% translate 'support' %}