Revision 09166ef0 snf-astakos-app/astakos/im/management/commands/project-control.py

b/snf-astakos-app/astakos/im/management/commands/project-control.py
35 35

  
36 36
from django.db import transaction
37 37
from snf_django.management.commands import SynnefoCommand, CommandError
38
from snf_django.management import utils
38 39
from astakos.im.functions import (terminate, suspend, unsuspend,
39 40
                                  reinstate, check_expiration,
40 41
                                  approve_application, deny_application)
......
89 90
    @transaction.commit_on_success
90 91
    def handle(self, *args, **options):
91 92

  
93
        self.output_format = options["output_format"]
92 94
        message = options['message']
93 95

  
94 96
        actions = {
......
120 122
        length = len(projects)
121 123
        if length == 0:
122 124
            s = 'No expired projects.\n'
123
        elif length == 1:
124
            s = '1 expired project:\n'
125
        else:
126
            s = '%d expired projects:\n' % (length,)
127
        self.stderr.write(s)
128

  
129
        if length > 0:
130
            labels = ('Project', 'Name', 'Status', 'Expiration date')
131
            columns = (10, 30, 14, 30)
132

  
133
            line = ' '.join(l.rjust(w) for l, w in zip(labels, columns))
134
            self.stderr.write(line + '\n')
135
            sep = '-' * len(line)
136
            self.stderr.write(sep + '\n')
137

  
138
            for project in projects:
139
                line = ' '.join(f.rjust(w) for f, w in zip(project, columns))
140
                self.stderr.write(line + '\n')
141

  
142
            if execute:
143
                self.stderr.write('%d projects have been terminated.\n' % (
125
            self.stderr.write(s)
126
            return
127
        labels = ('Project', 'Name', 'Status', 'Expiration date')
128
        utils.pprint_table(self.stdout, projects, labels,
129
                           self.output_format, title="Expired projects")
130

  
131
        if execute:
132
            self.stderr.write('%d projects have been terminated.\n' % (
144 133
                    length,))
145 134

  
146 135
    def expire(self, execute=False):

Also available in: Unified diff