Commit 1decc077 authored by Martin Juhás's avatar Martin Juhás
Browse files

Merge branch '518-fix-incorrect-exercise-deletion-and-incorrect-log-export-query' into 'main'

Resolve "Fix incorrect exercise deletion and incorrect log export query"

See merge request inject/backend!455
parents 8b48dd62 728cdf61
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -510,8 +510,11 @@ class ExerciseManager:
            )

        # delete all uploaded files during the exercise, even ones that were not sent anywhere
        for file_info in FileInfo.objects.filter(exercise_id=exercise_id):
        file_infos = FileInfo.objects.filter(exercise_id=exercise_id)
        for file_info in file_infos:
            os.remove(os.path.join(settings.FILE_STORAGE, str(file_info.id)))
        # must be deleted manually, because the exercise_id field is not a real foreign key
        file_infos.delete()

        for email_participant in exercise.email_participants.all():
            email_participant.threads.all().delete()
+2 −1
Original line number Diff line number Diff line
@@ -140,7 +140,8 @@ class TeamLogSerializer:

    def copy_uploaded_files(self) -> None:
        for file_info in FileInfo.objects.filter(
            uploaded_by_id__in=self.team.users
            uploaded_by_id__in=self.team.users,
            exercise_id=self.team.exercise_id,
        ):
            shutil.copyfile(
                os.path.join(settings.FILE_STORAGE, str(file_info.id)),