Repository: carpentries/amy

Issue:
Move profile update to login instructions
This form should be deprecated: https://amy.software-carpentry.org/forms/update_profile/
The page should redirect to http://static.carpentries.org/instructors/
which includes a list to all our current instructors and instructions on how to update one's own profile.


Discussion:

Resolving patch:
diff --git a/extforms/urls.py b/extforms/urls.py
--- a/extforms/urls.py
+++ b/extforms/urls.py
@@ -12,12 +12,9 @@
     url(r'^dc/request/confirm/$', views.DCEventRequestConfirm.as_view(), name='dc_workshop_request_confirm'),
     url(r'^dc/request_selforganized/$', views.DCSelfOrganizedEventRequest.as_view(), name='dc_workshop_selforganized_request'),
     url(r'^dc/request_selforganized/confirm/$', views.DCSelfOrganizedEventRequestConfirm.as_view(), name='dc_workshop_selforganized_request_confirm'),
-    # an existing SWC workshop submission has been turned off
-    url(r'^submit/$', views.EventSubmission.as_view(), name='event_submit'),
-    # disabled as per @maneesha's request
-    # url(r'^submit/confirm/$', views.EventSubmissionConfirm.as_view(), name='event_submission_confirm'),
-    url(r'^update_profile/$', views.ProfileUpdateRequestView.as_view(), name='profileupdate_request'),
-    url(r'^update_profile/confirm/$', views.ProfileUpdateRequestConfirm.as_view(), name='profileupdate_request_confirm'),
     url(r'^request_training/$', views.TrainingRequestCreate.as_view(), name='training_request'),
     url(r'^request_training/confirm/$', views.TrainingRequestConfirm.as_view(), name='training_request_confirm'),
+    # forms below have been turned off:
+    url(r'^submit/$', views.EventSubmission.as_view(), name='event_submit'),
+    url(r'^update_profile/$', views.ProfileUpdateRequestView.as_view(), name='profileupdate_request'),
 ]
diff --git a/extforms/views.py b/extforms/views.py
--- a/extforms/views.py
+++ b/extforms/views.py
@@ -3,7 +3,7 @@
 from django.shortcuts import render
 from django.template.loader import get_template
 from django.urls import reverse_lazy
