mirror of
https://github.com/pacnpal/thrillwiki_django_no_react.git
synced 2025-12-20 07:31:07 -05:00
Add initial migration for moderation app and resolve seed command issues
- Created an empty migration file for the moderation app to enable migrations. - Documented the resolution of the seed command failure due to missing moderation tables. - Identified and fixed a VARCHAR(10) constraint violation in the User model during seed data generation. - Updated role assignment in the seed command to comply with the field length constraint.
This commit is contained in:
@@ -15,17 +15,17 @@ class Command(BaseCommand):
|
||||
create_default_groups()
|
||||
|
||||
# Sync existing users with groups based on their roles
|
||||
users = User.objects.exclude(role=User.Roles.USER)
|
||||
users = User.objects.exclude(role="USER")
|
||||
for user in users:
|
||||
group = Group.objects.filter(name=user.role).first()
|
||||
if group:
|
||||
user.groups.add(group)
|
||||
|
||||
# Update staff/superuser status based on role
|
||||
if user.role == User.Roles.SUPERUSER:
|
||||
if user.role == "SUPERUSER":
|
||||
user.is_superuser = True
|
||||
user.is_staff = True
|
||||
elif user.role in [User.Roles.ADMIN, User.Roles.MODERATOR]:
|
||||
elif user.role in ["ADMIN", "MODERATOR"]:
|
||||
user.is_staff = True
|
||||
user.save()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user