def show(username): user = User.get_or_none(User.username == username) if user: followed = FanIdol.get_or_none(FanIdol.fan==current_user.id,FanIdol.idol==user.id) approved = FanIdol.get_or_none(FanIdol.fan==current_user.id,FanIdol.idol==user.id,FanIdol.approved==True) images = Image.select().where(Image.user==user.id,Image.gallery==True).order_by(Image.created_at.desc()).limit(6) profile_images = Image.select().where(Image.user==user.id,Image.gallery==False).order_by(Image.created_at.desc()).limit(6) ttl_images = Image.select().where(Image.user==user.id) ttlfans = len(user.fans) ttlidols = len(user.idols) ttl = len(ttl_images) followers = FanIdol.select().where(FanIdol.idol==current_user.id ,FanIdol.approved==False) idols = FanIdol.select().where(FanIdol.fan==current_user.id, FanIdol.approved==False) return render_template('users/show.html',followers=followers,idols=idols,followed=followed,approved=approved,user=user,images=images,profile_images=profile_images,ttl=ttl,ttlfans=ttlfans,ttlidols=ttlidols) return render_template('404.html'), 404
def fan_requests(self): from models.fanidol import FanIdol fan_requests = FanIdol.select(FanIdol.fan).where( FanIdol.idol == self.id, FanIdol.approved == False, FanIdol.blocked == False) return User.select().where(User.id.in_(fan_requests))
def pending_idols(self): from models.fanidol import FanIdol pending_idols = FanIdol.select(FanIdol.idol).where( FanIdol.fan == self.id, FanIdol.approved == False) return User.select().where(User.id.in_(pending_idols))
def my_idols(self): from models.fanidol import FanIdol idols = FanIdol.select(FanIdol.idol).where(FanIdol.fan == self.id, FanIdol.approved == True) return User.select().where(User.id.in_(idols)).order_by( User.username.asc())
def blocked(self): from models.fanidol import FanIdol fanidol = FanIdol.select(FanIdol.fan).where(FanIdol.idol == self.id, FanIdol.blocked == True) return User.select().where(User.id.in_(fanidol))
def fans(self): from models.fanidol import FanIdol fans = FanIdol.select().where(FanIdol.idol == self.id, FanIdol.is_approved == True) fans_list = [] for fan in fans: fans_list.append(fan.fan) return fans_list
def my_fans(self): from models.fanidol import FanIdol fans = FanIdol.select(FanIdol.fan).where(FanIdol.idol == self.id, FanIdol.approved == True, FanIdol.blocked == False) return User.select().where(User.id.in_(fans)).order_by( User.username.asc())
def index(): if current_user.is_authenticated: idols = FanIdol.select(FanIdol.idol).where( FanIdol.fan == current_user.id, FanIdol.approved == True) images = Image.select().where((Image.user.in_(idols)) | ( Image.user == current_user.id)).order_by(Image.created_at.desc()) return render_template('home.html', images=images) else: return render_template('sessions/new.html')
def idols(self): from models.fanidol import FanIdol # get a list of idols idols = FanIdol.select().where(FanIdol.fan == self.id, FanIdol.is_approved == True) idols_list = [] for idol in idols: idols_list.append(idol.idol) return idols_list
def followings(self): from models.fanidol import FanIdol # to get all idols idols = FanIdol.select(FanIdol.idol).where(FanIdol.fan==self.id,FanIdol.approved==True) return User.select().where(User.id.in_(idols))
def followers(self): from models.fanidol import FanIdol # to get all fans fans = FanIdol.select(FanIdol.fan).where(FanIdol.idol==self.id,FanIdol.approved==True) return User.select().where(User.id.in_(fans))
def get_request(self): from models.fanidol import FanIdol return FanIdol.select().where(FanIdol.idol==self.id,FanIdol.approved==False)
def idol_requests(self): from models.fanidol import FanIdol idols = FanIdol.select(FanIdol.idol).where( FanIdol.fan == self.id, FanIdol.is_approved == False) return User.select().where(User.id.in_(idols))
def fans(self): from models.fanidol import FanIdol # get list of fans fans = FanIdol.select(FanIdol.fan).where(FanIdol.idol == self.id, FanIdol.is_approved == True) return User.select().where(User.id.in_(fans))
def idols(self): from models.fanidol import FanIdol # get a list of idols user idols = FanIdol.select(FanIdol.idol).where(FanIdol.fan == self.id, FanIdol.is_approved == True) return User.select().where(User.id.in_(idols))