-from django.views.generic import TemplateView
+from django.views.generic import TemplateView, RedirectView
 
 from workshops.forms import (
     SWCEventRequestForm,
@@ -113,130 +113,23 @@ class DCEventRequestConfirm(SWCEventRequestConfirm):
     template_name = 'forms/workshop_dc_request_confirm.html'
 
 
-class ProfileUpdateRequestView(LoginNotRequiredMixin, EmailSendMixin,
-                           AMYCreateView):
-    model = ProfileUpdateRequest
-    form_class = ProfileUpdateRequestForm
-    page_title = 'Update Instructor Profile'
-    template_name = 'forms/profileupdate.html'
-    success_url = reverse_lazy('profileupdate_request_confirm')
-    email_fail_silently = False
-    email_kwargs = {
-        'to': settings.REQUEST_NOTIFICATIONS_RECIPIENTS,
-        'reply_to': None,
-    }
-
-    def get_success_message(self, *args, **kwargs):
-        """Don't display a success message."""
-        return ''
-
-    def get_context_data(self, **kwargs):
-        context = super().get_context_data(**kwargs)
-        context['title'] = self.page_title
-        return context
-
-    def get_subject(self):
-        subject = (
-            'New instructor profile update request: {name}, {affiliation}'
-        ).format(
-            name=self.object.get_full_name(),
-            affiliation=self.object.affiliation,
-        )
-        return subject
-
-    def get_body(self):
-        link = self.object.get_absolute_url()
-        link_domain = settings.SITE_URL
-
-        body_txt = get_template(
-            'mailing/profileupdaterequest.txt'
-        ).render({
-            'object': self.object,
-            'link': link,
-            'link_domain': link_domain,
-        })
-
-        body_html = get_template(
-            'mailing/profileupdaterequest.html'
-        ).render({
-            'object': self.object,
-            'link': link,
-            'link_domain': link_domain,
-        })
-        return body_txt, body_html
-
-    def form_valid(self, form):
-        """Send email to admins if the form is valid."""
-        data = form.cleaned_data
-        self.email_kwargs['reply_to'] = (data['email'], )
-        result = super().form_valid(form)
-        return result
-
-
-class ProfileUpdateRequestConfirm(LoginNotRequiredMixin, TemplateView):
-    """Display confirmation of received workshop request."""
-    template_name = 'forms/profileupdate_confirm.html'
-
-    def get_context_data(self, **kwargs):
-        context = super().get_context_data(**kwargs)
-        context['title'] = 'Thank you for updating your instructor profile'
-        return context
+# This form is disabled
+class ProfileUpdateRequestView(LoginNotRequiredMixin, RedirectView):
+    permanent = False
+    query_string = False
+    url = 'https://static.carpentries.org/instructors/'
 
 
-# This form is disabled as per @maneesha's request
-# class EventSubmission(LoginNotRequiredMixin, EmailSendMixin,
-#                       AMYCreateView):
+# This form is disabled
 class EventSubmission(LoginNotRequiredMixin, TemplateView):
     """Display form for submitting existing workshops."""
-    model = EventSubmissionModel
-    form_class = EventSubmitForm
     template_name = 'forms/event_submit.html'
-    success_url = reverse_lazy('event_submission_confirm')
-    email_fail_silently = False
-    email_kwargs = {
-        'to': settings.REQUEST_NOTIFICATIONS_RECIPIENTS,
-    }
-
-    def get_success_message(self, *args, **kwargs):
-        """Don't display a success message."""
-        return ''
 
     def get_context_data(self, **kwargs):
         context = super().get_context_data(**kwargs)
         context['title'] = 'Tell us about your workshop'
         return context
 
-    def get_subject(self):
-        return ('New workshop submission from {}'
-                .format(self.object.contact_name))
-
-    def get_body(self):
-        link = self.object.get_absolute_url()
-        link_domain = settings.SITE_URL
-        body_txt = get_template('mailing/eventsubmission.txt') \
-            .render({
-                'object': self.object,
-                'link': link,
-                'link_domain': link_domain,
-            })
-        body_html = get_template('mailing/eventsubmission.html') \
-            .render({
-                'object': self.object,
-                'link': link,
-                'link_domain': link_domain,
-            })
-        return body_txt, body_html
-
-
-class EventSubmissionConfirm(LoginNotRequiredMixin, TemplateView):
-    """Display confirmation of received workshop submission."""
-    template_name = 'forms/event_submission_confirm.html'
-
-    def get_context_data(self, **kwargs):
-        context = super().get_context_data(**kwargs)
-        context['title'] = 'Thanks for your submission'
-        return context
-
 
 class DCSelfOrganizedEventRequest(LoginNotRequiredMixin, EmailSendMixin,
                                   AMYCreateView):


Test patch:
diff --git a/workshops/test/test_action_required.py b/workshops/test/test_action_required.py
--- a/workshops/test/test_action_required.py
+++ b/workshops/test/test_action_required.py
@@ -82,7 +82,8 @@ def test_anonymous_user(self):
             reverse('dc_workshop_request'),
             reverse('dc_workshop_selforganized_request'),
             reverse('event_submit'),
-            reverse('profileupdate_request'),
+            # below always redirects, as it's been deprecated
+            # reverse('profileupdate_request'),
             reverse('training_request'),
             reverse('training_request_confirm'),
         ]
diff --git a/workshops/test/test_profile_update_request.py b/workshops/test/test_profile_update_request.py
--- a/workshops/test/test_profile_update_request.py
+++ b/workshops/test/test_profile_update_request.py
@@ -25,39 +25,6 @@ def setUp(self):
         self._setUpInstructors()
         self._setUpUsersAndLogin()
 
-    def test_request_added(self):
-        """Test if ProfileUpdateRequest is successfully added."""
-        data = {
-            'g-recaptcha-response': 'PASSED',  # to auto-pass RECAPTCHA
-            'personal': 'Harry', 'family': 'Potter',
-            'email': 'harry@potter.com', 'airport_iata': 'LON',
-            'affiliation': 'Auror at Ministry of Magic',
-            'occupation': '', 'occupation_other': 'Auror',
-            'github': 'hpotter', 'twitter': 'hpotter',
-            'orcid': '', 'website': '', 'gender': 'M',
-            'domains': [1, 2],  # IDs
-            'lessons': [1, 2],  # IDs
-            'privacy_consent': True,
-        }
-        rv = self.client.post(reverse('profileupdate_request'), data,
-            follow=True)
-        assert rv.status_code == 200
-        content = rv.content.decode('utf-8')
-        assert 'Fix errors below' not in content
-        assert \
-            'Thank you for updating your instructor profile' in content
-        assert ProfileUpdateRequest.objects.all().count() == 1
-        assert ProfileUpdateRequest.objects.all()[0].active is True
-
-        # check if an email was sent
-        self.assertEqual(len(mail.outbox), 1)
-        msg = mail.outbox[0]
-        self.assertEqual(
-            msg.subject,
-            'New instructor profile update request: Harry Potter, '
-            'Auror at Ministry of Magic',
-        )
-
     def test_request_discarded(self):
         """Ensure the request is discarded properly."""
         # add a minimal request