Repository: carpentries/amy

Issue:
Remove option for open training application
We are no longer running the open training application so we should remove this option from AMY.

This includes:

- [ ] remove text about open training at top of form (amy/templates/forms/trainingrequest.html)
- [ ] remove open training info from form submission email (amy/templates/mailing/training_request.html and amy/templates/mailing/training_request.txt)
- [ ] fix UI at top of form to only have "Profile Creation" as an option (so no accordion expanding needed - should be expanded by default; "Application type" text is no longer needed; radio button is not needed)  

We could also remove the `review_process` field from the `TrainingRequest` model. However, keeping it in may make it easier if we decide to go back to having different types of training applications.
 



Discussion:
@pbanaszkiewicz suggests a rework of the accordion.  Instead of application type, we only have the registration code/url display.  On the back end, we can still have the options, but have them hidden.  
Suggested release: sooner than 4.3
Remove the first sentence from this text:

> ~Use this if you have been invited to apply through an institutional membership or other agreement with The Carpentries.~ Please note your application materials and information about your progress towards The Carpentries Instructor certification may be shared with our contacts at your member site.

Resolving patch:
diff --git a/amy/extforms/forms.py b/amy/extforms/forms.py
--- a/amy/extforms/forms.py
+++ b/amy/extforms/forms.py
@@ -42,12 +42,11 @@ class TrainingRequestForm(forms.ModelForm):
     class Meta:
         model = TrainingRequest
         fields = (
-            "review_process",
+            "personal",
+            "family",
             "member_code",
             "member_code_override",
             "eventbrite_url",
-            "personal",
-            "family",
             "email",
             "secondary_email",
             "github",
@@ -82,7 +81,6 @@ class Meta:
             "code_of_conduct_agreement",
         )
         widgets = {
-            "review_process": forms.RadioSelect(),
             "occupation": RadioSelectWithOther("occupation_other"),
             "domains": CheckboxSelectMultipleWithOthers("domains_other"),
             "underrepresented": forms.RadioSelect(),
@@ -120,7 +118,6 @@ def __init__(self, *args, **kwargs):
 
         self.set_other_fields(self.helper.layout)
         self.set_fake_required_fields()
-        self.set_accordion(self.helper.layout)
         self.set_display_member_code_override(visible=False)
         self.set_hr(self.helper.layout)
 
@@ -152,6 +149,8 @@ def set_fake_required_fields(self) -> None:
         self["member_code"].field.widget.fake_required = True  # type: ignore
 
     def set_accordion(self, layout: Layout) -> None:
+        # Note: not used since 2024-03-19 (#2617).
+
         # special accordion display for the review process
         self["review_process"].field.widget.subfields = {  # type: ignore
             "preapproved": [
@@ -268,21 +267,25 @@ def clean(self):
         super().clean()
         errors = dict()
 
+        # Since 2024-03-19 (#2617) we don't allow open training applications. All
+        # applications are by default pre-approved.
+        review_process = self.cleaned_data.get("review_process", "preapproved")
+        self.instance.review_process = review_process
+
         # 1: validate registration code
-        review_process = self.cleaned_data.get("review_process", "")
         member_code = self.cleaned_data.get("member_code", "").split()
 
         # it's required when review_process is 'preapproved', but not when
         # 'open'
         if review_process == "preapproved" and not member_code:
-            errors["review_process"] = ValidationError(
+            errors["member_code"] = ValidationError(
                 "Registration code is required for pre-approved training "
                 "review process."
             )
 
         # it's required to be empty when review_process is 'open'
         if review_process == "open" and member_code:
-            errors["review_process"] = ValidationError(
+            errors["member_code"] = ValidationError(
                 "Registration code must be empty for open training review process."
             )
 


Test patch:
diff --git a/amy/extforms/tests/test_training_request_form.py b/amy/extforms/tests/test_training_request_form.py
--- a/amy/extforms/tests/test_training_request_form.py
+++ b/amy/extforms/tests/test_training_request_form.py
@@ -1,4 +1,5 @@
 from datetime import date, timedelta
+from unittest import skip
 
 from django.conf import settings
 from django.core import mail
@@ -160,7 +161,7 @@ def test_review_process_validation__preapproved_code_empty(self):
         """Shouldn't pass when review_process requires member_code."""
         # Arrange
         data = {
-            "review_process": "preapproved",
+            # "review_process": "preapproved",
             "member_code": "",
         }
 
@@ -179,6 +180,7 @@ def test_review_process_validation__preapproved_code_empty(self):
             HiddenInput,
         )
 
+    @skip("Since 2024-03-19 (#2617) we don't allow open training requests.")
     @override_settings(FLAGS={"ENFORCE_MEMBER_CODES": [("boolean", False)]})
     def test_review_process_validation__open_code_nonempty(self):
         """Shouldn't pass when review_process requires *NO* member_code."""