Example #1
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(),
                                 '')

        kwargs['application'] = serialize(application,
                                          posthook=format_application)
        kwargs['form_structure'] = application.licence_type.application_schema

        assessment = get_object_or_404(Assessment, pk=self.args[1])

        kwargs['assessment'] = serialize(assessment,
                                         post_hook=format_assessment)

        kwargs['other_assessments'] = serialize(Assessment.objects.filter(
            application=application).exclude(id=assessment.id).order_by('id'),
                                                posthook=format_assessment)

        kwargs['log_entry_form'] = ApplicationLogEntryForm(
            to=get_log_entry_to(application),
            fromm=self.request.user.get_full_name())

        return super(ViewReadonlyAssessorView, self).get_context_data(**kwargs)
Example #2
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(),
                                 '')

        kwargs['application'] = serialize(application,
                                          posthook=format_application)

        kwargs['assessments'] = serialize(
            Assessment.objects.filter(application=application),
            posthook=format_assessment)

        kwargs['payment_status'] = payment_utils.PAYMENT_STATUSES.get(
            payment_utils.get_application_payment_status(application))

        kwargs['log_entry_form'] = ApplicationLogEntryForm(
            to=get_log_entry_to(application),
            fromm=self.request.user.get_full_name())

        return super(ViewReadonlyOfficerView, self).get_context_data(**kwargs)
Example #3
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])
        assessment = get_object_or_404(Assessment, pk=self.args[1])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(), '')

        kwargs['application'] = serialize(application, posthook=format_application)
        kwargs['form_structure'] = application.licence_type.application_schema

        kwargs['assessment'] = serialize(assessment, post_hook=format_assessment)

        kwargs['other_assessments'] = serialize(Assessment.objects.filter(application=application).
                                                exclude(id=assessment.id).order_by('id'), posthook=format_assessment)

        assessors = [{'id': assessor.id, 'text': assessor.get_full_name()} for assessor in
                     assessment.assessor_group.members.all().order_by('first_name')]
        assessors.insert(0, {'id': 0, 'text': 'Unassigned'})

        kwargs['assessors'] = assessors

        kwargs['log_entry_form'] = ApplicationLogEntryForm(to=get_log_entry_to(application),
                                                           fromm=self.request.user.get_full_name())

        return super(EnterConditionsAssessorView, self).get_context_data(**kwargs)
Example #4
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)
Example #5
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = append_app_document_to_schema_data(
                application.licence_type.application_schema, application.data, application.hard_copy.file.url
            )

        convert_documents_to_url(
            application.licence_type.application_schema, application.data, application.documents.all()
        )

        kwargs["application"] = application

        if is_officer(self.request.user):
            kwargs["customer"] = application.applicant_profile.user

            if application.proxy_applicant is None:
                to = application.applicant_profile.user.email
            else:
                to = application.proxy_applicant.email

            kwargs["log_entry_form"] = CommunicationsLogEntryForm(to=to, fromm=self.request.user.email)

        return super(ViewReadonlyView, self).get_context_data(**kwargs)
Example #6
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(), '')

        kwargs['application'] = serialize(application, posthook=format_application)

        if is_officer(self.request.user):
            kwargs['customer'] = application.applicant

            kwargs['log_entry_form'] = ApplicationLogEntryForm(to=get_log_entry_to(application),
                                                               fromm=self.request.user.get_full_name())
        else:
            kwargs['payment_status'] = payment_utils.PAYMENT_STATUSES.get(payment_utils.
                                                                          get_application_payment_status(application))
        if application.processing_status == 'declined':
            message = "This application has been declined."
            details = ApplicationDeclinedDetails.objects.filter(application=application).first()
            if details and details.reason:
                message += "<br/>Reason:<br/>{}".format(details.reason.replace('\n', '<br/>'))
                kwargs['application']['declined_reason'] = details.reason
            messages.error(self.request, message)

        return super(ViewReadonlyView, self).get_context_data(**kwargs)
