Revision ef1fb98b snf-astakos-app/astakos/im/management/commands/term-add.py
b/snf-astakos-app/astakos/im/management/commands/term-add.py | ||
---|---|---|
34 | 34 |
from os.path import abspath |
35 | 35 |
|
36 | 36 |
from django.core.management.base import BaseCommand, CommandError |
37 |
from django.db import transaction |
|
37 | 38 |
|
38 |
from astakos.im.models import ApprovalTerms |
|
39 |
from astakos.im.models import ApprovalTerms, AstakosUser
|
|
39 | 40 |
|
40 | 41 |
|
41 | 42 |
class Command(BaseCommand): |
42 | 43 |
args = "<location>" |
43 | 44 |
help = "Insert approval terms" |
44 | 45 |
|
46 |
@transaction.commit_on_success |
|
45 | 47 |
def handle(self, *args, **options): |
46 | 48 |
if len(args) != 1: |
47 | 49 |
raise CommandError("Invalid number of arguments") |
... | ... | |
54 | 56 |
|
55 | 57 |
terms = ApprovalTerms(location=location) |
56 | 58 |
terms.save() |
59 |
AstakosUser.objects.select_for_update().\ |
|
60 |
filter(has_signed_terms=True).\ |
|
61 |
update(has_signed_terms=False, date_signed_terms=None) |
|
57 | 62 |
|
58 | 63 |
msg = "Created term id %d" % (terms.id,) |
59 | 64 |
self.stdout.write(msg + '\n') |
Also available in: Unified diff