From c94841c17b59afa5e2fe59637968b938ae28c2e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Mon, 26 Feb 2018 17:20:59 +0100 Subject: [PATCH] Add gen_history django-admin command --- histories/management/commands/gen_history.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 histories/management/commands/gen_history.py diff --git a/histories/management/commands/gen_history.py b/histories/management/commands/gen_history.py new file mode 100644 index 0000000..3a2a616 --- /dev/null +++ b/histories/management/commands/gen_history.py @@ -0,0 +1,16 @@ +from django.core.management.base import BaseCommand +from profiles import models as profiles +from histories.models import generate_history +from datetime import datetime + + +class Command(BaseCommand): + ''' Generates an history and prints the related XML ''' + + def add_arguments(self, parser): + pass + + def handle(self, *args, **kwargs): + prof = profiles.Profile.objects.all()[0] + history = generate_history(prof, datetime.now()) + self.stdout.write(history.to_xml_string())