space-accessstablestagetest-hooks
|
Last change
on this file since 055a7e9 was
654c9af,
checked in by Alex Dehnert <adehnert@…>, 14 years ago
|
|
Add script to redo student status validations
This is useful if you forget to run groups/load_people.py before running the
migration that adds the "valid" column to the PersonMembershipUpdate? model.
|
-
Property mode set to
100755
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | #!/usr/bin/python |
|---|
| 2 | |
|---|
| 3 | import sys |
|---|
| 4 | import os |
|---|
| 5 | |
|---|
| 6 | if __name__ == '__main__': |
|---|
| 7 | cur_file = os.path.abspath(__file__) |
|---|
| 8 | django_dir = os.path.abspath(os.path.join(os.path.dirname(cur_file), '..')) |
|---|
| 9 | proj_dir = os.path.abspath(os.path.join(django_dir, '..')) |
|---|
| 10 | sys.path.append(django_dir) |
|---|
| 11 | sys.path.append(proj_dir) |
|---|
| 12 | os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' |
|---|
| 13 | |
|---|
| 14 | import forms.models |
|---|
| 15 | import groups.models |
|---|
| 16 | |
|---|
| 17 | |
|---|
| 18 | def revalidate_confirmations(): |
|---|
| 19 | confirmations = forms.models.PersonMembershipUpdate.objects.filter(deleted__isnull=True, valid=forms.models.VALID_UNSET) |
|---|
| 20 | accounts = groups.models.AthenaMoiraAccount |
|---|
| 21 | for confirmation in confirmations: |
|---|
| 22 | try: |
|---|
| 23 | person = accounts.active_accounts.get(username=confirmation.username) |
|---|
| 24 | if person.is_student(): |
|---|
| 25 | confirmation.valid = forms.models.VALID_AUTOVALIDATED |
|---|
| 26 | else: |
|---|
| 27 | confirmation.valid = forms.models.VALID_AUTOREJECTED |
|---|
| 28 | |
|---|
| 29 | except accounts.DoesNotExist: |
|---|
| 30 | print "Could not find %s; rejecting" % (confirmation.username, ) |
|---|
| 31 | confirmation.valid = forms.models.VALID_AUTOREJECTED |
|---|
| 32 | confirmation.save() |
|---|
| 33 | |
|---|
| 34 | if __name__ == '__main__': |
|---|
| 35 | revalidate_confirmations() |
|---|
Note: See
TracBrowser
for help on using the repository browser.