Commit 0af0fd57 authored by Sofia Papagiannaki's avatar Sofia Papagiannaki Committed by Georgios D. Tsoukalas
Browse files

Unify astakos management command formatting

parent c1923a42
...@@ -35,7 +35,7 @@ from django.core.management.base import BaseCommand, CommandError ...@@ -35,7 +35,7 @@ from django.core.management.base import BaseCommand, CommandError
from astakos.im.models import Invitation from astakos.im.models import Invitation
from ._common import format_bool, format_date from ._common import format
class Command(BaseCommand): class Command(BaseCommand):
...@@ -56,13 +56,13 @@ class Command(BaseCommand): ...@@ -56,13 +56,13 @@ class Command(BaseCommand):
'real name': invitation.realname, 'real name': invitation.realname,
'email': invitation.username, 'email': invitation.username,
'code': invitation.code, 'code': invitation.code,
'consumed': format_bool(invitation.is_consumed), 'consumed': invitation.is_consumed,
'date created': format_date(invitation.created), 'date created': invitation.created,
'date consumed': format_date(invitation.consumed), 'date consumed': invitation.consumed,
'inviter real name': invitation.inviter.realname, 'inviter real name': invitation.inviter.realname,
'invitater email': invitation.inviter.email, 'invitater email': invitation.inviter.email,
} }
for key, val in sorted(kv.items()): for key, val in sorted(kv.items()):
line = '%s: %s\n' % (key.rjust(18), val) line = '%s: %s\n' % (key.rjust(18), format(val))
self.stdout.write(line) self.stdout.write(line)
...@@ -67,9 +67,9 @@ class Command(NoArgsCommand): ...@@ -67,9 +67,9 @@ class Command(NoArgsCommand):
id = str(invitation.id) id = str(invitation.id)
code = str(invitation.code) code = str(invitation.code)
consumed = format_bool(invitation.is_consumed) consumed = format_bool(invitation.is_consumed)
fields = ( fields = (format(elem) for elem in \
id, invitation.inviter.email, invitation.username, invitation.realname, (id, invitation.inviter.email, invitation.username,
code, consumed) invitation.realname, code, consumed))
if options['csv']: if options['csv']:
line = '|'.join(fields) line = '|'.join(fields)
......
...@@ -36,7 +36,7 @@ from optparse import make_option ...@@ -36,7 +36,7 @@ from optparse import make_option
from django.core.management.base import NoArgsCommand from django.core.management.base import NoArgsCommand
from astakos.im.models import Chain from astakos.im.models import Chain
from ._common import format_bool, shortened from ._common import format, shortened
class Command(NoArgsCommand): class Command(NoArgsCommand):
...@@ -71,13 +71,13 @@ class Command(NoArgsCommand): ...@@ -71,13 +71,13 @@ class Command(NoArgsCommand):
for info in chain_info(chain_dict): for info in chain_info(chain_dict):
fields = [ fields = [(format(elem) for elem in (
(info['projectid'], False), (info['projectid'], False),
(info['name'], True), (info['name'], True),
(info['owner'], True), (info['owner'], True),
(info['status'], False), (info['status'], False),
(info['appid'], False), (info['appid'], False),
] )]
if options['csv']: if options['csv']:
line = '|'.join(fields) line = '|'.join(fields)
......
...@@ -37,7 +37,7 @@ from django.core.management.base import BaseCommand, CommandError ...@@ -37,7 +37,7 @@ from django.core.management.base import BaseCommand, CommandError
from synnefo.lib.ordereddict import OrderedDict from synnefo.lib.ordereddict import OrderedDict
from astakos.im.models import Chain, ProjectApplication from astakos.im.models import Chain, ProjectApplication
from ._common import format_bool, format_date from ._common import format
class Command(BaseCommand): class Command(BaseCommand):
...@@ -86,7 +86,7 @@ class Command(BaseCommand): ...@@ -86,7 +86,7 @@ class Command(BaseCommand):
def show_info(self, info): def show_info(self, info):
for key, val in info.items(): for key, val in info.items():
line = '%s: %s\n' % (key.rjust(22), val) line = '%s: %s\n' % (key.rjust(22), format(val))
self.stdout.write(line) self.stdout.write(line)
self.stdout.write('\n') self.stdout.write('\n')
...@@ -140,9 +140,9 @@ def app_fields(app): ...@@ -140,9 +140,9 @@ def app_fields(app):
('homepage', app.homepage), ('homepage', app.homepage),
('description', app.description), ('description', app.description),
('comments for review', app.comments), ('comments for review', app.comments),
('request issue date', format_date(app.issue_date)), ('request issue date', app.issue_date),
('request start date', format_date(app.start_date)), ('request start date', app.start_date),
('request end date', format_date(app.end_date)), ('request end date', app.end_date),
('resources', app.resource_policies), ('resources', app.resource_policies),
('join policy', app.member_join_policy_display), ('join policy', app.member_join_policy_display),
('leave policy', app.member_leave_policy_display), ('leave policy', app.member_leave_policy_display),
...@@ -168,15 +168,15 @@ def project_fields(s, project, last_app): ...@@ -168,15 +168,15 @@ def project_fields(s, project, last_app):
('homepage', app.homepage), ('homepage', app.homepage),
('description', app.description), ('description', app.description),
('comments for review', app.comments), ('comments for review', app.comments),
('request issue date', format_date(app.issue_date)), ('request issue date', app.issue_date),
('request start date', format_date(app.start_date)), ('request start date', app.start_date),
('creation date', format_date(project.creation_date)), ('creation date', project.creation_date),
('request end date', format_date(app.end_date)), ('request end date', app.end_date),
]) ])
deact_date = project.deactivation_date deact_date = project.deactivation_date
if deact_date is not None: if deact_date is not None:
d['deactivation date'] = format_date(deact_date) d['deactivation date'] = deact_date
mem_limit = app.limit_on_members_number mem_limit = app.limit_on_members_number
mem_limit_show = mem_limit if mem_limit is not None else "unlimited" mem_limit_show = mem_limit if mem_limit is not None else "unlimited"
......
...@@ -37,7 +37,7 @@ from django.core.management.base import NoArgsCommand ...@@ -37,7 +37,7 @@ from django.core.management.base import NoArgsCommand
from astakos.im.models import AstakosUser from astakos.im.models import AstakosUser
from ._common import format_bool from ._common import format
class Command(NoArgsCommand): class Command(NoArgsCommand):
...@@ -79,13 +79,16 @@ class Command(NoArgsCommand): ...@@ -79,13 +79,16 @@ class Command(NoArgsCommand):
for user in users: for user in users:
id = str(user.id) id = str(user.id)
active = format_bool(user.is_active) active = user.is_active
admin = format_bool(user.is_superuser) admin = user.is_superuser
uuid = user.uuid or '' uuid = user.uuid or ''
fields = ( fields = (format(elem) for elem in (
id, user.email, user.realname, active, admin, \ id,
uuid, user.auth_providers_display user.email,
) user.realname,
active, admin, uuid,
user.auth_providers_display
))
if options['csv']: if options['csv']:
line = '|'.join(fields) line = '|'.join(fields)
......
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