Example #7
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(), '')

        kwargs['application'] = serialize(application, posthook=format_application)
        kwargs['form_structure'] = application.licence_type.application_schema

        assessment = get_object_or_404(Assessment, pk=self.args[1])

        kwargs['assessment'] = serialize(assessment, post_hook=format_assessment,exclude=['application','applicationrequest_ptr'])

        kwargs['other_assessments'] = serialize(Assessment.objects.filter(application=application).
                                                exclude(id=assessment.id).order_by('id'), posthook=format_assessment,exclude=['application','applicationrequest_ptr'])

        kwargs['log_entry_form'] = ApplicationLogEntryForm(to=get_log_entry_to(application),
                                                           fromm=self.request.user.get_full_name())

        if application.processing_status == 'declined':
            message = "This application has been declined."
            details = ApplicationDeclinedDetails.objects.filter(application=application).first()
            if details and details.reason:
                message += "<br/>Reason:<br/>{}".format(details.reason.replace('\n', '<br/>'))
                kwargs['application']['declined_reason'] = details.reason
            messages.error(self.request, message)

        return super(ViewReadonlyAssessorView, self).get_context_data(**kwargs)
Example #8
0
    def _build_data(self, request, application):
        officers = [{'id': officer.id, 'text': render_user_name(officer)} for officer in get_all_officers()]
        officers.insert(0, {'id': 0, 'text': 'Unassigned'})

        current_ass_groups = [ass_request.assessor_group for ass_request in
                              Assessment.objects.filter(application=application)]

        ass_groups = [{'id': ass_group.id, 'text': ass_group.name} for ass_group in
                      AssessorGroup.objects.all().exclude(id__in=[ass_group.pk for ass_group in current_ass_groups])]

        # extract and format the previous lodgements of the application
        previous_lodgements = []
        for revision in revisions.get_for_object(application).filter(revision__comment='Details Modified').order_by(
                '-revision__date_created'):
            previous_lodgement = revision.object_version.object

            if previous_lodgement.hard_copy is not None:
                previous_lodgement.licence_type.application_schema, previous_lodgement.data = \
                    append_app_document_to_schema_data(previous_lodgement.licence_type.application_schema, previous_lodgement.data,
                                                       previous_lodgement.hard_copy.file.url)

            # reversion won't reference the previous many-to-many sets, only the latest one, so need to get documents as per below
            previous_lodgement_documents = Document.objects.filter(pk__in=revision.field_dict['documents'])

            convert_documents_to_url(previous_lodgement.licence_type.application_schema, previous_lodgement.data,
                                     previous_lodgement_documents)
            previous_lodgements.append({'lodgement_number': '{}-{}'.format(previous_lodgement.lodgement_number,
                                                                           previous_lodgement.lodgement_sequence),
                                        'date': formats.date_format(revision.revision.date_created, 'd/m/Y', True),
                                        'data': previous_lodgement.data})

        previous_application_returns_outstanding = False
        if application.previous_application is not None:
            previous_application_returns_outstanding = Return.objects.filter(licence=application.previous_application.licence).\
                exclude(status='accepted').exclude(status='submitted').exists()

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.licence_type.application_schema, application.data, application.documents.all())

        data = {
            'user': serialize(request.user),
            'application': serialize(application, posthook=format_application),
            'form_structure': application.licence_type.application_schema,
            'officers': officers,
            'amendment_requests': serialize(AmendmentRequest.objects.filter(application=application),
                                            posthook=format_amendment_request),
            'assessor_groups': ass_groups,
            'assessments': serialize(Assessment.objects.filter(application=application),
                                     posthook=format_assessment),
            'previous_versions': serialize(previous_lodgements),
            'returns_outstanding': previous_application_returns_outstanding,
            'csrf_token': str(csrf(request).get('csrf_token'))
        }

        return data
Example #9
0
    def get_context_data(self, **kwargs):
        application = utils.get_session_application(self.request.session)

        if application.review_status == 'awaiting_amendments':
            amendments = AmendmentRequest.objects.filter(application=application).filter(status='requested')
            kwargs['amendments'] = amendments

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

        kwargs['application'] = application

        return super(EnterDetailsView, self).get_context_data(**kwargs)
