Commit 5aa0e3fa authored by Giorgos Korfiatis's avatar Giorgos Korfiatis Committed by Christos Stavrakakis
Browse files

astakos: Use pprint_table for expired projects

parent 8a9af388
......@@ -35,7 +35,7 @@ from optparse import make_option
from django.db import transaction
from django.core.management.base import CommandError
from snf_django.management import utils
from astakos.im.functions import (terminate, suspend, unsuspend,
reinstate, check_expiration,
approve_application, deny_application)
......@@ -91,6 +91,7 @@ class Command(SynnefoCommand):
@transaction.commit_on_success
def handle(self, *args, **options):
self.output_format = options["output_format"]
message = options['message']
actions = {
......@@ -122,27 +123,14 @@ class Command(SynnefoCommand):
length = len(projects)
if length == 0:
s = 'No expired projects.\n'
elif length == 1:
s = '1 expired project:\n'
else:
s = '%d expired projects:\n' % (length,)
self.stderr.write(s)
if length > 0:
labels = ('Project', 'Name', 'Status', 'Expiration date')
columns = (10, 30, 14, 30)
line = ' '.join(l.rjust(w) for l, w in zip(labels, columns))
self.stderr.write(line + '\n')
sep = '-' * len(line)
self.stderr.write(sep + '\n')
for project in projects:
line = ' '.join(f.rjust(w) for f, w in zip(project, columns))
self.stderr.write(line + '\n')
if execute:
self.stderr.write('%d projects have been terminated.\n' % (
self.stderr.write(s)
return
labels = ('Project', 'Name', 'Status', 'Expiration date')
utils.pprint_table(self.stdout, projects, labels,
self.output_format, title="Expired projects")
if execute:
self.stderr.write('%d projects have been terminated.\n' % (
length,))
def expire(self, execute=False):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment