def _make_bound_form(self, email_or_username="******", course_id="course-v1:edX+DemoX+Demo_Course"): """ Builds bound ManageLearnersDataSharingConsentForm. """ form_data = { ManageLearnersForm.Fields.EMAIL_OR_USERNAME: email_or_username, ManageLearnersForm.Fields.COURSE: course_id, } return ManageLearnersDataSharingConsentForm( form_data, enterprise_customer=self.enterprise_customer)
def post(self, request, customer_uuid): """ Handle POST request - handle form submissions. Arguments: request (django.http.request.HttpRequest): Request instance customer_uuid (str): Enterprise Customer UUID """ manage_learners_dsc_form = ManageLearnersDataSharingConsentForm( request.POST, enterprise_customer=EnterpriseCustomer.objects.get( uuid=customer_uuid)) # check that form data is well-formed if manage_learners_dsc_form.is_valid(): delete_data_sharing_consent( manage_learners_dsc_form.cleaned_data[ ManageLearnersDataSharingConsentForm.Fields.COURSE], customer_uuid, manage_learners_dsc_form.cleaned_data[ ManageLearnersDataSharingConsentForm.Fields. EMAIL_OR_USERNAME]) messages.success( request, _("Successfully requested the Data Sharing consent from learner." )) return HttpResponseRedirect( reverse("admin:" + UrlNames.MANAGE_LEARNERS_DSC, args=(customer_uuid, ))) return self.get_form_view( request, customer_uuid, additional_context={ self.ContextParameters.MANAGE_LEARNERS_DSC_FORM: manage_learners_dsc_form })
def get(self, request, customer_uuid): """ Handle GET request - render "Request a DSC from Learner" form. Arguments: request (django.http.request.HttpRequest): Request instance customer_uuid (str): Enterprise Customer UUID Returns: django.http.response.HttpResponse: HttpResponse """ return self.get_form_view( request, customer_uuid, additional_context={ self.ContextParameters.MANAGE_LEARNERS_DSC_FORM: ManageLearnersDataSharingConsentForm() })