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:
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 @@
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(
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)
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)
|