Exemple #1
0
    def get_context_data(self, **kwargs):
        try:
            application = utils.get_session_application(self.request.session)
        except Exception as e:
            messages.error(self.request, e.message)
            return redirect("wl_applications:new_application")

        kwargs["is_payment_required"] = (
            not is_licence_free(generate_product_code(application))
            and not application.invoice_reference
            and is_customer(self.request.user)
        )

        if application.data:
            utils.convert_documents_to_url(application.data, application.documents.all(), "")

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = utils.append_app_document_to_schema_data(
                application.licence_type.application_schema, application.data, application.hard_copy.file.url
            )
        else:
            kwargs["data"] = application.data

        kwargs["application"] = application

        return super(PreviewView, self).get_context_data(**kwargs)
Exemple #2
0
    def get(self, request, *args, **kwargs):
        try:
            application = utils.get_session_application(self.request.session)
        except Exception as e:
            messages.error(self.request, e.message)
            return redirect('wl_applications:new_application')

        # update invoice reference if received, else keep the same
        application.invoice_reference = request.GET.get('invoice', application.invoice_reference)

        application.save()

        context = {}

        context['application'] = application

        context['show_invoice'] = not is_licence_free(generate_product_code(application)) and \
            not application.is_licence_amendment

        delete_session_application(request.session)

        return render(request, self.template_name, context)
Exemple #3
0
    def get(self, request, *args, **kwargs):
        try:
            application = utils.get_session_application(self.request.session)
        except Exception as e:
            messages.error(self.request, e.message)
            return redirect('wl_applications:new_application')

        # update invoice reference if received, else keep the same
        application.invoice_reference = request.GET.get(
            'invoice', application.invoice_reference)

        application.save()

        context = {}

        context['application'] = application

        context['show_invoice'] = not is_licence_free(generate_product_code(application)) and \
            not application.is_licence_amendment

        delete_session_application(request.session)

        return render(request, self.template_name, context)
Exemple #4
0
    def get(self, request, *args, **kwargs):
        application = get_object_or_404(Application, pk=args[0])
        product = get_product(generate_product_code(application))
        user = application.applicant.id

        error_url = request.build_absolute_uri(reverse('wl_applications:preview'))
        success_url = request.build_absolute_uri(reverse('wl_applications:complete'))

        parameters = {
            'system': PAYMENT_SYSTEM_ID,
            'basket_owner': user,
            'associateInvoiceWithToken': True,
            'checkoutWithToken': True,
            'fallback_url': error_url,
            'return_url': success_url,
            'forceRedirect': True,
            'template': 'wl/payment_information.html',
            'proxy': is_officer(request.user),
            "products": [
                {"id": product.id if product is not None else None}
            ],
            "vouchers": []
        }

        # senior discount
        if application.is_senior_offer_applicable:
            parameters['vouchers'].append({'code': SENIOR_VOUCHER_CODE})

        url = request.build_absolute_uri(
            reverse('payments:ledger-initial-checkout')
        )

        response = requests.post(url, headers=JSON_REQUEST_HEADER_PARAMS, cookies=request.COOKIES,
                                 data=json.dumps(parameters))

        return HttpResponse(response.content)
Exemple #5
0
    def get_context_data(self, **kwargs):
        try:
            application = utils.get_session_application(self.request.session)
        except Exception as e:
            messages.error(self.request, e.message)
            return redirect('wl_applications:new_application')

        kwargs['is_payment_required'] = not is_licence_free(generate_product_code(application)) and \
            not application.invoice_reference and is_customer(self.request.user)

        if application.data:
            utils.convert_documents_to_url(application.data,
                                           application.documents.all(), '')

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = utils.\
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)
        else:
            kwargs['data'] = application.data

        kwargs['application'] = application

        return super(PreviewView, self).get_context_data(**kwargs)