-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into edit_project
# Conflicts: # frontend/src/i18n/locales/en.ts # frontend/src/i18n/locales/nl.ts # frontend/src/views/CreateProjectView.vue
- Loading branch information
Showing
55 changed files
with
6,649 additions
and
777 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
|
||
from sqlalchemy.ext.asyncio import AsyncSession | ||
from src.docker_tests.utils import submission_path | ||
import pathlib | ||
import zipfile | ||
import csv | ||
import io | ||
|
||
from src.submission.models import Status | ||
from src.submission.schemas import Submission | ||
from typing import Sequence | ||
|
||
from src.group.service import get_group_by_id | ||
from src.group.exceptions import GroupNotFound | ||
|
||
|
||
async def project_zip_stream(db: AsyncSession, submissions: Sequence[Submission], project_id): | ||
data = io.BytesIO() | ||
csvdata = io.StringIO() | ||
writer = csv.DictWriter(csvdata, fieldnames=[ | ||
"project", "group", "date", "status", "remarks", "stdout", "stderr"]) | ||
writer.writeheader() | ||
|
||
with zipfile.ZipFile(data, mode='w') as z: | ||
|
||
for submission in submissions: | ||
path = pathlib.Path(submission_path(submission.files_uuid, "")) | ||
|
||
group = await get_group_by_id(db, submission.group_id) | ||
|
||
if not group: | ||
raise GroupNotFound() | ||
|
||
writer.writerow({'project': submission.project_id, 'group': group.num, 'date': submission.date, 'status': Status( | ||
submission.status).name, 'remarks': submission.remarks, 'stdout': submission.stdout, 'stderr': submission.stderr}) | ||
|
||
for f_name in path.iterdir(): | ||
name = f"project_{ | ||
project_id}/group_{group.num}/{str(f_name).replace(str(path), "")}" | ||
z.write(f_name, arcname=name) | ||
|
||
z.writestr(f"project_{project_id}/submissions.csv", csvdata.getvalue()) | ||
|
||
data.seek(0) | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.