Exemplo n.º 1
0
    def POST(self):
        id = xutils.get_argument("id")
        name = xutils.get_argument("name")
        if name == "" or name is None:
            return dict(code="fail", message="名称为空")

        old = xutils.call("note.get_by_id", id)
        if old is None:
            return dict(code="fail", message="笔记不存在")

        if old.creator != xauth.get_current_name():
            return dict(code="fail", message="没有权限")

        file = xutils.call("note.get_by_name", name)
        if file is not None and file.is_deleted == 0:
            return dict(code="fail", message="%r已存在" % name)

        xutils.call("note.update", dict(id=id), name=name)

        event_body = dict(action="rename", id=id, name=name, type=old.type)
        xmanager.fire("note.updated", event_body)
        xmanager.fire("note.rename", event_body)
        if old.type == "group":
            cacheutil.prefix_del("group.list")
        return dict(code="success")
Exemplo n.º 2
0
    def POST(self):
        id = xutils.get_argument("id")
        name = xutils.get_argument("name")
        if name == "" or name is None:
            return dict(code="fail", message="名称为空")
        db = xtables.get_file_table()
        old  = db.select_one(where=dict(id=id))
        if old.creator != xauth.get_current_name():
            return dict(code="fail", message="没有权限")

        file = db.select_one(where=dict(name=name, is_deleted=0))
        if file is not None:
            return dict(code="fail", message="%r已存在" % name)
        db.update(where=dict(id=id), name=name, mtime=xutils.format_datetime())
        event_body = dict(action="rename", id=id, name=name, type=old.type)
        xmanager.fire("note.updated", event_body)
        xmanager.fire("note.rename", event_body)
        if old.type == "group":
            cacheutil.prefix_del("group.list")
        return dict(code="success")
Exemplo n.º 3
0
def update_priority(creator, id, value):
    table = xtables.get_file_table()
    rows = table.update(priority=value, where=dict(creator=creator, id=id))
    cache_key = "[%s]note.recent" % creator
    cacheutil.prefix_del(cache_key)
    return rows > 0
Exemplo n.º 4
0
def update_note_cache(ctx):
    type = ctx.get("type", "")
    cacheutil.prefix_del("[%s]note" % xauth.get_current_name())
Exemplo n.º 5
0
def expire_message_cache(ctx):
    cacheutil.prefix_del("message.count")
Exemplo n.º 6
0
def update_cache(ctx):
    type = ctx.get("type", "")
    cacheutil.prefix_del("recent_notes")
    cacheutil.prefix_del("group.list")