Example #10
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(), '')

        kwargs['application'] = serialize(application,posthook=format_application,
                                            related={
                                                'applicant': {'exclude': ['residential_address','postal_address','billing_address']},
                                                'applicant_profile':{'fields':['email','id','institution','name']},
                                                'previous_application':{'exclude':['applicant','applicant_profile','previous_application','licence']},
                                                'licence':{'related':{
                                                   'holder':{'exclude': ['residential_address','postal_address','billing_address']},
                                                   'issuer':{'exclude': ['residential_address','postal_address','billing_address']},
                                                   'profile':{'related': {'user': {'exclude': ['residential_address','postal_address','billing_address']}},
						       'exclude': ['postal_address']}
                                                   },'exclude':['holder','issuer','profile','licence_ptr']}
                                            })
        kwargs['form_structure'] = application.licence_type.application_schema

        assessment = get_object_or_404(Assessment, pk=self.args[1])

        kwargs['assessment'] = serialize(assessment, post_hook=format_assessment,exclude=['application','applicationrequest_ptr'],
                                                related={'assessor_group':{'related':{'members':{'exclude':['residential_address']}}},
                                                    'officer':{'exclude':['residential_address']},
                                                    'assigned_assessor':{'exclude':['residential_address']}})


        kwargs['other_assessments'] = serialize(Assessment.objects.filter(application=application).exclude(id=assessment.id).order_by('id'),
                                                posthook=format_assessment,exclude=['application','applicationrequest_ptr'],
                                                related={'assessor_group':{'related':{'members':{'exclude':['residential_address']}}},
                                                    'officer':{'exclude':['residential_address']},
                                                    'assigned_assessor':{'exclude':['residential_address']}})


        kwargs['log_entry_form'] = ApplicationLogEntryForm(to=get_log_entry_to(application),
                                                           fromm=self.request.user.get_full_name())

        if application.processing_status == 'declined':
            message = "This application has been declined."
            details = ApplicationDeclinedDetails.objects.filter(application=application).first()
            if details and details.reason:
                message += "<br/>Reason:<br/>{}".format(details.reason.replace('\n', '<br/>'))
                kwargs['application']['declined_reason'] = details.reason
            messages.error(self.request, message)

        return super(ViewReadonlyAssessorView, self).get_context_data(**kwargs)
Example #11
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])
        assessment = get_object_or_404(Assessment, pk=self.args[1])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(), '')

        #kwargs['application'] = serialize(application, posthook=format_application)
        kwargs['application'] = serialize(application,posthook=format_application,
                                            related={
                                                'applicant': {'exclude': ['residential_address','postal_address','billing_address']},
                                                'applicant_profile':{'fields':['email','id','institution','name']},
                                                'previous_application':{'exclude':['applicant','applicant_profile','previous_application','licence']},
                                                'licence':{'related':{
                                                   'holder':{'exclude': ['residential_address','postal_address','billing_address']},
                                                   'issuer':{'exclude': ['residential_address','postal_address','billing_address']},
                                                   'profile':{'related': {'user': {'exclude': ['residential_address','postal_address','billing_address']}},
						       'exclude': ['postal_address']}
                                                   },'exclude':['holder','issuer','profile','licence_ptr']}
                                            })
        kwargs['form_structure'] = application.licence_type.application_schema

        kwargs['assessment'] = serialize(assessment, post_hook=format_assessment,
                                            exclude=['application','applicationrequest_ptr'],
                                            related={'assessor_group':{'related':{'members':{'exclude':['residential_address']}}},
                                                'officer':{'exclude':['residential_address']},
                                                'assigned_assessor':{'exclude':['residential_address']}})

        kwargs['other_assessments'] = serialize(Assessment.objects.filter(application=application).
						exclude(id=assessment.id).order_by('id'),
                                                posthook=format_assessment,exclude=['application','applicationrequest_ptr'],
                                                related={'assessor_group':{'related':{'members':{'exclude':['residential_address']}}},
                                                    'officer':{'exclude':['residential_address']},
                                                    'assigned_assessor':{'exclude':['residential_address']}})

        assessors = [{'id': assessor.id, 'text': assessor.get_full_name()} for assessor in
                     assessment.assessor_group.members.all().order_by('first_name')]
        assessors.insert(0, {'id': 0, 'text': 'Unassigned'})

        kwargs['assessors'] = assessors

        kwargs['log_entry_form'] = ApplicationLogEntryForm(to=get_log_entry_to(application),
                                                           fromm=self.request.user.get_full_name())

        return super(EnterConditionsAssessorView, self).get_context_data(**kwargs)
Example #12
0
    def get_context_data(self, **kwargs):
        application = utils.get_session_application(self.request.session)

        if application.review_status == 'awaiting_amendments':
            amendments = AmendmentRequest.objects.filter(
                application=application).filter(status='requested')
            kwargs['amendments'] = amendments

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

        kwargs['application'] = application

        return super(EnterDetailsView, self).get_context_data(**kwargs)
Example #13
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')

        if application.review_status == 'awaiting_amendments':
            amendments = AmendmentRequest.objects.filter(application=application).filter(status='requested')
            kwargs['amendments'] = amendments

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

        kwargs['application'] = application

        return super(EnterDetailsView, self).get_context_data(**kwargs)
Example #14
0
    def get_context_data(self, **kwargs):
        application = utils.get_session_application(self.request.session)

        kwargs['is_payment_required'] = not is_licence_free(generate_product_title(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)
Example #15
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.licence_type.application_schema, application.data, application.documents.all())

        kwargs['application'] = serialize(application, posthook=format_application)
        kwargs['form_structure'] = application.licence_type.application_schema

        assessment = get_object_or_404(Assessment, pk=self.args[1])

        kwargs['assessment'] = assessment
        kwargs['action_url'] = reverse('wl_applications:submit_conditions_assessor', args=[application.pk, assessment.pk])

        return super(EnterConditionsAssessorView, self).get_context_data(**kwargs)
Example #16
0
    def get_context_data(self, **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')

        if application.review_status == 'awaiting_amendments':
            amendments = AmendmentRequest.objects.filter(
                application=application).filter(status='requested')
            kwargs['amendments'] = amendments

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

        kwargs['application'] = application

        return super(EnterDetailsView, self).get_context_data(**kwargs)
Example #17
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(), '')

        kwargs['application'] = serialize(application, posthook=format_application)
        kwargs['form_structure'] = application.licence_type.application_schema
        kwargs['assessments'] = serialize(Assessment.objects.filter(application=application), posthook=format_assessment)

        kwargs['log_entry_form'] = ApplicationLogEntryForm(to=get_log_entry_to(application), fromm=self.request.user.get_full_name())

        kwargs['payment_status'] = payment_utils.PAYMENT_STATUSES.get(payment_utils.
                                                                      get_application_payment_status(application))

        return super(EnterConditionsView, self).get_context_data(**kwargs)
Example #18
0
    def get_context_data(self, **kwargs):
        application = utils.get_session_application(self.request.session)

        kwargs['is_payment_required'] = not is_licence_free(generate_product_title(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)
Example #19
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(), '')

        kwargs['application'] = serialize(application,posthook=format_application,
                                            related={
                                                'applicant': {'exclude': ['residential_address','postal_address','billing_address']},
                                                'applicant_profile':{'fields':['email','id','institution','name']},
                                                'previous_application':{'exclude':['applicant','applicant_profile','previous_application','licence']},
                                                'licence':{'related':{
                                                   'holder':{'exclude': ['residential_address','postal_address','billing_address']},
                                                   'issuer':{'exclude': ['residential_address','postal_address','billing_address']},
                                                   'profile':{'related': {'user': {'exclude': ['residential_address','postal_address','billing_address']}},
						       'exclude': ['postal_address']}
                                                   },'exclude':['holder','issuer','profile','licence_ptr']}
                                            })

        kwargs['assessments'] = serialize(Assessment.objects.filter(application=application),
                                             posthook=format_assessment,exclude=['application','applicationrequest_ptr'],
                                             related={'assessor_group':{'related':{'members':{'exclude':['residential_address']}}},
                                                 'officer':{'exclude':['residential_address']},
                                                 'assigned_assessor':{'exclude':['residential_address']}})


        kwargs['payment_status'] = payment_utils.PAYMENT_STATUSES.get(payment_utils.
                                                                      get_application_payment_status(application))

        kwargs['log_entry_form'] = ApplicationLogEntryForm(to=get_log_entry_to(application),
                                                           fromm=self.request.user.get_full_name())

        if application.processing_status == 'declined':
            details = ApplicationDeclinedDetails.objects.filter(application=application).first()
            if details and details.reason:
                kwargs['application']['declined_reason'] = details.reason
        return super(ViewReadonlyOfficerView, self).get_context_data(**kwargs)
Example #20
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(), '')

        kwargs['application'] = serialize(application, posthook=format_application)

        if is_officer(self.request.user):
            kwargs['customer'] = application.applicant

            kwargs['log_entry_form'] = ApplicationLogEntryForm(to=get_log_entry_to(application), fromm=self.request.user.get_full_name())
        else:
            kwargs['payment_status'] = payment_utils.PAYMENT_STATUSES.get(payment_utils.
                                                                          get_application_payment_status(application))

        return super(ViewReadonlyView, self).get_context_data(**kwargs)
Example #21
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(),
                                 '')

        #kwargs['application'] = serialize(application, posthook=format_application)
        kwargs['application'] = serialize(
            application,
            posthook=format_application,
            related={
                'applicant': {
                    'exclude': [
                        'residential_address', 'postal_address',
                        'billing_address'
                    ]
                },
                'applicant_profile': {
                    'fields': ['email', 'id', 'institution', 'name']
                }
            })
        kwargs['form_structure'] = application.licence_type.application_schema
        kwargs['assessments'] = serialize(
            Assessment.objects.filter(application=application),
            posthook=format_assessment,
            exclude=['application', 'applicationrequest_ptr'])

        kwargs['log_entry_form'] = ApplicationLogEntryForm(
            to=get_log_entry_to(application),
            fromm=self.request.user.get_full_name())

        kwargs['payment_status'] = payment_utils.PAYMENT_STATUSES.get(
            payment_utils.get_application_payment_status(application))

        return super(EnterConditionsView, self).get_context_data(**kwargs)
Example #22
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(), '')

        kwargs['application'] = serialize(application,posthook=format_application,
                                            related={
                                                'applicant': {'exclude': ['residential_address','postal_address','billing_address']},
                                                'applicant_profile':{'fields':['email','id','institution','name']},
                                                'previous_application':{'exclude':['applicant','applicant_profile','previous_application','licence']},
                                                'licence':{'related':{
                                                   'holder':{'exclude': ['residential_address','postal_address','billing_address']},
                                                   'issuer':{'exclude': ['residential_address','postal_address','billing_address']},
                                                   'profile':{'related': {'user': {'exclude': ['residential_address','postal_address','billing_address']}},
						       'exclude': ['postal_address']}
                                                   },'exclude':['holder','issuer','profile','licence_ptr']}
                                            })

        if is_officer(self.request.user):
            kwargs['customer'] = application.applicant

            kwargs['log_entry_form'] = ApplicationLogEntryForm(to=get_log_entry_to(application),
                                                               fromm=self.request.user.get_full_name())
        else:
            kwargs['payment_status'] = payment_utils.PAYMENT_STATUSES.get(payment_utils.
                                                                          get_application_payment_status(application))
        if application.processing_status == 'declined':
            message = "This application has been declined."
            details = ApplicationDeclinedDetails.objects.filter(application=application).first()
            if details and details.reason:
                message += "<br/>Reason:<br/>{}".format(details.reason.replace('\n', '<br/>'))
                kwargs['application']['declined_reason'] = details.reason
            messages.error(self.request, message)

        return super(ViewReadonlyView, self).get_context_data(**kwargs)
Example #23
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])
        assessment = get_object_or_404(Assessment, pk=self.args[1])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(), '')

        kwargs['application'] = serialize(application, posthook=format_application)
        kwargs['form_structure'] = application.licence_type.application_schema

        kwargs['assessment'] = serialize(assessment, post_hook=format_assessment)

        kwargs['other_assessments'] = serialize(Assessment.objects.filter(application=application).
                                                exclude(id=assessment.id).order_by('id'), posthook=format_assessment)

        kwargs['log_entry_form'] = ApplicationLogEntryForm(to=get_log_entry_to(application), fromm=self.request.user.get_full_name())

        return super(EnterConditionsAssessorView, self).get_context_data(**kwargs)
Example #24
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.licence_type.application_schema,
                                 application.data, application.documents.all())

        kwargs['application'] = serialize(application, posthook=format_application)
        kwargs['form_structure'] = application.licence_type.application_schema
        kwargs['assessments'] = serialize(Assessment.objects.filter(application=application), posthook=format_assessment)
        kwargs['action_url'] = reverse('wl_applications:submit_conditions', args=[application.pk])

        if application.proxy_applicant is None:
            to = application.applicant_profile.user.get_full_name()
        else:
            to = application.proxy_applicant.get_full_name()

        kwargs['log_entry_form'] = CommunicationsLogEntryForm(to=to, fromm=self.request.user.get_full_name())

        return super(EnterConditionsView, self).get_context_data(**kwargs)
Example #25
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])
        assessment = get_object_or_404(Assessment, pk=self.args[1])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(),
                                 '')

        #kwargs['application'] = serialize(application, posthook=format_application)
        kwargs['application'] = serialize(
            application,
            posthook=format_application,
            related={
                'applicant': {
                    'exclude': [
                        'residential_address', 'postal_address',
                        'billing_address'
                    ]
                },
                'applicant_profile': {
                    'fields': ['email', 'id', 'institution', 'name']
                },
                'previous_application': {
                    'exclude': [
                        'applicant', 'applicant_profile',
                        'previous_application', 'licence'
                    ]
                },
                'licence': {
                    'related': {
                        'holder': {
                            'exclude': [
                                'residential_address', 'postal_address',
                                'billing_address'
                            ]
                        },
                        'issuer': {
                            'exclude': [
                                'residential_address', 'postal_address',
                                'billing_address'
                            ]
                        },
                        'profile': {
                            'related': {
                                'user': {
                                    'exclude': [
                                        'residential_address',
                                        'postal_address', 'billing_address'
                                    ]
                                }
                            },
                            'exclude': ['postal_address']
                        }
                    },
                    'exclude': ['holder', 'issuer', 'profile', 'licence_ptr']
                }
            })
        kwargs['form_structure'] = application.licence_type.application_schema

        kwargs['assessment'] = serialize(
            assessment,
            post_hook=format_assessment,
            exclude=['application', 'applicationrequest_ptr'],
            related={
                'assessor_group': {
                    'related': {
                        'members': {
                            'exclude': ['residential_address']
                        }
                    }
                },
                'officer': {
                    'exclude': ['residential_address']
                },
                'assigned_assessor': {
                    'exclude': ['residential_address']
                }
            })

        kwargs['other_assessments'] = serialize(
            Assessment.objects.filter(application=application).exclude(
                id=assessment.id).order_by('id'),
            posthook=format_assessment,
            exclude=['application', 'applicationrequest_ptr'],
            related={
                'assessor_group': {
                    'related': {
                        'members': {
                            'exclude': ['residential_address']
                        }
                    }
                },
                'officer': {
                    'exclude': ['residential_address']
                },
                'assigned_assessor': {
                    'exclude': ['residential_address']
                }
            })

        assessors = [{
            'id': assessor.id,
            'text': assessor.get_full_name()
        } for assessor in assessment.assessor_group.members.all().order_by(
            'first_name')]
        assessors.insert(0, {'id': 0, 'text': 'Unassigned'})

        kwargs['assessors'] = assessors

        kwargs['log_entry_form'] = ApplicationLogEntryForm(
            to=get_log_entry_to(application),
            fromm=self.request.user.get_full_name())

        return super(EnterConditionsAssessorView,
                     self).get_context_data(**kwargs)
Example #26
0
    def _build_data(self, request, application):
        officers = [{'id': officer.id, 'text': render_user_name(officer)} for officer in get_all_officers()]
        officers.insert(0, {'id': 0, 'text': 'Unassigned'})

        current_ass_groups = [ass_request.assessor_group for ass_request in
                              Assessment.objects.filter(application=application)]

        ass_groups = [{'id': ass_group.id, 'text': ass_group.name} for ass_group in
                      AssessorGroup.objects.all().exclude(id__in=[ass_group.pk for ass_group in current_ass_groups]).
                          order_by('name')]

        # extract and format the previous lodgements of the application
        previous_lodgements = []
        for revision in revisions.get_for_object(application).filter(revision__comment='Details Modified').order_by(
                '-revision__date_created'):
            previous_lodgement = revision.object_version.object

            if previous_lodgement.hard_copy is not None:
                previous_lodgement.licence_type.application_schema, previous_lodgement.data = \
                    append_app_document_to_schema_data(previous_lodgement.licence_type.application_schema,
                                                       previous_lodgement.data,
                                                       previous_lodgement.hard_copy.file.url)

            # reversion won't reference the previous many-to-many sets, only the latest one, so need to get documents as per below
            previous_lodgement_documents = Document.objects.filter(pk__in=revision.field_dict['documents'])

            convert_documents_to_url(previous_lodgement.data, previous_lodgement_documents, '')
            previous_lodgements.append({'lodgement_number': '{}-{}'.format(previous_lodgement.lodgement_number,
                                                                           previous_lodgement.lodgement_sequence),
                                        'date': formats.date_format(revision.revision.date_created, 'd/m/Y', True),
                                        'data': previous_lodgement.data})

        previous_application_returns_outstanding = False
        if application.previous_application is not None:
            previous_application_returns_outstanding = Return.objects.filter(
                licence=application.previous_application.licence). \
                exclude(status='accepted').exclude(status='submitted').exists()

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(), '')

        data = {
            'user': serialize(request.user),
            'application': serialize(application, posthook=format_application),
            'form_structure': application.licence_type.application_schema,
            'officers': officers,
            'amendment_requests': serialize(AmendmentRequest.objects.filter(application=application),
                                            posthook=format_amendment_request),
            'assessor_groups': ass_groups,
            'assessments': serialize(Assessment.objects.filter(application=application),
                                     posthook=format_assessment),
            'previous_versions': serialize(previous_lodgements),
            'returns_outstanding': previous_application_returns_outstanding,
            'payment_status': payment_utils.PAYMENT_STATUSES.get(payment_utils.
                                                                 get_application_payment_status(application)),
            'csrf_token': str(csrf(request).get('csrf_token'))
        }

        return data
