wip: Use ints as input

This commit is contained in:
Christian Cueni 2024-06-17 14:21:47 +02:00
parent 7356056baf
commit 0a9a4af5b2
4 changed files with 15 additions and 14 deletions

1
.gitignore vendored
View File

@ -46,7 +46,6 @@ coverage.xml
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:

View File

@ -0,0 +1,4 @@
/**
* Created by christiancueni on 17.06.2024.
* Copyright (c) 2024 ITerativ GmbH. All rights reserved.
*/

View File

@ -453,17 +453,15 @@ class ExportXlsTestCase(TestCase):
# supervisor sees all cs in region
supervisor = User.objects.get(id=TEST_SUPERVISOR1_USER_ID)
requested_cs_ids = [
str(TEST_COURSE_SESSION_ZURICH_ID),
str(TEST_COURSE_SESSION_BERN_ID),
TEST_COURSE_SESSION_ZURICH_ID,
TEST_COURSE_SESSION_BERN_ID,
]
allowed_csrs_ids = _get_course_sessions_with_roles_for_user(
supervisor, self.ALLOWED_ROLES, requested_cs_ids
)
self.assertCountEqual(
[int(cs) for cs in requested_cs_ids], [csr.id for csr in allowed_csrs_ids]
)
self.assertCountEqual(requested_cs_ids, [csr.id for csr in allowed_csrs_ids])
def test_student_cannot_export_data(self):
# student cannot export any data
@ -479,8 +477,8 @@ class ExportXlsTestCase(TestCase):
# trainer can only export cs where she is assigned
trainer = User.objects.get(email="test-trainer2@example.com")
requested_cs_ids = [
str(TEST_COURSE_SESSION_BERN_ID),
str(TEST_COURSE_SESSION_ZURICH_ID),
TEST_COURSE_SESSION_BERN_ID,
TEST_COURSE_SESSION_ZURICH_ID,
]
allowed_csrs_ids = _get_course_sessions_with_roles_for_user(
@ -494,7 +492,7 @@ class ExportXlsTestCase(TestCase):
def test_trainer_can_get_circles_where_expert(self):
trainer = User.objects.get(email="test-trainer2@example.com")
circle = Circle.objects.get(slug="test-lehrgang-lp-circle-fahrzeug")
requested_cs_ids = [str(TEST_COURSE_SESSION_ZURICH_ID)]
requested_cs_ids = [TEST_COURSE_SESSION_ZURICH_ID]
allowed_csrs_ids = _get_course_sessions_with_roles_for_user(
trainer, self.ALLOWED_ROLES, requested_cs_ids
@ -510,7 +508,7 @@ class ExportXlsTestCase(TestCase):
def test_trainer_cannot_get_circles_where_not_expert(self):
trainer = User.objects.get(email="test-trainer2@example.com")
circle = Circle.objects.get(slug="test-lehrgang-lp-circle-reisen")
requested_cs_ids = [str(TEST_COURSE_SESSION_ZURICH_ID)]
requested_cs_ids = [TEST_COURSE_SESSION_ZURICH_ID]
allowed_csrs_ids = _get_course_sessions_with_roles_for_user(
trainer, self.ALLOWED_ROLES, requested_cs_ids
@ -525,7 +523,7 @@ class ExportXlsTestCase(TestCase):
supervisor = User.objects.get(id=TEST_SUPERVISOR1_USER_ID)
circle_reisen = Circle.objects.get(slug="test-lehrgang-lp-circle-reisen")
circle_fahrzeug = Circle.objects.get(slug="test-lehrgang-lp-circle-fahrzeug")
requested_cs_ids = [str(TEST_COURSE_SESSION_ZURICH_ID)]
requested_cs_ids = [TEST_COURSE_SESSION_ZURICH_ID]
allowed_csrs_ids = _get_course_sessions_with_roles_for_user(
supervisor, self.ALLOWED_ROLES, requested_cs_ids

View File

@ -548,7 +548,7 @@ def export_attendance_as_xsl(request):
)
data = export_attendance(
[cs.id for cs in course_sessions_with_roles],
circle_ids=[int(circle_id) for circle_id in circle_ids],
circle_ids=circle_ids,
)
return _make_excel_response(data)
@ -562,7 +562,7 @@ def export_competence_certificate_as_xsl(request):
)
data = export_competence_certificates(
[cswr.id for cswr in course_sessions_with_roles],
circle_ids=[int(circle_id) for circle_id in circle_ids],
circle_ids=circle_ids,
)
return _make_excel_response(data)
@ -613,7 +613,7 @@ def _get_course_sessions_with_roles_for_user(
csr
for csr in get_course_sessions_with_roles_for_user(user)
if any(role in allowed_roles for role in csr.roles)
and str(csr.id) in requested_cs_ids
and csr.id in requested_cs_ids
] # noqa
return all_cs_roles_for_user