def post(self): current_app.logger.debug('Attempting to load application') try: application = Application._schema().load(request.json) except MarshmallowError as e: raise BadRequest(e) if application.application_guid is not None: raise BadRequest( f'messageid: {application.messageid} already exists.') if application.applicant.clientid == application.submitter.clientid: application.submitter = application.applicant current_app.logger.debug('Attempting to load the mine') mine = Mine.find_by_mine_no(application.minenumber) if mine is None: raise BadRequest('Mine not found from the minenumber supplied.') application.mine = mine application.now_application_identity = NOWApplicationIdentity( mine=mine, mine_guid=mine.mine_guid, now_submission=application, now_number=NOWApplicationIdentity.create_now_number(mine)) current_app.logger.debug('Attempting to Save') application.save() return application, 201
def put(self, application_guid): now_application_identity = NOWApplicationIdentity.find_by_guid( application_guid) if not now_application_identity: raise NotFound('No identity record for this application guid.') if now_application_identity.now_application_id is None: raise NotImplemented( 'This application has not been imported. Please import an application before making changes.' ) data = request.json lead_inspector_party_guid = data.get('lead_inspector_party_guid', None) if lead_inspector_party_guid is not None: now_application_identity.now_application.lead_inspector_party_guid = lead_inspector_party_guid now_application_status_code = data.get('now_application_status_code', None) if now_application_status_code is not None and now_application_identity.now_application.now_application_status_code != now_application_status_code: now_application_identity.now_application.status_updated_date = datetime.today( ) if data.get('mine_guid', None): mine = Mine.find_by_mine_guid(data['mine_guid']) if not mine: raise BadRequest('mine not found') current_app.logger.info( f'Assigning {now_application_identity} to {mine}') now_application_identity.mine = mine now_application_identity.save() now_application_identity.now_application.deep_update_from_dict(data) return now_application_identity.now_application
def post(self, application_guid): now_application_identity = NOWApplicationIdentity.find_by_guid( application_guid) if not now_application_identity: raise NotFound('No identity record for this application guid.') return DocumentManagerService.initializeFileUploadWithDocumentManager( request, now_application_identity.mine, 'noticeofwork')
def post(self): data = self.parser.parse_args() mine = Mine.find_by_mine_guid(data['mine_guid']) permit = Permit.find_by_permit_guid(data['permit_guid']) err_str = '' if not mine: err_str += 'Mine not Found. ' if not permit: err_str += 'Permit not Found. ' if mine and not mine.major_mine_ind: err_str += 'Permit Applications can only be created on mines where major_mine_ind=True' if err_str: raise BadRequest(err_str) new_now = NOWApplicationIdentity(mine_guid=data['mine_guid'], permit=permit) new_now.now_application = NOWApplication( notice_of_work_type_code=data['notice_of_work_type_code'], now_application_status_code='REC', submitted_date=data['submitted_date'], received_date=data['received_date']) new_now.save() return new_now, 201
def get(self, application_guid): original = request.args.get('original', False, type=bool) now_application_identity = NOWApplicationIdentity.find_by_guid( application_guid) if not now_application_identity: raise NotFound('No identity record for this application guid.') if now_application_identity.now_application_id and not original: application = now_application_identity.now_application application.imported_to_core = True else: application = transmogrify_now(now_application_identity) application.imported_to_core = False return application
def post(self, application_guid): data = self.parser.parse_args() application_progress_status_code = data.get( 'application_progress_status_code') identity = NOWApplicationIdentity.find_by_guid(application_guid) if not identity.now_application: raise NotFound( 'There was no notice of work application found with the provided now_application_guid.' ) if not application_progress_status_code: raise BadRequest('application_progress_status_code is required') now_progress = NOWApplicationProgress.create( identity.now_application, application_progress_status_code) try: now_progress.save() except Exception as e: raise InternalServerError(f'Error when saving: {e}') return now_progress, 201
def post(self): try: application_nda = ApplicationNDA._schema().load(request.json) except MarshmallowError as e: raise BadRequest(e) if application_nda.application_nda_guid is not None: raise BadRequest( f'messageid: {application_nda.messageid} already exists.') if application_nda.applicant.clientid == application_nda.submitter.clientid: application_nda.submitter = application_nda.applicant mine = Mine.find_by_mine_no(application_nda.minenumber) if mine is None: raise BadRequest('Mine not found from the minenumber supplied.') application_nda.mine_guid = mine.mine_guid application_nda.nownumber = NOWApplicationIdentity.create_now_number( mine) application_nda.save() return application_nda, 201