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' %}
+
+ {% for ls in logicsetters %}
+ - {{ ls.get_full_name }}
+ {% endfor %}
+
{% translate 'support' %}
- project metropolis
diff --git a/core/utils/actions.py b/core/utils/actions.py
new file mode 100644
index 0000000..813c440
--- /dev/null
+++ b/core/utils/actions.py
@@ -0,0 +1,47 @@
+from django.conf import settings
+from django.contrib import admin
+from django.contrib.auth.models import Group
+from django.db.models import QuerySet
+from django.utils.translation import gettext_lazy as _
+
+from core.models import User
+
+
+@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.groups.add(
+ Group.objects.get_or_create(name=settings.LOGIC_PUZZLE_SETTERS_NAME)
+ )
+
+
+@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=settings.LOGIC_PUZZLE_SETTERS_NAME))
+
+
+@admin.action(
+ permissions=["change"],
+ description=_("Set selected users as a Qr Code Setter"),
+)
+def set_as_location_setter(modeladmin, request, queryset: QuerySet[User]):
+ for user in queryset:
+ user.groups.add(
+ Group.objects.get_or_create(name=settings.LOCATION_SETTERS_NAME)
+ )
+
+
+@admin.action(
+ permissions=["change"],
+ description=_("Remove selected users as a Qr Code Setter"),
+)
+def remove_as_location_setter(modeladmin, request, queryset: QuerySet[User]):
+ for user in queryset:
+ user.groups.remove(Group.objects.get(name=settings.LOCATION_SETTERS_NAME))
diff --git a/core/views/index.py b/core/views/index.py
index 8a25e91..a1cc244 100644
--- a/core/views/index.py
+++ b/core/views/index.py
@@ -23,9 +23,16 @@ def credits(q):
try:
hintsetters = User.objects.filter(
groups__in=[
- Group.objects.get(id=settings.HINTS_GROUP_PK),
+ Group.objects.get(name=settings.HINT_SETTERS_NAME),
+ ]
+ ).all()
+ logicsetters = User.objects.filter(
+ groups__in=[
+ Group.objects.get(name=settings.LOGIC_PUZZLE_SETTERS_NAME),
]
).all()
except Group.DoesNotExist:
hintsetters = []
- return render(q, "core/credits.html", dict(hintsetters=hintsetters))
+ return render(
+ q, "core/credits.html", dict(hintsetters=hintsetters, logicsetters=logicsetters)
+ )
diff --git a/wlmac-scavenger/settings.py b/wlmac-scavenger/settings.py
index 691a11d..3db8091 100644
--- a/wlmac-scavenger/settings.py
+++ b/wlmac-scavenger/settings.py
@@ -113,11 +113,8 @@
me_url=f"{base_url}/api/me/internal",
scope="me_meta internal",
)
-
-HINTS_GROUP_PK: Final[
- int
-] = 1 # the pk of the hints group (defined in commands/init.py)
-
+LOCATION_SETTERS_NAME: Final[str] = "Location Setter"
+LOGIC_PUZZLE_SETTERS_NAME: Final[str] = "Logic Puzzle Setters"
try:
with open(os.path.join(os.path.dirname(__file__), "local_settings.py")) as f:
exec(f.read(), globals())