import DAE
[auf_rh_dae.git] / project / dae / management / commands / dae.py
CommitLineData
0d5def11
OL
1# -*- encoding: utf-8 -*-
2
3from django.core.management.base import BaseCommand
f513a886 4
0d5def11 5from project.dae import models as dae
f513a886
OL
6
7class Command(BaseCommand):
8
9
10 def handle(self, *args, **options):
bfdede88 11
5be12f6a
OL
12 if len(args) < 2:
13 print len(args)
14 self.stdout.write("dae <modele> <id> <run>\n")
0d5def11
OL
15 return
16
17 classname = args[0]
18 klass = getattr(dae, classname, None)
3b14230d
OL
19 if klass is None:
20 self.stdout.write("Le modèle %s n'existe pas dans DAE.\n" % classname)
0d5def11
OL
21
22 id = int(args[1])
23 try:
24 obj = klass.objects.get(id=id)
25 except:
26 self.stdout.write("L'id %s n'existe pas pour le modèle %s dans DAE.\n" % \
27 (id, classname))
28 return
29
0d5def11 30
47d7067b
OL
31 copy = obj.importer()
32 self.stdout.write(u"\n[%s] DAE:%s => RH:%s\n" %
33 (obj.__class__.__name__, obj.id, copy.id))
0d5def11 34