w.c.s : nouvelle version des outils de gestion hors-ligne
[progfou.git] / wcs / wcs-status.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3
4 import os
5 import sys
6
7 if len(sys.argv) != 3:
8 print >>sys.stderr, "Usage : %s <site> <formulaire>" % sys.argv[0]
9 sys.exit(1)
10 VHOST = sys.argv[1]
11 FORM_NAME = sys.argv[2]
12
13 PRINT_FORMAT = "%4s | %-17s | %-52s"
14 PRINT_HEADERS = PRINT_FORMAT % ('Num.', 'Statut', 'Utilisateur')
15 PRINT_BAR = "=" * len(PRINT_HEADERS)
16
17 from wcs import publisher
18 from wcs.formdef import FormDef
19
20 pub = publisher.WcsPublisher.create_publisher()
21 pub.app_dir = os.path.join(pub.app_dir, VHOST)
22
23 formdef = FormDef.get_by_urlname(FORM_NAME)
24
25 print PRINT_HEADERS
26 print PRINT_BAR
27
28 for object in formdef.data_class().select():
29 print PRINT_FORMAT % ('%04d' % object.id,
30 object.get_workflow_status().name,
31 '%s <%s>' % (object.user.display_name, object.user.email),
32 )
33
34 print PRINT_BAR