diff --git a/amy/trainings/tests/test_training_progress.py b/amy/trainings/tests/test_training_progress.py index 8dac3317c..8735fbba8 100644 --- a/amy/trainings/tests/test_training_progress.py +++ b/amy/trainings/tests/test_training_progress.py @@ -433,6 +433,50 @@ def test_notes(self): "Notes: Additional notes", ) + def test_notes_with_quotes(self): + self._test( + progress=TrainingProgress( + state="p", + trainee=self.ironman, + created_at=datetime(2016, 5, 1, 16, 00), + requirement=TrainingRequirement(name="Welcome Session"), + notes='Additional "notes"', + ), + expected="Passed Welcome Session
" + "on Sunday 01 May 2016 at 16:00.
" + "Notes: Additional "notes"", + ) + + def test_trainee_notes(self): + self._test( + progress=TrainingProgress( + state="p", + trainee=self.ironman, + created_at=datetime(2016, 5, 1, 16, 00), + requirement=TrainingRequirement(name="Get Involved"), + involvement_type=Involvement(name="Other"), + trainee_notes="Additional notes from trainee", + ), + expected="Passed Get Involved
" + "Other: Additional notes from trainee
" + "on Sunday 01 May 2016 at 16:00.", + ) + + def test_trainee_notes_with_quotes(self): + self._test( + progress=TrainingProgress( + state="p", + trainee=self.ironman, + created_at=datetime(2016, 5, 1, 16, 00), + requirement=TrainingRequirement(name="Get Involved"), + involvement_type=Involvement(name="Other"), + trainee_notes='Additional "notes" from trainee', + ), + expected="Passed Get Involved
" + "Other: Additional "notes" from trainee
" + "on Sunday 01 May 2016 at 16:00.", + ) + def test_no_mentor_or_examiner_assigned(self): self._test( progress=TrainingProgress( diff --git a/amy/workshops/templatetags/training_progress.py b/amy/workshops/templatetags/training_progress.py index e4c7a931a..8985f8a70 100644 --- a/amy/workshops/templatetags/training_progress.py +++ b/amy/workshops/templatetags/training_progress.py @@ -33,7 +33,9 @@ def progress_description(progress: TrainingProgress): involvement = "
" involvement += progress.involvement_type.name if progress.involvement_type.name == "Other": - involvement += f": {progress.trainee_notes or 'No details provided'}" + involvement += ( + f": {escape(progress.trainee_notes) or 'No details provided'}" + ) else: involvement = ""