Esempio n. 1
0
    def post(self, request, *args, **kwargs):
        try:
            application = utils.get_session_application(self.request.session)
        except Exception as e:
            messages.error(self.request, str(e))
            return redirect('wl_applications:new_application')

        application.data = utils.create_data_from_form(
            application.licence_type.application_schema, request.POST,
            request.FILES)

        for f in request.FILES:
            if f == 'application_document':
                if application.hard_copy is None:
                    application.hard_copy = Document.objects.create(
                        name='hard_copy')
                application.hard_copy.file = request.FILES[f]
                application.hard_copy.save()
            else:
                # for legacy applications, need to check if there's a document where file is
                # named by the file name rather than the form field name
                try:
                    document = application.documents.get(
                        name=str(request.FILES[f]))
                except Document.DoesNotExist:
                    document = application.documents.get_or_create(name=f)[0]

                document.name = f
                document.file = request.FILES[f]

                document.save()

        application.save()

        if 'draft' in request.POST or 'draft_continue' in request.POST:
            application.customer_status = 'draft'

            # The processing status should only be set to 'draft' if the application hasn't been lodged
            if not application.lodgement_number:
                application.processing_status = 'draft'

            application.save()

            messages.warning(request, 'The application was saved to draft.')

            if 'draft' in request.POST:
                utils.delete_session_application(request.session)
                return redirect('wl_dashboard:home')
            else:
                return redirect('wl_applications:enter_details')
        else:
            return redirect('wl_applications:preview')
