def default_template(user1): tmpl = Template( name="test_default_template", provider=VE_PROVIDER.DOCKER, status=TEMPLATE_STATUS.UNCHECKED, description="old_desc", content="", template_args={}, docker_image="ubuntu", network_configs=[], virtual_environment_count=0, creator=user1, ) tmpl.save() return tmpl
def get_template_info_by_id(self, template_id): """Query template basic info from DB by its id :type template_id: int :param template_id: unique id of Template """ return Template.objects(id=template_id).first()
def get_template_info_by_name(self, template_name): """Query template basic info from DB by its id :type template_name: str|unicode :param template_name: unique name of Template """ return Template.objects(name=template_name).first()
def delete_template_from_hackathon(self, template_id): template = Template.objects(id=template_id).first() if template is None: return not_found("template does not exist") if template in g.hackathon.templates: g.hackathon.templates.remove(template) g.hackathon.save() # self.db.delete_object(htr) return self.get_templates_with_detail_by_hackathon(g.hackathon)
def add_template_to_hackathon(self, template_id): try: template = Template.objects(id=template_id).first() if template is None: return not_found("template does not exist") if not (template in g.hackathon.templates): g.hackathon.templates.append(template) g.hackathon.save() return self.get_templates_with_detail_by_hackathon(g.hackathon) except Exception as ex: self.log.error(ex) return internal_server_error("add a hackathon template rel record faild")
def add_template_to_hackathon(self, template_id): try: template = Template.objects(id=template_id).first() if template is None: return not_found("template does not exist") if not (template in g.hackathon.templates): g.hackathon.templates.append(template) g.hackathon.save() return self.get_templates_with_detail_by_hackathon(g.hackathon) except Exception as ex: self.log.error(ex) return internal_server_error( "add a hackathon template rel record faild")
def search_template(self, args): """Search template by status, name or description""" criterion = self.__generate_search_criterion(args) return [t.dic() for t in Template.objects(criterion)]
def template_verified(self, template_id): Template.objects(id=template_id).update_one( status=TEMPLATE_STATUS.CHECK_PASS)
def template_verified(self, template_id): Template.objects(id=template_id).update_one(status=TEMPLATE_STATUS.CHECK_PASS)