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 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