@method_decorator(login_required)<EOL><INDENT>def get(self, request):<DEDENT>
enterprise_customer_uuid = request.GET.get('<STR_LIT>')<EOL>success_url = request.GET.get('<STR_LIT>')<EOL>failure_url = request.GET.get('<STR_LIT>')<EOL>course_id = request.GET.get('<STR_LIT>', '<STR_LIT>')<EOL>program_uuid = request.GET.get('<STR_LIT>', '<STR_LIT>')<EOL>self.preview_mode = bool(request.GET.get('<STR_LIT>', False))<EOL>enterprise_customer = get_enterprise_customer_or_404(enterprise_customer_uuid)<EOL>context_data = get_global_context(request, enterprise_customer)<EOL>if not self.preview_mode:<EOL><INDENT>if not self.course_or_program_exist(course_id, program_uuid):<EOL><INDENT>error_code = '<STR_LIT>'<EOL>log_message = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>course_id=course_id,<EOL>program_uuid=program_uuid,<EOL>error_code=error_code,<EOL>userid=request.user.id,<EOL>enterprise_customer_uuid=enterprise_customer_uuid,<EOL>)<EOL>)<EOL>return render_page_with_error_code_message(request, context_data, error_code, log_message)<EOL><DEDENT>try:<EOL><INDENT>consent_record = get_data_sharing_consent(<EOL>request.user.username,<EOL>enterprise_customer_uuid,<EOL>program_uuid=program_uuid,<EOL>course_id=course_id<EOL>)<EOL><DEDENT>except NotConnectedToOpenEdX as error:<EOL><INDENT>error_code = '<STR_LIT>'<EOL>log_message = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>userid=request.user.id,<EOL>enterprise_customer_uuid=enterprise_customer_uuid,<EOL>error=error,<EOL>error_code=error_code,<EOL>course_id=course_id,<EOL>)<EOL>)<EOL>return render_page_with_error_code_message(request, context_data, error_code, log_message)<EOL><DEDENT>try:<EOL><INDENT>consent_required = consent_record.consent_required()<EOL><DEDENT>except AttributeError:<EOL><INDENT>consent_required = None<EOL><DEDENT>if consent_record is None or not consent_required:<EOL><INDENT>error_code = '<STR_LIT>'<EOL>log_message = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>userid=request.user.id,<EOL>enterprise_customer_uuid=enterprise_customer_uuid,<EOL>consent_record=consent_record,<EOL>consent_required=consent_required,<EOL>error_code=error_code,<EOL>course_id=course_id,<EOL>)<EOL>)<EOL>return render_page_with_error_code_message(request, context_data, error_code, log_message)<EOL><DEDENT>else:<EOL><INDENT>enterprise_customer = consent_record.enterprise_customer<EOL><DEDENT><DEDENT>elif not request.user.is_staff:<EOL><INDENT>raise PermissionDenied()<EOL><DEDENT>context_data = get_global_context(request, enterprise_customer)<EOL>if not (enterprise_customer_uuid and success_url and failure_url):<EOL><INDENT>error_code = '<STR_LIT>'<EOL>log_message = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>userid=request.user.id,<EOL>enterprise_customer_uuid=enterprise_customer_uuid,<EOL>success_url=success_url,<EOL>failure_url=failure_url,<EOL>error_code=error_code,<EOL>course_id=course_id,<EOL>)<EOL>)<EOL>return render_page_with_error_code_message(request, context_data, error_code, log_message)<EOL><DEDENT>try:<EOL><INDENT>updated_context_dict = self.get_course_or_program_context(<EOL>enterprise_customer,<EOL>course_id=course_id,<EOL>program_uuid=program_uuid<EOL>)<EOL>context_data.update(updated_context_dict)<EOL><DEDENT>except Http404:<EOL><INDENT>error_code = '<STR_LIT>'<EOL>log_message = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'.format(<EOL>error_code=error_code,<EOL>userid=request.user.id,<EOL>enterprise_customer=enterprise_customer.uuid,<EOL>course_id=course_id,<EOL>)<EOL>)<EOL>return render_page_with_error_code_message(request, context_data, error_code, log_message)<EOL><DEDENT>item = '<STR_LIT>' if course_id else '<STR_LIT>'<EOL>context_data.update({<EOL>'<STR_LIT>': _(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>).format(<EOL>enterprise_customer_name=enterprise_customer.name,<EOL>bold_start='<STR_LIT>',<EOL>bold_end='<STR_LIT>',<EOL>item=item,<EOL>),<EOL>'<STR_LIT>': _(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>).format(<EOL>enterprise_customer_name=enterprise_customer.name,<EOL>bold_start='<STR_LIT>',<EOL>bold_end='<STR_LIT>',<EOL>item=item,<EOL>),<EOL>'<STR_LIT>': success_url,<EOL>'<STR_LIT>': failure_url,<EOL>'<STR_LIT>': request.GET.get('<STR_LIT>') is not None,<EOL>'<STR_LIT>': [<EOL>_('<STR_LIT>').format(item=item),<EOL>_('<STR_LIT>'),<EOL>_('<STR_LIT>'),<EOL>],<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>})<EOL>platform_name = context_data['<STR_LIT>']<EOL>published_only = False if self.preview_mode else True<EOL>enterprise_consent_page = enterprise_customer.get_data_sharing_consent_text_overrides(<EOL>published_only=published_only<EOL>)<EOL>if enterprise_consent_page:<EOL><INDENT>context_data.update(self.get_context_from_db(enterprise_consent_page, platform_name, item, context_data))<EOL><DEDENT>else:<EOL><INDENT>context_data.update(self.get_default_context(enterprise_customer, platform_name))<EOL><DEDENT>return render(request, '<STR_LIT>', context=context_data)<EOL>
Render a form to collect user input about data sharing consent.