Exemplo n.º 1
0
    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
        """
        transmit_courses_metadata_form = TransmitEnterpriseCoursesForm(
            request.POST)

        # check that form data is well-formed
        if transmit_courses_metadata_form.is_valid():
            channel_worker_username = transmit_courses_metadata_form.cleaned_data[
                'channel_worker_username']

            # call `transmit_content_metadata` management command to trigger
            # transmission of enterprise courses metadata
            call_command('transmit_content_metadata',
                         '--catalog_user',
                         channel_worker_username,
                         enterprise_customer=customer_uuid)

            # Redirect to GET
            return HttpResponseRedirect('')

        return self.get_form_view(
            request,
            customer_uuid,
            additional_context={
                self.ContextParameters.TRANSMIT_COURSES_METADATA_FORM:
                transmit_courses_metadata_form
            })
Exemplo n.º 2
0
    def get(self, request, enterprise_customer_uuid):
        """
        Handle GET request - render "Transmit courses metadata" form.

        Arguments:
            request (django.http.request.HttpRequest): Request instance
            enterprise_customer_uuid (str): Enterprise Customer UUID

        Returns:
            django.http.response.HttpResponse: HttpResponse
        """
        context = self._build_context(request, enterprise_customer_uuid)
        transmit_courses_metadata_form = TransmitEnterpriseCoursesForm()
        context.update({self.ContextParameters.TRANSMIT_COURSES_METADATA_FORM: transmit_courses_metadata_form})

        return render(request, self.template, context)
Exemplo n.º 3
0
    def get(self, request, customer_uuid):
        """
        Handle GET request - render "Transmit courses metadata" 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.TRANSMIT_COURSES_METADATA_FORM:
                TransmitEnterpriseCoursesForm()
            })