]> git.siccegge.de Git - teilnehmertool.git/blobdiff - teilnehmertool.py
schaun ob abgemeldet im create_nametag
[teilnehmertool.git] / teilnehmertool.py
index 0408eb22ed886723ac792b4c7cb20c74736fd1b2..bda2774fca2b67cbb68fb005d20a52dccc73e286 100755 (executable)
@@ -10,6 +10,7 @@ import jinja2
 import os
 import os.path
 import re
+import sys
 
 conn = None
 
@@ -46,8 +47,8 @@ def import_teilnehmer(input):
                 continue
             if not int(row[0]) in ids:
                 print "Importing %s" % (row, )
-                conn.execute("INSERT INTO teilnehmer VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
-                             row[:-2] + ['Kein T-Shirt', 'Kein Pulli'] + row[-2:] + [0, 0, 0])
+                conn.execute("INSERT INTO teilnehmer VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
+                             row[:-2] + ['Kein T-Shirt', 'Kein Pulli'] + row[-2:] + [0, 0, 0, "", "false"])
 
     conn.commit()
 
@@ -150,27 +151,30 @@ def create_remind(outdir='output'):
                                                                                       preis, id])
     conn.commit()
 
+
 def create_nametag(outdir='output'):
     template = env.get_template('nametag.svg')
 
-    for vorname, nachname, namensschild, hochschule in \
-        conn.execute("SELECT vorname, nachname, namensschild, hochschule FROM teilnehmer"):
+    for teiln_id, vorname, nachname, namensschild, hochschule, dochned in \
+        conn.execute("SELECT id, vorname, nachname, namensschild, hochschule, dochned FROM teilnehmer"):
+
+        if dochned != "false":
+            print >> sys.stderr, "not generating %s %s (id %s), because abgemeldet" % (vorname, nachname, teiln_id)
+            continue
 
-        with open(os.path.join(outdir, "%s.svg" % namensschild), 'w') as f:
+        with open(os.path.join(outdir, "%s.svg" % teiln_id), 'w') as f:
             f.write(template.render(name=u"%s %s" % (vorname.decode('utf-8'),
                                                      nachname.decode('utf-8')),
                                     nick=namensschild.decode('utf-8'),
                                     uni1=hochschule.decode('utf-8')).encode('utf-8'))
 
 
-
 def create_teilnehmer_list(outdir = 'output'):
     template = env.get_template('teilnehmerliste.tex')
 
     teilnehmer = []
-    i = 1
-    for vor, nach, nick, hochschule, betrag, bezahlt, shirtsize, zippersize in \
-        conn.execute("SELECT vorname, nachname, namensschild, hochschule, betrag, bezahlt, tshirt, zipper FROM teilnehmer ORDER BY UPPER(nachname) ASC"):
+    for vor, nach, nick, hochschule, betrag, bezahlt, shirtsize, zippersize, dochned, comment in \
+        conn.execute("SELECT vorname, nachname, namensschild, hochschule, betrag, bezahlt, tshirt, zipper, dochned, orga_comment FROM teilnehmer ORDER BY UPPER(nachname) ASC"):
 
         vor = vor.decode('utf8')
         nach = nach.decode('utf8')
@@ -186,10 +190,17 @@ def create_teilnehmer_list(outdir = 'output'):
         if re.match("kein", zippersize, flags=re.IGNORECASE):
             zippersize = ""
 
-        teilnehmer.append({'vorname': vor, 'nachname': nach, 'num': i,
+        ## string to bool..
+        if dochned == "false":
+            will_attend = True
+        else:
+            will_attend = False
+        comment = comment.decode('utf8')
+
+        teilnehmer.append({'vorname': vor, 'nachname': nach,
             'hochschule': hochschule, 'nick': nick, 'betrag': betrag, 'bezahlt':
-            bezahlt, 'shirtsize': shirtsize, 'zippersize': zippersize})
-        i = i+1
+            bezahlt, 'shirtsize': shirtsize, 'zippersize': zippersize,
+            'will_attend': will_attend, 'comment': comment})
 
 
     with open(os.path.join(outdir, "teilnehmerliste.tex"), 'w') as out: