space-accessstablestage
Last change
on this file was
df88ee9,
checked in by Alex Dehnert <adehnert@…>, 13 years ago
|
Use transaction.commit_on_success for imports
Fixed the following scripts:
- forms/update_validations.py (15s->1s for 70ish validations)
- space/import_into_db.py (67s->1s for 75 spaces and 100 assignments)
- util/sync_moira_authz.py (65s->4s for importing ~50 new people)
util/update_old_previews.py was skipped:
- it's dead code, I believe --- I think previews are unused
- preview updating is slow, IIRC; it's dubious we'd get noticeably better
runtime on the script, and there may even be utility to the progress
updates not doing this transactionally supplies
This closes ASA Trac #59.
|
-
Property mode set to
100755
|
File size:
1.2 KB
|
Rev | Line | |
---|
[654c9af] | 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 | |
---|
[df88ee9] | 14 | from django.db import transaction |
---|
| 15 | |
---|
[654c9af] | 16 | import forms.models |
---|
| 17 | import groups.models |
---|
| 18 | |
---|
| 19 | |
---|
[df88ee9] | 20 | @transaction.commit_on_success |
---|
[654c9af] | 21 | def revalidate_confirmations(): |
---|
| 22 | confirmations = forms.models.PersonMembershipUpdate.objects.filter(deleted__isnull=True, valid=forms.models.VALID_UNSET) |
---|
| 23 | accounts = groups.models.AthenaMoiraAccount |
---|
| 24 | for confirmation in confirmations: |
---|
| 25 | try: |
---|
| 26 | person = accounts.active_accounts.get(username=confirmation.username) |
---|
| 27 | if person.is_student(): |
---|
| 28 | confirmation.valid = forms.models.VALID_AUTOVALIDATED |
---|
| 29 | else: |
---|
| 30 | confirmation.valid = forms.models.VALID_AUTOREJECTED |
---|
| 31 | |
---|
| 32 | except accounts.DoesNotExist: |
---|
| 33 | print "Could not find %s; rejecting" % (confirmation.username, ) |
---|
| 34 | confirmation.valid = forms.models.VALID_AUTOREJECTED |
---|
| 35 | confirmation.save() |
---|
| 36 | |
---|
| 37 | if __name__ == '__main__': |
---|
| 38 | revalidate_confirmations() |
---|
Note: See
TracBrowser
for help on using the repository browser.