Skip to content
Snippets Groups Projects
Commit 46858364 authored by Jan Prachař's avatar Jan Prachař
Browse files

fix chybějících adresářů při stažení řešení celého kola

parent 957bee38
No related branches found
No related tags found
1 merge request!50fix chybějících adresářů při stažení řešení celého kola
......@@ -45,7 +45,7 @@ def handle_download_submits(the_job: TheJob):
want_subdirs: bool = job.in_json['want_subdirs'] # type: ignore
sess = db.get_session()
papers = (sess.query(db.Paper, db.User, db.Task.code, db.Place.code)
papers = (sess.query(db.Paper, db.User, db.Task.code, db.Place)
.select_from(db.Paper)
.filter(db.Paper.paper_id.in_(ids))
.join(db.User, db.User.user_id == db.Paper.for_user)
......@@ -61,7 +61,7 @@ def handle_download_submits(the_job: TheJob):
cnt = 0
with zipfile.ZipFile(temp_file, mode='w') as zip:
for p, u, task_code, place_code in papers:
for p, u, task_code, place in papers:
cnt += 1
full_name = u.full_name()
ascii_name = (unicodedata.normalize('NFD', full_name)
......@@ -70,7 +70,7 @@ def handle_download_submits(the_job: TheJob):
fn = f'{task_code}_{cnt:04d}_{u.user_id}_{p.paper_id}_{ascii_name}.pdf'
fn = werkzeug.utils.secure_filename(fn)
if want_subdirs:
fn = f'{place_code}/{fn}'
fn = f'{place.get_code()}/{fn}'
logger.debug('Job: Přidávám %s', fn)
zip.write(filename=os.path.join(data_dir('submits'), p.file_name),
arcname=fn)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment