Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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