示例#1
0
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
示例#2
0
    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))
示例#3
0
    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))
示例#4
0
    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())
示例#5
0
    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))
示例#6
0
 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
示例#7
0
    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())
示例#8
0
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')
示例#9
0
 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
示例#10
0
文件: user.py 项目: dixondj/Nextagram
 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))
示例#11
0
文件: user.py 项目: dixondj/Nextagram
 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))
示例#12
0
文件: user.py 项目: dixondj/Nextagram
 def get_request(self):
     from models.fanidol import FanIdol
     return FanIdol.select().where(FanIdol.idol==self.id,FanIdol.approved==False)
示例#13
0
 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))
示例#15
0
 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))