Esempio n. 2
0
    def post(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")

        application.data = utils.create_data_from_form(
            application.licence_type.application_schema, request.POST, request.FILES
        )

        for f in request.FILES:
            if f == "application_document":
                if application.hard_copy is None:
                    application.hard_copy = Document.objects.create(name="hard_copy")
                application.hard_copy.file = request.FILES[f]
                application.hard_copy.save()
            else:
                # for legacy applications, need to check if there's a document where file is
                # named by the file name rather than the form field name
                try:
                    document = application.documents.get(name=str(request.FILES[f]))
                except Document.DoesNotExist:
                    document = application.documents.get_or_create(name=f)[0]

                document.name = f
                document.file = request.FILES[f]

                document.save()

        application.save()

        if "draft" in request.POST or "draft_continue" in request.POST:
            application.customer_status = "draft"

            if application.processing_status != "renewal":
                application.processing_status = "draft"

            application.save()

            messages.warning(request, "The application was saved to draft.")

            if "draft" in request.POST:
                utils.delete_session_application(request.session)
                return redirect("wl_dashboard:home")
            else:
                return redirect("wl_applications:enter_details")
        else:
            return redirect("wl_applications:preview")
Esempio n. 3
0
    def post(self, request, *args, **kwargs):
        application = get_object_or_404(Application, pk=request.POST.get('applicationId'))

        if not (application.applicant == request.user or application.proxy_applicant == request.user):
            return HttpResponseForbidden('Application does not belong to user or proxy application')

        session_application_id = utils.get_session_application(request.session)

        if session_application_id.id == application.id:
            utils.delete_session_application(request.session)

            if application.is_temporary:
                application.delete()

        return HttpResponse()
Esempio n. 4
0
    def post(self, request, *args, **kwargs):
        application = utils.get_session_application(self.request.session)

        application.data = utils.create_data_from_form(application.licence_type.application_schema,
                                                       request.POST, request.FILES)

        for f in request.FILES:
            if f == 'application_document':
                if application.hard_copy is None:
                    application.hard_copy = Document.objects.create(name='hard_copy')
                application.hard_copy.file = request.FILES[f]
                application.hard_copy.save()
            else:
                document = Document.objects.create(name=f, file=request.FILES[f])
                document.save()
                # for legacy applications, need to check if there's a document where file is
                # named by the file name rather than the form field name
                try:
                    old_document = application.documents.get(name=str(request.FILES[f]))
                except Document.DoesNotExist:
                    old_document = application.documents.filter(name=f).first()

                if old_document is not None:
                    application.documents.remove(old_document)

                application.documents.add(document)

        application.save()

        if 'draft' in request.POST or 'draft_continue' in request.POST:
            application.customer_status = 'draft'

            # The processing status should only be set to 'draft' if the application hasn't been lodged
            if not application.lodgement_number:
                application.processing_status = 'draft'

            application.save()

            messages.warning(request, 'The application was saved to draft.')

            if 'draft' in request.POST:
                utils.delete_session_application(request.session)
                return redirect('wl_dashboard:home')
            else:
                return redirect('wl_applications:enter_details')
        else:
            return redirect('wl_applications:preview')
Esempio n. 5
0
    def post(self, request, *args, **kwargs):
        application = get_object_or_404(Application,
                                        pk=request.POST.get('applicationId'))

        if not (application.applicant == request.user
                or application.proxy_applicant == request.user):
            return HttpResponseForbidden(
                'Application does not belong to user or proxy application')

        session_application_id = utils.get_session_application(request.session)

        if session_application_id.id == application.id:
            utils.delete_session_application(request.session)

            if application.is_temporary:
                application.delete()

        return HttpResponse()
Esempio n. 6
0
    def get(self, request, *args, **kwargs):
        application = utils.get_session_application(self.request.session)

        application.lodgement_sequence += 1
        application.lodgement_date = datetime.now().date()

        if application.customer_status == 'amendment_required':
            # this is a 're-lodged' application after some amendment were required.
            # from this point we assume that all the amendments have been amended.
            AmendmentRequest.objects.filter(application=application).filter(
                status='requested').update(status='amended')
            application.review_status = 'amended'
            application.processing_status = 'ready_for_action'
        else:
            application.processing_status = 'new'

        application.customer_status = 'under_review'

        if not application.lodgement_number:
            application.lodgement_number = '%s-%s' % (
                str(application.licence_type.pk).zfill(LICENCE_TYPE_NUM_CHARS),
                str(application.pk).zfill(LODGEMENT_NUMBER_NUM_CHARS))

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

        application.save(version_user=application.applicant,
                         version_comment='Details Modified')

        context = {}

        context['application'] = application

        context['show_invoice'] = not is_licence_free(generate_product_title(application)) and \
            not application.application_type == 'amendment'

        delete_session_application(request.session)

        return render(request, self.template_name, context)
Esempio n. 7
0
    def get(self, request, *args, **kwargs):
        application = utils.get_session_application(self.request.session)

        # 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_title(application)) and \
            not application.application_type == 'amendment'

        delete_session_application(request.session)

        return render(request, self.template_name, context)
Esempio n. 8
0
    def get(self, request, *args, **kwargs):
        application = utils.get_session_application(self.request.session)

        application.lodgement_sequence += 1
        application.lodgement_date = datetime.now().date()

        if application.customer_status == 'amendment_required':
            # this is a 're-lodged' application after some amendment were required.
            # from this point we assume that all the amendments have been amended.
            AmendmentRequest.objects.filter(application=application).filter(status='requested').update(status='amended')
            application.review_status = 'amended'
            application.processing_status = 'ready_for_action'
        else :
            application.processing_status = 'new'

        application.customer_status = 'under_review'

        if not application.lodgement_number:
            application.lodgement_number = '%s-%s' % (str(application.licence_type.pk).zfill(LICENCE_TYPE_NUM_CHARS),
                                                      str(application.pk).zfill(LODGEMENT_NUMBER_NUM_CHARS))

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

        application.save(version_user=application.applicant, version_comment='Details Modified')

        context = {}

        context['application'] = application

        context['show_invoice'] = not is_licence_free(generate_product_title(application)) and \
            not application.application_type == 'amendment'

        delete_session_application(request.session)

        return render(request, self.template_name, context)
Esempio n. 9
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)
Esempio n. 10
0
    def get(self, request, *args, **kwargs):
        try:
            application = utils.get_session_application(self.request.session)
        except Exception as e:
            messages.error(self.request, str(e))
            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_title(application)) and \
            not application.is_licence_amendment

        delete_session_application(request.session)

        return render(request, self.template_name, context)