Repository: carpentries/amy

Issue:
Reduce number of required supporting insturctors from 2 to 1 for online workshops
to trigger the "introduction" email.



Discussion:

Resolving patch:
diff --git a/amy/autoemails/actions.py b/amy/autoemails/actions.py
--- a/amy/autoemails/actions.py
+++ b/amy/autoemails/actions.py
@@ -714,10 +714,10 @@ def check(event: Event):
             and not event.tags.filter(name__in=["cancelled", "unresponsive", "stalled"])
             # special "automated-email" tag
             and event.tags.filter(name__icontains="automated-email")
-            # roles: 1 host and 2+ instructors
+            # roles: 1 host and 2+ instructors, and perhaps 1+ supporting instr.
             and host
             and len(instructors) >= 2
-            and (online and len(supporting_instructors) >= 2 or not online)
+            and (online and len(supporting_instructors) >= 1 or not online)
         )
 
     def get_additional_context(self, objects, *args, **kwargs):
@@ -745,6 +745,8 @@ def get_additional_context(self, objects, *args, **kwargs):
         hosts = tasks.filter(role__name="host")
         instructors = tasks.filter(role__name="instructor")
         support = tasks.filter(role__name="supporting-instructor")
+        context["instructors"] = [instr.person for instr in instructors]
+        context["supporting_instructors"] = [instr.person for instr in support]
         context["host"] = hosts[0].person
         context["instructor1"] = instructors[0].person
         context["instructor2"] = instructors[1].person


Test patch:
diff --git a/amy/autoemails/tests/test_instructorshostintroductionaction.py b/amy/autoemails/tests/test_instructorshostintroductionaction.py
--- a/amy/autoemails/tests/test_instructorshostintroductionaction.py
+++ b/amy/autoemails/tests/test_instructorshostintroductionaction.py
@@ -144,20 +144,17 @@ def testCheckConditions(self):
         )
         self.assertEqual(InstructorsHostIntroductionAction.check(e), True)
 
-        # 8th case: for online require also 2 supporting instructors
+        # 8th case: for online require also 1 supporting instructor
         e.tags.add(Tag.objects.get(name="online"))
         self.assertEqual(InstructorsHostIntroductionAction.check(e), False)
         Task.objects.create(
             person=self.person4, role=self.supporting_instructor, event=e,
         )
-        Task.objects.create(
-            person=self.person5, role=self.supporting_instructor, event=e,
-        )
         self.assertEqual(InstructorsHostIntroductionAction.check(e), True)
 
-        # 9th case: for online, more than 2 supporting instructors should still work
+        # 9th case: for online, more than 1 supporting instructors should still work
         Task.objects.create(
-            person=self.person1, role=self.supporting_instructor, event=e,
+            person=self.person5, role=self.supporting_instructor, event=e,
         )
         self.assertEqual(InstructorsHostIntroductionAction.check(e), True)
 
@@ -210,8 +207,13 @@ def testContext(self):
             workshop_host=Organization.objects.first(),
             regional_coordinator_email=["admin-uk@carpentries.org"],
             host=host.person,
+            instructors=[instructor1.person, instructor2.person],
             instructor1=instructor1.person,
             instructor2=instructor2.person,
+            supporting_instructors=[
+                supporting_instructor1.person,
+                supporting_instructor2.person,
+            ],
             supporting_instructor1=supporting_instructor1.person,
             supporting_instructor2=supporting_instructor2.person,
             all_emails=[