示例#1
0
    def _PUT(self, *param, **params):
        tag_id = param[0]
        if not validates_param_id(self, tag_id):
            self.logger.debug(
                "Failed to update tag. The value of parameter is invalid.")
            return web.badrequest(self.view.alert)

        if not validates_tag(self):
            self.logger.debug(
                "Failed to update tag. The value of input is invalid.")
            return web.badrequest(self.view.alert)

        tag = findby1(self.orm, tag_id)
        if not tag:
            self.logger.debug("Failed to update tag. No such tag - id=%s" %
                              tag_id)
            return web.notfound()

        cmp_tag = findby1name(self.orm, self.input.name)
        if not cmp_tag is None:
            if cmp_tag.id != tag.id:
                self.logger.debug(
                    "Failed to update tag. The same tag already exist - id='%s'"
                    % (cmp_tag.id))
                return web.conflict(web.ctx.path)

        tag.name = self.input.name

        update(self.orm, tag)
        return web.seeother(web.ctx.path)
示例#2
0
文件: tag.py 项目: goura/karesansui
    def _PUT(self, *param, **params):
        tag_id = param[0]
        if not validates_param_id(self, tag_id):
            self.logger.debug("Failed to update tag. The value of parameter is invalid.")
            return web.badrequest(self.view.alert)

        if not validates_tag(self):
            self.logger.debug("Failed to update tag. The value of input is invalid.")
            return web.badrequest(self.view.alert)

        tag = findby1(self.orm, tag_id)
        if not tag:
            self.logger.debug("Failed to update tag. No such tag - id=%s" % tag_id)
            return web.notfound() 

        cmp_tag = findby1name(self.orm, self.input.name)
        if not cmp_tag is None:
            if cmp_tag.id != tag.id:
                self.logger.debug("Failed to update tag. The same tag already exist - id='%s'" % (cmp_tag.id))
                return web.conflict(web.ctx.path)

        tag.name = self.input.name

        update(self.orm, tag)
        return web.seeother(web.ctx.path)
示例#3
0
文件: tag.py 项目: goura/karesansui
    def _DELETE(self, *param, **params):
        tag_id = param[0]
        if not validates_param_id(self, tag_id):
            self.logger.debug("Failed to delete tag. The value of parameter is invalid.")
            return web.badrequest(self.view.alert)

        tag = findby1(self.orm, tag_id)
        if not tag:
            self.logger.debug("Failed to delete tag. No such tag - id=%s" % tag_id)
            return web.notfound() 

        delete(self.orm, tag)
        return web.seeother("/%s.%s" % ("tag", "part"))
示例#4
0
文件: tag.py 项目: goura/karesansui
    def _GET(self, *param, **params):
        tag_id = param[0]
        if not validates_param_id(self, tag_id):
            self.logger.debug("Failed to get tag. The value of parameter is invalid.")
            return web.badrequest(self.view.alert)

        tag = findby1(self.orm, tag_id)
        if not tag:
            self.logger.debug("Failed to get tag. No such tag - id=%s" % tag_id)
            return web.notfound()
        self.view.tag = tag
        
        return True
示例#5
0
    def _DELETE(self, *param, **params):
        tag_id = param[0]
        if not validates_param_id(self, tag_id):
            self.logger.debug(
                "Failed to delete tag. The value of parameter is invalid.")
            return web.badrequest(self.view.alert)

        tag = findby1(self.orm, tag_id)
        if not tag:
            self.logger.debug("Failed to delete tag. No such tag - id=%s" %
                              tag_id)
            return web.notfound()

        delete(self.orm, tag)
        return web.seeother("/%s.%s" % ("tag", "part"))
示例#6
0
    def _GET(self, *param, **params):
        tag_id = param[0]
        if not validates_param_id(self, tag_id):
            self.logger.debug(
                "Failed to get tag. The value of parameter is invalid.")
            return web.badrequest(self.view.alert)

        tag = findby1(self.orm, tag_id)
        if not tag:
            self.logger.debug("Failed to get tag. No such tag - id=%s" %
                              tag_id)
            return web.notfound()
        self.view.tag = tag

        return True