示例#1
0
    def get_one_post(self, num):
        query = "SELECT * FROM pet_posts WHERE no=%d"
        t_post = self.db.select_one(query % int(num))
        post = self.post.create_from_dbdata(t_post)
        query = "select * from pet_pets where id=%d"
        t_pet = self.db.select_one(query % post.pet)
        if t_pet[3] == 1:
            self.pet = FreePet()
        else:
            self.pet = NFreePet()
        pet = self.pet.create_from_dbdata(t_pet)
        query = "select fname from pet_pictures where p_no=%d"
        picture = self.db.select_one(query % post.no)
        query = "select kinds from pet_kinds where id='%s'"
        kinds = self.db.select_one(query % pet.kinds)
        query = "select kinds_kinds from pet_kinds_kinds where id='%s'"
        kinds_kinds = self.db.select_one(query % pet.kinds_kinds)
        post_and_pet = list()
        post_and_pet.append(post)
        post_and_pet.append(pet)

        post_and_pet.append(kinds[0])
        post_and_pet.append(kinds_kinds[0])

        if (picture is not None):
            post_and_pet.append(picture[0])

        return post_and_pet
示例#2
0
    def getPost_myRegistlist(self):
        user = self.getUser_by_token()

        query = "select * from pet_posts where register_id='%s'order by no desc"
        posts = self.db.select_all(query % user.id)
        post_list = list()
        for i in posts:
            temp = self.post.makeDicByPost(self.post.create_from_dbdata(i))
            query = "select * from pet_pets where id=%d"
            pet_t = self.db.select_one(query % temp['pet'])
            if pet_t[3] == 1:
                self.pet = FreePet()
            else:
                self.pet = NFreePet()
            pet = self.pet.create_from_dbdata(pet_t)
            query = "select kinds from pet_kinds where id='%s'"
            kinds = self.db.select_one(query % pet.kinds)
            query = "select kinds_kinds from pet_kinds_kinds where id='%s'"
            kinds_kinds = self.db.select_one(query % pet.kinds_kinds)
            temp['kinds'] = kinds
            temp['kinds_kinds'] = kinds_kinds
            temp['gender'] = pet.gender

            post_list.append(temp)

        return post_list
示例#3
0
    def get_posts(self, page):

        query = "select count(no) from pet_posts"
        num = self.db.select_one(query)
        num = round(num[0] / 5 + 0.5)

        query = "select * from pet_posts order by no desc Limit %d , 5"
        posts = self.db.select_all(query % ((int(page) - 1) * 5))
        post_list = list()
        for i in posts:
            temp = self.post.makeDicByPost(self.post.create_from_dbdata(i))
            query = "select * from pet_pets where id=%d"
            pet_t = self.db.select_one(query % temp['pet'])
            if pet_t[3] == 1:
                self.pet = FreePet()
            else:
                self.pet = NFreePet()
            pet = self.pet.create_from_dbdata(pet_t)
            query = "select kinds from pet_kinds where id='%s'"
            kinds = self.db.select_one(query % pet.kinds)
            query = "select kinds_kinds from pet_kinds_kinds where id='%s'"
            kinds_kinds = self.db.select_one(query % pet.kinds_kinds)
            temp['kinds'] = kinds
            temp['kinds_kinds'] = kinds_kinds
            temp['gender'] = pet.gender

            post_list.append(temp)

        post_list.append(num)
        return post_list
示例#4
0
    def getRegister_list(self):
        user = self.getUser_by_token()
        query = "select pet_pets.id, pet_kinds.kinds, pet_kinds_kinds.kinds_kinds, is_free, price, gender,is_Neutralization,weight ,height,helth,uid from pet_pets join pet_kinds on pet_pets.kinds=pet_kinds.id join pet_kinds_kinds on pet_pets.kinds_kinds=pet_kinds_kinds.id where uid='%s'"
        pets = self.db.select_all(query % (user.id))
        pet_list = list()
        for i in pets:
            if i[3] is not 1:
                self.pet = NFreePet()
                temp = self.pet.makeDicByPet(self.pet.create_from_dbdata(i))
            else:
                self.pet = FreePet()
                temp = self.pet.makeDicByPet(self.pet.create_from_dbdata(i))
            pet_list.append(temp)

        return pet_list
示例#5
0
 def save_register(self, data):
     if data['is_free'] == 'O':
         self.pet = FreePet()
         pet = self.pet.create_from_request(data)
         query = "insert into pet_pets (kinds, kinds_kinds, is_free, price, gender,is_Neutralization,weight ,height,helth,uid) values((select id from pet_kinds where kinds='%s'),(select id from pet_kinds_kinds where kinds_kinds='%s'),%d,%d,%d,%d,%d,%d,'%s','%s')"
         self.db.insert(query %
                        (pet.kinds, pet.kinds_kinds, pet.is_free, 0,
                         pet.gender, pet.is_Neutralization, pet.weight,
                         pet.height, pet.helth, self.getUser_by_token().id))
     else:
         self.pet = NFreePet()
         pet = self.pet.create_from_request(data)
         query = "insert into pet_pets (kinds, kinds_kinds, is_free, price, gender,is_Neutralization,weight ,height,helth,uid) values((select id from pet_kinds where kinds='%s'),(select id from pet_kinds_kinds where kinds_kinds='%s'),%d,%d,%d,%d,%d,%d,'%s','%s')"
         self.db.insert(query %
                        (pet.kinds, pet.kinds_kinds, pet.is_free, pet.price,
                         pet.gender, pet.is_Neutralization, pet.weight,
                         pet.height, pet.helth, self.getUser_by_token().id))