-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
161 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from django.conf import settings | ||
from django.contrib.auth import get_user_model | ||
from django.contrib.auth.models import Group, Permission | ||
from django.contrib.contenttypes.models import ContentType | ||
from django.core.management.base import BaseCommand | ||
|
||
from clubs.models import Club | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Give superuser to hard-coded user accounts affiliated with OSA." | ||
web_execute = True | ||
|
||
def handle(self, *args, **kwargs): | ||
User = get_user_model() | ||
content_type = ContentType.objects.get_for_model(Club) | ||
approve_perm = Permission.objects.get( | ||
codename="approve_club", content_type=content_type | ||
) | ||
pending_perm = Permission.objects.get( | ||
codename="see_pending_clubs", content_type=content_type | ||
) | ||
if not settings.OSA_KEYS: | ||
raise ValueError("OSA_KEYS not set in settings") | ||
if not (approvers := Group.objects.filter(name="Approvers").first()): | ||
raise ValueError("Approvers group not found") | ||
for key in settings.OSA_KEYS: | ||
if not key or not (user := User.objects.get(username=key)): | ||
continue | ||
user.is_superuser = True | ||
user.is_staff = True | ||
user.user_permissions.add(approve_perm) | ||
user.user_permissions.add(pending_perm) | ||
approvers.user_set.add(user) | ||
user.save() | ||
approvers.save() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -265,3 +265,5 @@ | |
|
||
# Cybersource settings | ||
CYBERSOURCE_CLIENT_VERSION = "0.15" | ||
|
||
OSA_KEYS = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -118,5 +118,6 @@ | |
}, | ||
"engines": { | ||
"node": "^20.0.0" | ||
} | ||
}, | ||
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters