From 75571b855768c0d563fc2071ed56d2b9561441f2 Mon Sep 17 00:00:00 2001 From: mikaelGusse Date: Thu, 4 Apr 2024 13:03:07 +0300 Subject: [PATCH] Fix small issues with pseudonymization --- .../templates/exercise/_submission_info.html | 2 +- .../exercise/staff/_assessment_panel.html | 4 +--- .../templatetags/external_services.py | 1 - locale/en/LC_MESSAGES/django.po | 24 ++++++++++++++----- locale/fi/LC_MESSAGES/django.po | 20 ++++++++++++++-- userprofile/pseudonymize.py | 4 +++- 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/exercise/templates/exercise/_submission_info.html b/exercise/templates/exercise/_submission_info.html index 18d9d0606..4a9f71807 100644 --- a/exercise/templates/exercise/_submission_info.html +++ b/exercise/templates/exercise/_submission_info.html @@ -44,7 +44,7 @@

{% translate "SUBMISSION_INFO" %}

{{ submission.submitters.all|names }} {% endif %} {% else %} - Somebody + {% translate "PSEUDONYMIZED_SUBMITTERS" %} {% endif %} diff --git a/exercise/templates/exercise/staff/_assessment_panel.html b/exercise/templates/exercise/staff/_assessment_panel.html index f64b2bb22..0d547873f 100644 --- a/exercise/templates/exercise/staff/_assessment_panel.html +++ b/exercise/templates/exercise/staff/_assessment_panel.html @@ -15,9 +15,7 @@ ASSESSED_BY -- {{ user }}, {{ time }} {% endblocktranslate %} {% else %} - {% blocktranslate trimmed with user="Somebody" time=submission.grading_time %} - ASSESSED_BY -- {{ user }}, {{ time }} - {% endblocktranslate %} + {% translate 'ASSESSED_BY' %} -- {% translate 'SOMEBODY' %}, {{ submission.grading_time }} {% endif %} {% else %} diff --git a/external_services/templatetags/external_services.py b/external_services/templatetags/external_services.py index 06dcaeee0..3b13df5c0 100644 --- a/external_services/templatetags/external_services.py +++ b/external_services/templatetags/external_services.py @@ -1,5 +1,4 @@ import string - from django import template from lib.errors import TagUsageError diff --git a/locale/en/LC_MESSAGES/django.po b/locale/en/LC_MESSAGES/django.po index 894e2aaf2..362bfc43f 100644 --- a/locale/en/LC_MESSAGES/django.po +++ b/locale/en/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-20 17:06+0200\n" +"POT-Creation-Date: 2024-04-04 13:12+0300\n" "PO-Revision-Date: 2021-05-27 14:47+0300\n" "Last-Translator: Jimmy Ihalainen \n" "Language-Team: English<>\n" @@ -1017,11 +1017,6 @@ msgstr "Deadline deviations" msgid "SUBMISSION_DEVIATIONS" msgstr "Submission deviations" -#: exercise/templates/exercise/staff/results.html -#: exercise/templates/exercise/staff/analytics.html -msgid "PSEUDONYMIZATION_ERROR_MSG" -msgstr "This view is not available when pseudonymization is enabled!" - #: course/templates/course/_course_menu.html msgid "UNPSEUDONYMIZE" msgstr "Depseudonymize" @@ -4044,6 +4039,10 @@ msgstr "Submitted on" msgid "INCLUDES_LATE_PENALTY" msgstr "Includes late penalty" +#: exercise/templates/exercise/_submission_info.html +msgid "PSEUDONYMIZED_SUBMITTERS" +msgstr "Anonymous submitters" + #: exercise/templates/exercise/_submit_progress.html #: exercise/templates/exercise/exercise.html msgid "POSTING_SUBMISSION" @@ -4256,6 +4255,14 @@ msgstr "Results" msgid "ASSESSED_BY -- %(user)s, %(time)s" msgstr "Assessed by %(user)s, %(time)s" +#: exercise/templates/exercise/staff/_assessment_panel.html +msgid "ASSESSED_BY" +msgstr "Assessed by" + +#: exercise/templates/exercise/staff/_assessment_panel.html +msgid "SOMEBODY" +msgstr "Somebody" + #: exercise/templates/exercise/staff/_assessment_panel.html msgid "NOT_ASSESSED_MANUALLY" msgstr "Not assessed manually" @@ -4481,6 +4488,11 @@ msgstr "Latest submission time" msgid "NO_SUBMITTERS" msgstr "No submitters" +#: exercise/templates/exercise/staff/analytics.html +#: exercise/templates/exercise/staff/results.html +msgid "PSEUDONYMIZATION_ERROR_MSG" +msgstr "This view is not available when pseudonymization is enabled!" + #: exercise/templates/exercise/staff/analytics.html msgid "MODULE_SELECTION" msgstr "Module selection" diff --git a/locale/fi/LC_MESSAGES/django.po b/locale/fi/LC_MESSAGES/django.po index f26d3d95c..d67de0790 100644 --- a/locale/fi/LC_MESSAGES/django.po +++ b/locale/fi/LC_MESSAGES/django.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2024-01-20 17:06+0200\n" +"POT-Creation-Date: 2024-04-04 13:12+0300\n" "PO-Revision-Date: 2019-08-14 12:16+0200\n" "Last-Translator: Jimmy Ihalainen \n" "Language-Team: Finnish <>\n" @@ -1031,7 +1031,6 @@ msgstr "Pseudonymisointi pois päältä" msgid "PSEUDONYMIZE" msgstr "Pseudonymisointi päälle" - #: course/templates/course/_enroll_form.html msgid "ENROLL_THROUGH_SIS" msgstr "" @@ -4050,6 +4049,10 @@ msgstr "Palautushetki" msgid "INCLUDES_LATE_PENALTY" msgstr "Sisältää myöhästymissakon" +#: exercise/templates/exercise/_submission_info.html +msgid "PSEUDONYMIZED_SUBMITTERS" +msgstr "Anonymisoidut palauttajat" + #: exercise/templates/exercise/_submit_progress.html #: exercise/templates/exercise/exercise.html msgid "POSTING_SUBMISSION" @@ -4264,6 +4267,14 @@ msgstr "Tulokset" msgid "ASSESSED_BY -- %(user)s, %(time)s" msgstr "Arvostellut %(user)s, %(time)s" +#: exercise/templates/exercise/staff/_assessment_panel.html +msgid "ASSESSED_BY" +msgstr "Arvostellut" + +#: exercise/templates/exercise/staff/_assessment_panel.html +msgid "SOMEBODY" +msgstr "Joku" + #: exercise/templates/exercise/staff/_assessment_panel.html msgid "NOT_ASSESSED_MANUALLY" msgstr "Ei arvosteltu manuaalisesti" @@ -4490,6 +4501,11 @@ msgstr "Viimeisin palautusaika" msgid "NO_SUBMITTERS" msgstr "Ei palauttajia" +#: exercise/templates/exercise/staff/analytics.html +#: exercise/templates/exercise/staff/results.html +msgid "PSEUDONYMIZATION_ERROR_MSG" +msgstr "Tämä näkymä ei ole saatavilla kun pseudonymisointi on päällä!" + #: exercise/templates/exercise/staff/analytics.html msgid "MODULE_SELECTION" msgstr "Moduulin valinta" diff --git a/userprofile/pseudonymize.py b/userprofile/pseudonymize.py index 0dd3a74d2..1289d391c 100644 --- a/userprofile/pseudonymize.py +++ b/userprofile/pseudonymize.py @@ -1,5 +1,5 @@ import json -from random import choice +from random import seed, choice from faker import Faker import hashlib @@ -32,7 +32,9 @@ def format_user(user: User, pseudonymized: bool, user_profile: UserProfile = Non if pseudonymized: # Return formatted versions of the user's attributes and all the user class's methods if user_profile is not None: + Faker.seed(user_profile.student_id) user_profile.student_id = str(fake.random_int(min=10, max=10000)) + seed(user.first_name) user.first_name = choice(DATA["colors"])["name"] user.last_name = choice(DATA["animals"]) user.email = pseudonymize('email', user.email)