Repository: carpentries/amy

Issue:
Redisplay person record after approving instructor information
After I approve an instructor profile update request, I should see the person's record, not the list of other records waiting to be updated - I want to check that the information is correct.



Discussion:

Resolving patch:
diff --git a/workshops/forms.py b/workshops/forms.py
--- a/workshops/forms.py
+++ b/workshops/forms.py
@@ -520,9 +520,7 @@ class Meta(SWCEventRequestForm.Meta):
         }
 
 
-class ProfileUpdateRequestForm(forms.ModelForm):
-    captcha = ReCaptchaField()
-
+class ProfileUpdateRequestFormNoCaptcha(forms.ModelForm):
     class Meta:
         model = ProfileUpdateRequest
         exclude = ('active', 'created_at')
@@ -539,6 +537,10 @@ def clean_twitter(self):
         return re.sub('^@+', '', twitter_handle)
 
 
+class ProfileUpdateRequestForm(ProfileUpdateRequestFormNoCaptcha):
+    captcha = ReCaptchaField()
+
+
 class PersonLookupForm(forms.Form):
     person = selectable.AutoCompleteSelectField(
         lookup_class=lookups.PersonLookup,
diff --git a/workshops/urls.py b/workshops/urls.py
--- a/workshops/urls.py
+++ b/workshops/urls.py
@@ -85,6 +85,7 @@
     url(r'^profile_updates/$', views.AllProfileUpdateRequests.as_view(), name='all_profileupdaterequests'),
     url(r'^profile_updates/closed/$', views.AllClosedProfileUpdateRequests.as_view(), name='all_closed_profileupdaterequests'),
     url(r'^profile_update/(?P<request_id>\d+)/?$', views.profileupdaterequest_details, name='profileupdaterequest_details'),
+    url(r'^profile_update/(?P<request_id>\d+)/fix/?$', views.ProfileUpdateRequestFix.as_view(), name='profileupdaterequest_fix'),
     url(r'^profile_update/(?P<request_id>\d+)/discard/?$', views.profileupdaterequest_discard, name='profileupdaterequest_discard'),
     url(r'^profile_update/(?P<request_id>\d+)/accept/(?P<person_id>[\w\.-]+)/?$', views.profileupdaterequest_accept, name='profileupdaterequest_accept'),
     url(r'^update_profile/$', views.profileupdaterequest_create, name='profileupdate_request'),
diff --git a/workshops/views.py b/workshops/views.py
--- a/workshops/views.py
+++ b/workshops/views.py
@@ -59,7 +59,7 @@
     PersonTaskForm, HostForm, SWCEventRequestForm, DCEventRequestForm,
     ProfileUpdateRequestForm, PersonLookupForm, bootstrap_helper_wider_labels,
     SimpleTodoForm, bootstrap_helper_inline_formsets, BootstrapHelper,
-    AdminLookupForm,
+    AdminLookupForm, ProfileUpdateRequestFormNoCaptcha,
 )
 from workshops.util import (
     upload_person_task_csv,  verify_upload_person_task,
@@ -2019,6 +2019,15 @@ def profileupdaterequest_details(request, request_id):
     return render(request, 'workshops/profileupdaterequest.html', context)
 
 
+class ProfileUpdateRequestFix(LoginRequiredMixin, PermissionRequiredMixin,
+                              UpdateViewContext):
+    perms = 'workshops.change_profileupdaterequest'
+    model = ProfileUpdateRequest
+    form_class = ProfileUpdateRequestFormNoCaptcha
+    pk_url_kwarg = 'request_id'
+    template_name = 'workshops/generic_form.html'
+
+
 @login_required
 @permission_required('workshops.change_profileupdaterequest',
                      raise_exception=True)
@@ -2083,7 +2092,7 @@ def profileupdaterequest_accept(request, request_id, person_id):
 
     messages.success(request,
                      '{} was updated successfully.'.format(person_name))
-    return redirect(reverse('all_profileupdaterequests'))
+    return redirect(person.get_absolute_url())
 
 #------------------------------------------------------------
 


Test patch: