From e335c3800f4a0565439785b81f6eed4e5c3d3d53 Mon Sep 17 00:00:00 2001 From: Piotr Banaszkiewicz Date: Tue, 17 Sep 2024 16:11:59 +0100 Subject: [PATCH 1/4] [#2703] Hide "instructors_post" workshop survey link field, relabel "instructors_pre" --- amy/templates/includes/event_details_table.html | 3 +-- amy/workshops/forms.py | 11 +++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/amy/templates/includes/event_details_table.html b/amy/templates/includes/event_details_table.html index 44b98872d..555a4fb69 100644 --- a/amy/templates/includes/event_details_table.html +++ b/amy/templates/includes/event_details_table.html @@ -20,8 +20,7 @@ Website URL:{{ event.website_url|default:"—"|urlize_newtab }} {% if event.url %}Validate event{% else %}Error{% endif %} Language:{{ event.language|default:"—" }} Eventbrite key:{% if event.reg_key %}{{ event.reg_key }}{% else %}—{% endif %} - Pre-workshop assessment survey for instructors{{ event.instructors_pre|default:"—"|urlize_newtab}} - Post-workshop assessment survey for instructors{{ event.instructors_post|default:"—"|urlize_newtab}} + Assessment survey for instructors:{{ event.instructors_pre|default:"—"|urlize_newtab}} Attendance: diff --git a/amy/workshops/forms.py b/amy/workshops/forms.py index 345176153..4b828322c 100644 --- a/amy/workshops/forms.py +++ b/amy/workshops/forms.py @@ -408,6 +408,15 @@ class EventForm(forms.ModelForm): required=False, ) + instructors_pre = forms.URLField( + label="Assessment survey for instructors:", + help_text=( + "Auto-generated as long as the event is NOT marked as complete and " + "it has a slug." + ), + required=False, + ) + helper = BootstrapHelper(add_cancel_button=False, duplicate_buttons_on_top=True) class Meta: @@ -438,7 +447,6 @@ class Meta: "lessons", "public_status", "instructors_pre", - "instructors_post", "comment", ] widgets = { @@ -486,7 +494,6 @@ def __init__(self, *args, **kwargs): "manual_attendance", "contact", "instructors_pre", - "instructors_post", Div( Div(HTML("Location details"), css_class="card-header"), Div( From 8dde830ae60260677da56fc3fb4df731709890ef Mon Sep 17 00:00:00 2001 From: Piotr Banaszkiewicz Date: Tue, 17 Sep 2024 16:12:25 +0100 Subject: [PATCH 2/4] [#2703] API v2: show value from "instructors_pre" field --- amy/api/v2/serializers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/amy/api/v2/serializers.py b/amy/api/v2/serializers.py index 11305ca21..5d05b0721 100644 --- a/amy/api/v2/serializers.py +++ b/amy/api/v2/serializers.py @@ -72,7 +72,9 @@ class EventSerializer(serializers.ModelSerializer): human_readable_date = serializers.CharField(read_only=True) eligible_for_instructor_recruitment = serializers.BooleanField(read_only=True) - workshop_reports_link = serializers.CharField(read_only=True) + workshop_reports_link = serializers.CharField( + read_only=True, source="instructors_pre" + ) main_tag = serializers.SerializerMethodField() class Meta: From 0eeae638557681a948e601e31be32d46c32655dd Mon Sep 17 00:00:00 2001 From: Piotr Banaszkiewicz Date: Tue, 17 Sep 2024 16:14:52 +0100 Subject: [PATCH 3/4] [#2703] Autogenerate and update workshop survey link --- amy/workshops/models.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/amy/workshops/models.py b/amy/workshops/models.py index ef3794b6f..110a794f8 100644 --- a/amy/workshops/models.py +++ b/amy/workshops/models.py @@ -1629,6 +1629,9 @@ def save(self, *args, **kwargs): self.latitude = None self.longitude = None + if self.slug and not self.completed: + self.instructors_pre = reports_link(self.slug) + super().save(*args, **kwargs) From e24db94a64232eae85cfc27f18e553e031d9a7b9 Mon Sep 17 00:00:00 2001 From: Piotr Banaszkiewicz Date: Tue, 17 Sep 2024 16:34:08 +0100 Subject: [PATCH 4/4] [#2703] Update a test --- amy/workshops/tests/test_event.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/amy/workshops/tests/test_event.py b/amy/workshops/tests/test_event.py index f4613e13b..532111995 100644 --- a/amy/workshops/tests/test_event.py +++ b/amy/workshops/tests/test_event.py @@ -1103,6 +1103,7 @@ def test_merging_basic_attributes(self): "longitude": self.event_a.longitude, "learners_pre": self.event_b.learners_pre, "learners_post": self.event_a.learners_post, + # Doesn't follow strategy, because it's refreshed with a slug from Event A: "instructors_pre": self.event_b.instructors_pre, "instructors_post": self.event_a.instructors_post, "learners_longterm": self.event_b.learners_longterm, @@ -1113,6 +1114,7 @@ def test_merging_basic_attributes(self): rv = self.client.post(self.url, data=self.strategy) self.assertEqual(rv.status_code, 302) self.event_b.refresh_from_db() + assertions["instructors_pre"] = self.event_b.instructors_pre # needs refresh for key, value in assertions.items(): self.assertEqual(getattr(self.event_b, key), value, key)