diff --git a/backend/api/signals.py b/backend/api/signals.py index a1790662..f7e42d89 100644 --- a/backend/api/signals.py +++ b/backend/api/signals.py @@ -7,6 +7,7 @@ from api.models.student import Student from api.models.submission import (ExtraCheckResult, StateEnum, StructureCheckResult, Submission) +from api.models.teacher import Teacher from api.tasks.docker_image import (task_docker_image_build, task_docker_image_remove) from api.tasks.extra_check import task_extra_check_start @@ -35,8 +36,11 @@ def _user_creation(user: User, attributes: dict, **_): """Upon user creation, auto-populate additional properties""" student_id: str = cast(str, attributes.get("ugentStudentID")) - if student_id is not None: + if student_id is None: Student.create(user, student_id=student_id) + else: + # For now, we assume that everyone without a student ID is a teacher. + Teacher.create(user) @receiver(run_docker_image_build) diff --git a/backend/api/tasks/docker_image.py b/backend/api/tasks/docker_image.py index 73946f60..b4a1eb9f 100644 --- a/backend/api/tasks/docker_image.py +++ b/backend/api/tasks/docker_image.py @@ -21,7 +21,7 @@ def task_docker_image_build(docker_image: DockerImage): client.images.build(path=MEDIA_ROOT, dockerfile=docker_image.file.path, tag=get_docker_image_tag(docker_image), rm=True, quiet=True, forcerm=True) docker_image.state = StateEnum.READY - except Exception: + except (docker.errors.BuildError, docker.errors.APIError): docker_image.state = StateEnum.ERROR notification_type = NotificationType.DOCKER_IMAGE_BUILD_ERROR finally: diff --git a/backend/api/views/user_view.py b/backend/api/views/user_view.py index 413a975c..b4ae6c93 100644 --- a/backend/api/views/user_view.py +++ b/backend/api/views/user_view.py @@ -86,7 +86,7 @@ def notifications(self, request: Request, pk: str): # Get the notifications for the user notifications = Notification.objects.filter(user=pk, is_read=False).order_by("-created_at") - if 0 < notifications.count() < count: + if notifications.count() < count: notifications = list(notifications) + list( Notification.objects.filter(user=pk, is_read=True).order_by("-created_at")[:count - notifications.count()] ) diff --git a/frontend/src/components/projects/groups/GroupsManageTable.vue b/frontend/src/components/projects/groups/GroupsManageTable.vue index 7dbc59b4..c254e66f 100644 --- a/frontend/src/components/projects/groups/GroupsManageTable.vue +++ b/frontend/src/components/projects/groups/GroupsManageTable.vue @@ -2,7 +2,7 @@ import DataTable, { type DataTableRowExpandEvent } from 'primevue/datatable'; import Column from 'primevue/column'; import AllSubmission from '@/components/submissions/AllSubmission.vue'; -import InputNumber from 'primevue/inputnumber'; +import InputNumber, { InputNumberBlurEvent } from 'primevue/inputnumber'; import { type Project } from '@/types/Project.ts'; import { useStudents } from '@/composables/services/student.service.ts'; import { ref } from 'vue'; @@ -35,7 +35,7 @@ const editingGroup = ref(); * @param group The group to update. * @param score The new score. */ -function updateGroupScore(group: Group, score: number): void { +function updateGroupScore(group: Group, score: number|string): void { emit('update:group-score', group, score); editingGroup.value = null; } @@ -79,7 +79,7 @@ async function expandGroup(event: DataTableRowExpandEvent): Promise {