Revision 8cf9b2dd snf-astakos-app/astakos/im/management/commands/project-admin-checks.py
b/snf-astakos-app/astakos/im/management/commands/project-admin-checks.py | ||
---|---|---|
33 | 33 |
|
34 | 34 |
from optparse import make_option |
35 | 35 |
from django.core.management.base import BaseCommand, CommandError |
36 |
from django.db import transaction |
|
37 | 36 |
|
38 | 37 |
from astakos.im.functions import check_expiration |
38 |
from astakos.im.project_xctx import project_transaction_context |
|
39 | 39 |
|
40 |
@transaction.commit_manually |
|
41 | 40 |
class Command(BaseCommand): |
42 | 41 |
help = "Perform administration checks on projects" |
43 | 42 |
|
... | ... | |
84 | 83 |
def handle(self, *args, **options): |
85 | 84 |
|
86 | 85 |
execute = options['execute'] |
86 |
if options['expire']: |
|
87 |
self.expire(execute=execute) |
|
87 | 88 |
|
89 |
@project_transaction_context(sync=True) |
|
90 |
def expire(self, execute=False, ctx=None): |
|
88 | 91 |
try: |
89 |
if options['expire']: |
|
90 |
projects = check_expiration(execute=execute) |
|
91 |
self.print_expired(projects, execute) |
|
92 |
projects = check_expiration(execute=execute) |
|
93 |
self.print_expired(projects, execute) |
|
92 | 94 |
except BaseException as e: |
93 |
transaction.rollback() |
|
95 |
if ctx: |
|
96 |
ctx.mark_rollback() |
|
94 | 97 |
raise CommandError(e) |
95 |
else: |
|
96 |
transaction.commit() |
Also available in: Unified diff