Revision 39b2cb50 snf-astakos-app/astakos/im/management/commands/project-control.py

b/snf-astakos-app/astakos/im/management/commands/project-control.py
36 36
from django.core.management.base import BaseCommand, CommandError
37 37
from astakos.im.functions import (terminate, suspend, resume, check_expiration,
38 38
                                  approve_application, deny_application)
39
from astakos.im.project_xctx import cmd_project_transaction_context
39
from synnefo.lib.db.transaction import commit_on_success_strict
40 40

  
41 41

  
42 42
class Command(BaseCommand):
......
117 117
            self.expire(execute=True)
118 118

  
119 119
    def run_command(self, func, *args):
120
        with cmd_project_transaction_context(sync=True) as ctx:
120
        @commit_on_success_strict()
121
        def inner():
121 122
            try:
122 123
                func(*args)
123 124
            except BaseException as e:
124
                if ctx:
125
                    ctx.mark_rollback()
126 125
                raise CommandError(e)
126
        inner()
127 127

  
128 128
    def print_expired(self, projects, execute):
129 129
        length = len(projects)
......
152 152
                self.stdout.write('%d projects have been terminated.\n' % (
153 153
                    length,))
154 154

  
155
    @cmd_project_transaction_context(sync=True)
155
    @commit_on_success_strict()
156 156
    def expire(self, execute=False, ctx=None):
157 157
        try:
158 158
            projects = check_expiration(execute=execute)

Also available in: Unified diff