def hackathon_online(self, hackathon): req = ok() if hackathon.status == HACK_STATUS.DRAFT or hackathon.status == HACK_STATUS.OFFLINE or hackathon.status == HACK_STATUS.APPLY_ONLINE: if self.util.is_local() or hackathon.config.get( 'cloud_provider') == CLOUD_PROVIDER.NONE: req = ok() elif hackathon.config.get( 'cloud_provider') == CLOUD_PROVIDER.AZURE: is_success = docker_host_manager.check_subscription_id( hackathon.id) if not is_success: req = general_error(code=HTTP_CODE.AZURE_KEY_NOT_READY ) # azure sub id is invalide elif hackathon.status == HACK_STATUS.ONLINE: req = ok() else: req = general_error(code=HTTP_CODE.CREATE_NOT_FINISHED) if req.get('error') is None: hackathon.status = HACK_STATUS.ONLINE hackathon.save() self.create_hackathon_notice( hackathon.id, HACK_NOTICE_EVENT.HACK_ONLINE, HACK_NOTICE_CATEGORY.HACKATHON) # hackathon online return req
def hackathon_offline(self, hackathon): req = ok() if hackathon.status == HACK_STATUS.ONLINE or hackathon.status == HACK_STATUS.DRAFT: hackathon.status = HACK_STATUS.OFFLINE hackathon.save() elif hackathon.status == HACK_STATUS.INIT: req = general_error(code=HTTP_CODE.CREATE_NOT_FINISHED) return req
def hackathon_offline(self, hackathon): req = ok() if hackathon.status == HACK_STATUS.ONLINE or hackathon.status == HACK_STATUS.DRAFT or hackathon.status == HACK_STATUS.APPLY_ONLINE: hackathon.status = HACK_STATUS.OFFLINE hackathon.save() self.create_hackathon_notice(hackathon.id, HACK_NOTICE_EVENT.HACK_OFFLINE, HACK_NOTICE_CATEGORY.HACKATHON) # hackathon offline elif hackathon.status == HACK_STATUS.INIT: req = general_error(code=HTTP_CODE.CREATE_NOT_FINISHED) return req
def hackathon_online(self, hackathon): req = ok() if hackathon.status == HACK_STATUS.DRAFT or hackathon.status == HACK_STATUS.OFFLINE: if self.util.is_local() or hackathon.config.cloud_provide == CLOUD_PROVIDER.NONE: req = ok() elif hackathon.config.cloud_provider == CLOUD_PROVIDER.AZURE: is_success = docker_host_manager.check_subscription_id(hackathon.id) if not is_success: req = general_error(code=HTTP_CODE.AZURE_KEY_NOT_READY) # azure sub id is invalide elif hackathon.status == HACK_STATUS.ONLINE: req = ok() else: req = general_error(code=HTTP_CODE.CREATE_NOT_FINISHED) if req.get('error') is None: hackathon.status = HACK_STATUS.ONLINE hackathon.save() return req
def hackathon_offline(self, hackathon): req = ok() if hackathon.status == HACK_STATUS.ONLINE or hackathon.status == HACK_STATUS.DRAFT or hackathon.status == HACK_STATUS.APPLY_ONLINE: hackathon.status = HACK_STATUS.OFFLINE hackathon.save() self.create_hackathon_notice( hackathon.id, HACK_NOTICE_EVENT.HACK_OFFLINE, HACK_NOTICE_CATEGORY.HACKATHON) # hackathon offline elif hackathon.status == HACK_STATUS.INIT: req = general_error(code=HTTP_CODE.CREATE_NOT_FINISHED) return req
def hackathon_offline(self, hackathon): req = ok() if hackathon.status == HackathonStatus.ONLINE or hackathon.status == HackathonStatus.DRAFT or hackathon.status == HackathonStatus.APPLY_ONLINE: hackathon.status = HackathonStatus.OFFLINE hackathon.save() self.create_hackathon_notice( hackathon.id, HackathonNotifyEvent.HACK_OFFLINE, HackathonNotifyCategory.HACKATHON) # hackathon offline elif hackathon.status == HackathonStatus.INIT: req = general_error(code=HTTP_CODE.CREATE_NOT_FINISHED) return req
def apply_online_hackathon(self, hackathon): """apply for onlining a hackathon, should be called by the hackathon creator :return hackathon in dict if updated successfully. """ try: req = ok() if hackathon.status == HACK_STATUS.OFFLINE or hackathon.status == HACK_STATUS.DRAFT: hackathon.status = HACK_STATUS.APPLY_ONLINE hackathon.save() elif hackathon.status == HACK_STATUS.INIT: req = general_error(code=HTTP_CODE.CREATE_NOT_FINISHED) return req except Exception as e: self.log.error(e) return internal_server_error("fail to delete hackathon" + hackathon.name)
def hackathon_online(self, hackathon): req = ok() if hackathon.status == HackathonStatus.DRAFT or hackathon.status == HackathonStatus.OFFLINE or hackathon.status == HackathonStatus.APPLY_ONLINE: if self.util.is_local() or hackathon.config.get( 'cloud_provider') == CloudProvider.NONE: req = ok() elif hackathon.config.get('cloud_provider') == CloudProvider.AZURE: raise NotImplementedError() elif hackathon.status == HackathonStatus.ONLINE: req = ok() else: req = general_error(code=HTTP_CODE.CREATE_NOT_FINISHED) if req.get('error') is None: hackathon.status = HackathonStatus.ONLINE hackathon.save() self.create_hackathon_notice( hackathon.id, HackathonNotifyEvent.HACK_ONLINE, HackathonNotifyCategory.HACKATHON) # hackathon online return req
def hackathon_online(self, hackathon): req = ok() if hackathon.status == HACK_STATUS.DRAFT or hackathon.status == HACK_STATUS.OFFLINE or hackathon.status == HACK_STATUS.APPLY_ONLINE: if self.util.is_local() or hackathon.config.get( 'cloud_provider') == CLOUD_PROVIDER.NONE: req = ok() elif hackathon.config.get( 'cloud_provider') == CLOUD_PROVIDER.AZURE: raise NotImplementedError() elif hackathon.status == HACK_STATUS.ONLINE: req = ok() else: req = general_error(code=HTTP_CODE.CREATE_NOT_FINISHED) if req.get('error') is None: hackathon.status = HACK_STATUS.ONLINE hackathon.save() self.create_hackathon_notice( hackathon.id, HACK_NOTICE_EVENT.HACK_ONLINE, HACK_NOTICE_CATEGORY.HACKATHON) # hackathon online return req