Skip to content
Snippets Groups Projects
Commit 4961dd89 authored by Martin Mareš's avatar Martin Mareš
Browse files

Merge branch 'honza/fix5' into 'devel'

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

See merge request mj/mo-submit!50
parents dd5b2efe 46858364
Branches
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): ...@@ -45,7 +45,7 @@ def handle_download_submits(the_job: TheJob):
want_subdirs: bool = job.in_json['want_subdirs'] # type: ignore want_subdirs: bool = job.in_json['want_subdirs'] # type: ignore
sess = db.get_session() 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) .select_from(db.Paper)
.filter(db.Paper.paper_id.in_(ids)) .filter(db.Paper.paper_id.in_(ids))
.join(db.User, db.User.user_id == db.Paper.for_user) .join(db.User, db.User.user_id == db.Paper.for_user)
...@@ -61,7 +61,7 @@ def handle_download_submits(the_job: TheJob): ...@@ -61,7 +61,7 @@ def handle_download_submits(the_job: TheJob):
cnt = 0 cnt = 0
with zipfile.ZipFile(temp_file, mode='w') as zip: 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 cnt += 1
full_name = u.full_name() full_name = u.full_name()
ascii_name = (unicodedata.normalize('NFD', full_name) ascii_name = (unicodedata.normalize('NFD', full_name)
...@@ -70,7 +70,7 @@ def handle_download_submits(the_job: TheJob): ...@@ -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 = f'{task_code}_{cnt:04d}_{u.user_id}_{p.paper_id}_{ascii_name}.pdf'
fn = werkzeug.utils.secure_filename(fn) fn = werkzeug.utils.secure_filename(fn)
if want_subdirs: if want_subdirs:
fn = f'{place_code}/{fn}' fn = f'{place.get_code()}/{fn}'
logger.debug('Job: Přidávám %s', fn) logger.debug('Job: Přidávám %s', fn)
zip.write(filename=os.path.join(data_dir('submits'), p.file_name), zip.write(filename=os.path.join(data_dir('submits'), p.file_name),
arcname=fn) arcname=fn)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment