Created
July 2, 2012 15:48
-
-
Save nychng/3033889 to your computer and use it in GitHub Desktop.
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
from django.core.management.base import BaseCommand | |
from django.contrib.auth.models import Group | |
from events.models import Event | |
from role.models import Role | |
class Command(BaseCommand): | |
""" | |
This is a one time command that updates an event's general users to groups | |
""" | |
def handle(self, *args, **options): | |
# get AEPA2012 | |
aepa = Event.objects.get(pk=6) | |
tf = Event.objects.get(pk=2) | |
# get all the users for aepa and add them to group | |
aepa_role = Role.objects.get(event=aepa, roletype__name='General') | |
aepa_group = Group.objects.get(name='%s: Delegate' % aepa.name) | |
for profile in aepa_role.profiles.all(): | |
profile.user.groups.add(aepa_group) | |
print profile.user | |
# get all the users for aepa and add them to group | |
tf_role = Role.objects.get(event=tf, roletype__name='General') | |
tf_group = Group.objects.get(name='%s: Delegate' % tf.name) | |
for profile in tf_role.profiles.all(): | |
profile.user.groups.add(tf_group) | |
print profile.user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment