def get_context_data(self, **kwargs): licence_type = WildlifeLicenceType.objects.get(code_slug=self.args[0]) application = get_object_or_404(Application, pk=self.args[1]) if len(self.args) > 1 else None if utils.is_app_session_data_set(self.request.session, 'profile_pk'): profile = get_object_or_404(Profile, pk=utils.get_app_session_data(self.request.session, 'profile_pk')) else: profile = application.applicant_profile kwargs['licence_type'] = licence_type kwargs['profile'] = profile kwargs['structure'] = licence_type.application_schema kwargs['is_proxy_applicant'] = is_officer(self.request.user) if len(self.args) > 1: kwargs['application_pk'] = self.args[1] temp_files_dir = utils.get_app_session_data(self.request.session, 'temp_files_dir') if temp_files_dir is not None: temp_files_url = settings.MEDIA_URL + os.path.basename(os.path.normpath(temp_files_dir)) if utils.is_app_session_data_set(self.request.session, 'data'): data = utils.get_app_session_data(self.request.session, 'data') if temp_files_dir is not None: utils.prepend_url_to_files(licence_type.application_schema, data, temp_files_url) kwargs['data'] = data if utils.is_app_session_data_set(self.request.session, 'application_document'): application_document = utils.get_app_session_data(self.request.session, 'application_document') if temp_files_dir is not None: application_document = os.path.join(temp_files_url, application_document) kwargs['structure'], kwargs['data'] = utils.append_app_document_to_schema_data(kwargs['structure'], kwargs['data'], application_document) return super(PreviewView, self).get_context_data(**kwargs)
def get_context_data(self, **kwargs): application = get_object_or_404(Application, pk=self.args[1]) if len(self.args) > 1 else None licence_type = WildlifeLicenceType.objects.get(code_slug=self.args[0]) if utils.is_app_session_data_set(self.request.session, 'profile_pk'): profile = get_object_or_404(Profile, pk=utils.get_app_session_data(self.request.session, 'profile_pk')) else: profile = application.applicant_profile kwargs['licence_type'] = licence_type kwargs['profile'] = profile kwargs['structure'] = licence_type.application_schema kwargs['is_proxy_applicant'] = is_officer(self.request.user) if application is not None: kwargs['application_pk'] = application.pk if application.review_status == 'awaiting_amendments': amendments = AmendmentRequest.objects.filter(application=application).filter(status='requested') kwargs['amendments'] = amendments temp_files_dir = utils.get_app_session_data(self.request.session, 'temp_files_dir') if temp_files_dir is not None: temp_files_url = settings.MEDIA_URL + os.path.basename(os.path.normpath(temp_files_dir)) if utils.is_app_session_data_set(self.request.session, 'data'): data = utils.get_app_session_data(self.request.session, 'data') if temp_files_dir is not None: utils.prepend_url_to_files(licence_type.application_schema, data, temp_files_url) kwargs['data'] = data if utils.is_app_session_data_set(self.request.session, 'application_document'): application_document = utils.get_app_session_data(self.request.session, 'application_document') if temp_files_dir is not None: application_document = os.path.join(temp_files_url, application_document) kwargs['application_document'] = application_document return super(EnterDetailsView, self).get_context_data(**kwargs)