예제 #1
0
    def post(self, cmsg):
        edit_map_list = user_data.get_usermap_list(cmsg.common.userid)
        if not edit_map_list:
            user_data.create_usermap_list(cmsg.common.userid)

        if edit_map_list and edit_map_list[0] != '0':
            return auth.pack(None, const.ERROR_HAS_GUIDE)

        mapid = global_data.get_counter(const.TAG_USERMAP_COUNT)
        user_data.create_usermap(cmsg.common.userid, mapid, 0, "empty", cmsg.url, cmsg.data, 100)

        return auth.pack(None, 0, cmsg.common.userid)
예제 #2
0
    def post(self, cmsg):
        user_map_edit_list = user_data.get_usermap_list(cmsg.common.userid)
        try:
            index = user_map_edit_list.index(str(cmsg.id))
            if index < 0 or index >= 12:
                return auth.pack(None, const.ERROR_SYSTEM)
        except:
            return auth.pack(None, const.ERROR_SYSTEM)

        user_data.delete_usermap(cmsg.common.userid, cmsg.id, index)

        return auth.pack(None, 0, cmsg.common.userid)
예제 #3
0
def export_user_map():
    global user_map_path
    max_value = global_data.get_counter_value(const.TAG_USER_COUNT)
    max_value = int(max_value)

    for userid in range(1, max_value + 1):
        usermaplist = user_data.get_usermap_list(userid)
        if usermaplist:
            for mapid in usermaplist:
                if mapid != '0':
                    mapdata = user_data.get_usermap_attr(userid, mapid, "data")
                    if mapdata is not None and mapdata != "":
                        with open(
                                user_map_path + str(userid) + "." +
                                str(mapid) + ".data", "wb") as f:
                            f.write(mapdata)
예제 #4
0
    def post(self, cmsg):
        jewel, download_num = user_data.get_user_attrs(cmsg.common.userid, "jewel", "download_num")
        if download_num is None:
            download_num = 0

        name, ownerid, url, data = map_data.get_map_attrs(cmsg.id, "name", "ownerid", "url", "data")

        download_num = int(download_num)
        if download_num >= const.DOWNLOAD_MAX:
            return auth.pack(None, const.ERROR_SYSTEM)

        download_template = self.application.static_data.get_download_template(download_num)
        if not download_template:
            return auth.pack(None, const.ERROR_SYSTEM)

        need_guild = 0
        need_jewel = -download_template.price
        if int(ownerid) != cmsg.common.userid:
            need_guild = 1
            if int(jewel) < download_template.price:
                return auth.pack(None, const.ERROR_NO_JEWEL)
        else:
            need_jewel = 0


        empty_slot = -1
        edit_map_list = user_data.get_usermap_list(cmsg.common.userid)
        if not edit_map_list:
            user_data.create_usermap_list(cmsg.common.userid)
            empty_slot = 1
        else:
            for i in range(len(edit_map_list)):
                if edit_map_list[i] == '0':
                    empty_slot = i
                    break

        if empty_slot == -1:
            return auth.pack(None, const.ERROR_DOWNLOAD)

        mapid = global_data.get_counter(const.TAG_USERMAP_COUNT)
        user_data.create_usermap(cmsg.common.userid, mapid, empty_slot, name, url, data, need_guild, need_jewel)

        return auth.pack(None, 0, cmsg.common.userid)
예제 #5
0
    def post(self, cmsg):
        if cmsg.index < 0 or cmsg.index >= 12:
            return auth.pack(None, const.ERROR_SYSTEM)

        edit_map_list = user_data.get_usermap_list(cmsg.common.userid)
        if not edit_map_list:
            user_data.create_usermap_list(cmsg.common.userid)
        else:
            if edit_map_list[cmsg.index] != '0':
                return auth.pack(None, const.ERROR_SYSTEM)

        mapid = global_data.get_counter(const.TAG_USERMAP_COUNT)
        user_data.create_usermap(cmsg.common.userid, mapid, cmsg.index)

        smsg = smsg_create_map()
        smsg.map.id = mapid
        smsg.map.name = "empty"
        smsg.map.url = ""
        smsg.map.date = util.now_date_str()
        smsg.map.upload = 0
        return auth.pack(smsg, 0, cmsg.common.userid)