def fans(self): # return a list of fan user instances that only approved from models.fan_idol import FanIdol fans_id = FanIdol.select(FanIdol.fan).where( FanIdol.idol == self.id, FanIdol.is_approved == True) fans = User.select().where(User.id.in_(fans_id)) return fans
def idols(self): # return a list of idol user instances that only approved from models.fan_idol import FanIdol idols_id = FanIdol.select(FanIdol.idol).where( FanIdol.fan == self.id, FanIdol.is_approved == True) idols = User.select().where(User.id.in_(idols_id)) return idols
def image_feed(self): from models.fan_idol import FanIdol from models.image import Image approved_idols_id = FanIdol.select(FanIdol.idol).where( FanIdol.fan == self.id, FanIdol.is_approved == True) return Image.select().where( Image.user.in_(approved_idols_id)).order_by( Image.created_at.desc())
def image_feed(self): from models.fan_idol import FanIdol from models.image import Image approved_idols_id = FanIdol.select(FanIdol.idol).where( FanIdol.fan == self.id, FanIdol.is_approved == True) idols_with_me = [x.idol for x in approved_idols_id ] # return a list of idols' id idols_with_me.append(self.id) # add your own id return Image.select().where(Image.user.in_(idols_with_me)).order_by( Image.created_at.desc())
def fan_requests(self): from models.fan_idol import FanIdol fans_id = FanIdol.select(FanIdol.fan).where(FanIdol.idol== self.id, FanIdol.is_approved==False) return User.select().where(User.id.in_(fans_id))
def fans(self): from models.fan_idol import FanIdol fans_id = FanIdol.select(FanIdol.fan).where( FanIdol.idol == self.id, FanIdol.is_approved == True) fans = User.select().where(User.id.in_(fans_id)) return fans
def idols(self): from models.fan_idol import FanIdol idols_id = FanIdol.select(FanIdol.idol).where( FanIdol.fan == self.id, FanIdol.is_approved == True) idols = User.select().where(User.id.in_(idols_id)) return idols
def idol_requests(self): from models.fan_idol import FanIdol idols_id = FanIdol.select(FanIdol.idol).where( FanIdol.fan == self.id, FanIdol.is_approved == False) return User.select().where(User.id.in_(idols_id)).order_by( User.created_at.desc())