fu
This commit is contained in:
parent
a932cbb0af
commit
c53b89100a
@ -6,7 +6,11 @@ def main():
|
|||||||
db = DatabaseService("config.toml")
|
db = DatabaseService("config.toml")
|
||||||
db.init_db()
|
db.init_db()
|
||||||
|
|
||||||
|
user_id = input("Einzelticket ID:")
|
||||||
|
if user_id == "":
|
||||||
badges = db.get_user_badges()
|
badges = db.get_user_badges()
|
||||||
|
else:
|
||||||
|
badges = db.get_user_badges(int(user_id.strip()))
|
||||||
|
|
||||||
badge_generator = BadgeGeneratorService("config.toml")
|
badge_generator = BadgeGeneratorService("config.toml")
|
||||||
|
|
||||||
|
|||||||
13
output_badges/merge.py
Normal file
13
output_badges/merge.py
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import os
|
||||||
|
from subprocess import check_output, DEVNULL
|
||||||
|
|
||||||
|
from from_root import from_root
|
||||||
|
|
||||||
|
for file in os.listdir(from_root("output_badges")):
|
||||||
|
if file.endswith(".pdf"):
|
||||||
|
outfile_name = file.split(".pdf")[0]
|
||||||
|
outfile_name += "-print.pdf"
|
||||||
|
check_output(
|
||||||
|
["pdfjam", file, "--nup", "1x2", "--paper", "a4paper", "--noautoscale", "true", "--outfile", outfile_name],
|
||||||
|
stderr=DEVNULL
|
||||||
|
)
|
||||||
@ -24,7 +24,8 @@ class DatabaseService:
|
|||||||
cursorclass=pymysql.cursors.DictCursor)
|
cursorclass=pymysql.cursors.DictCursor)
|
||||||
logger.info("Connected to database.")
|
logger.info("Connected to database.")
|
||||||
|
|
||||||
def get_user_badges(self) -> List[Dict]:
|
def get_user_badges(self, user_id: Optional[int] = None) -> List[Dict]:
|
||||||
|
if user_id is None:
|
||||||
with self._conn.cursor() as cursor:
|
with self._conn.cursor() as cursor:
|
||||||
cursor.execute(
|
cursor.execute(
|
||||||
"""SELECT u.user_id, u.user_name, s.seat_id, upp.picture, tic.ticket_id
|
"""SELECT u.user_id, u.user_name, s.seat_id, upp.picture, tic.ticket_id
|
||||||
@ -37,5 +38,17 @@ class DatabaseService:
|
|||||||
ON u.user_id = tic.user;"""
|
ON u.user_id = tic.user;"""
|
||||||
)
|
)
|
||||||
user_badges = cursor.fetchall()
|
user_badges = cursor.fetchall()
|
||||||
|
else:
|
||||||
|
with self._conn.cursor() as cursor:
|
||||||
|
cursor.execute(
|
||||||
|
"""SELECT u.user_id, u.user_name, s.seat_id, upp.picture
|
||||||
|
FROM users AS u
|
||||||
|
LEFT JOIN seats AS s
|
||||||
|
ON u.user_id = s.`user`
|
||||||
|
LEFT JOIN user_profile_picture AS upp
|
||||||
|
ON u.user_id = upp.user_id
|
||||||
|
WHERE u.user_id = %s;""", (user_id,)
|
||||||
|
)
|
||||||
|
user_badges = cursor.fetchall()
|
||||||
logger.info(f"Got {len(user_badges)} user badges from database.")
|
logger.info(f"Got {len(user_badges)} user badges from database.")
|
||||||
return user_badges
|
return user_badges
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user