Example #27
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(),
                                 '')

        kwargs['application'] = serialize(
            application,
            posthook=format_application,
            related={
                'applicant': {
                    'exclude': [
                        'residential_address', 'postal_address',
                        'billing_address'
                    ]
                },
                'applicant_profile': {
                    'fields': ['email', 'id', 'institution', 'name']
                },
                'previous_application': {
                    'exclude': [
                        'applicant', 'applicant_profile',
                        'previous_application', 'licence'
                    ]
                },
                'licence': {
                    'related': {
                        'holder': {
                            'exclude': [
                                'residential_address', 'postal_address',
                                'billing_address'
                            ]
                        },
                        'issuer': {
                            'exclude': [
                                'residential_address', 'postal_address',
                                'billing_address'
                            ]
                        },
                        'profile': {
                            'related': {
                                'user': {
                                    'exclude': [
                                        'residential_address',
                                        'postal_address', 'billing_address'
                                    ]
                                }
                            },
                            'exclude': ['postal_address']
                        }
                    },
                    'exclude': ['holder', 'issuer', 'profile', 'licence_ptr']
                }
            })
        kwargs['form_structure'] = application.licence_type.application_schema

        assessment = get_object_or_404(Assessment, pk=self.args[1])

        kwargs['assessment'] = serialize(
            assessment,
            post_hook=format_assessment,
            exclude=['application', 'applicationrequest_ptr'],
            related={
                'assessor_group': {
                    'related': {
                        'members': {
                            'exclude': ['residential_address']
                        }
                    }
                },
                'officer': {
                    'exclude': ['residential_address']
                },
                'assigned_assessor': {
                    'exclude': ['residential_address']
                }
            })

        kwargs['other_assessments'] = serialize(
            Assessment.objects.filter(application=application).exclude(
                id=assessment.id).order_by('id'),
            posthook=format_assessment,
            exclude=['application', 'applicationrequest_ptr'],
            related={
                'assessor_group': {
                    'related': {
                        'members': {
                            'exclude': ['residential_address']
                        }
                    }
                },
                'officer': {
                    'exclude': ['residential_address']
                },
                'assigned_assessor': {
                    'exclude': ['residential_address']
                }
            })

        kwargs['log_entry_form'] = ApplicationLogEntryForm(
            to=get_log_entry_to(application),
            fromm=self.request.user.get_full_name())

        if application.processing_status == 'declined':
            message = "This application has been declined."
            details = ApplicationDeclinedDetails.objects.filter(
                application=application).first()
            if details and details.reason:
                message += "<br/>Reason:<br/>{}".format(
                    details.reason.replace('\n', '<br/>'))
                kwargs['application']['declined_reason'] = details.reason
            messages.error(self.request, message)

        return super(ViewReadonlyAssessorView, self).get_context_data(**kwargs)
Example #28
0
    def get_context_data(self, **kwargs):
        application = get_object_or_404(Application, pk=self.args[0])

        if application.hard_copy is not None:
            application.licence_type.application_schema, application.data = \
                append_app_document_to_schema_data(application.licence_type.application_schema, application.data,
                                                   application.hard_copy.file.url)

        convert_documents_to_url(application.data, application.documents.all(),
                                 '')

        kwargs['application'] = serialize(
            application,
            posthook=format_application,
            related={
                'applicant': {
                    'exclude': [
                        'residential_address', 'postal_address',
                        'billing_address'
                    ]
                },
                'applicant_profile': {
                    'fields': ['email', 'id', 'institution', 'name']
                },
                'previous_application': {
                    'exclude': [
                        'applicant', 'applicant_profile',
                        'previous_application', 'licence'
                    ]
                },
                'licence': {
                    'related': {
                        'holder': {
                            'exclude': [
                                'residential_address', 'postal_address',
                                'billing_address'
                            ]
                        },
                        'issuer': {
                            'exclude': [
                                'residential_address', 'postal_address',
                                'billing_address'
                            ]
                        },
                        'profile': {
                            'related': {
                                'user': {
                                    'exclude': [
                                        'residential_address',
                                        'postal_address', 'billing_address'
                                    ]
                                }
                            },
                            'exclude': ['postal_address']
                        }
                    },
                    'exclude': ['holder', 'issuer', 'profile', 'licence_ptr']
                }
            })

        kwargs['assessments'] = serialize(
            Assessment.objects.filter(application=application),
            posthook=format_assessment,
            exclude=['application', 'applicationrequest_ptr'],
            related={
                'assessor_group': {
                    'related': {
                        'members': {
                            'exclude': ['residential_address']
                        }
                    }
                },
                'officer': {
                    'exclude': ['residential_address']
                },
                'assigned_assessor': {
                    'exclude': ['residential_address']
                }
            })

        kwargs['payment_status'] = payment_utils.PAYMENT_STATUSES.get(
            payment_utils.get_application_payment_status(application))

        kwargs['log_entry_form'] = ApplicationLogEntryForm(
            to=get_log_entry_to(application),
            fromm=self.request.user.get_full_name())

        if application.processing_status == 'declined':
            details = ApplicationDeclinedDetails.objects.filter(
                application=application).first()
            if details and details.reason:
                kwargs['application']['declined_reason'] = details.reason
        return super(ViewReadonlyOfficerView, self).get_context_data(**kwargs)