예제 #1
0
def approve(fan_username):
    fan = User.get_or_none(User.username == fan_username)

    inputbutton = request.form.get("inputbutton")
    print("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxdxx")
    print(inputbutton)

    if inputbutton == "approve":
        fanidol = FanIdol.get_or_none(FanIdol.fan == fan)
        fanidol.approved = True
        fanidol.save()

    else:

        print(fan.username)

        fanidol = FanIdol.get_or_none(FanIdol.fan == fan)
        print("XOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXOXO")
        fanidol.blocked = True
        fanidol.save()

        return redirect(url_for('users.blockeduser'))

    # current_user.approve(fan.id)
    # print("333333333333333333333333333333333333333333333333333333333333333333")

    return redirect(
        url_for('users.fan_requests', username=current_user.username))
예제 #2
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
예제 #3
0
    def approve(self, fan_id):
        from models.fanidol import FanIdol

        fanidol = FanIdol.get_or_none(FanIdol.idol == self.id,
                                      FanIdol.fan == int(fan_id))
        fanidol.approved = True
        fanidol.save()
예제 #4
0
    def unfollow(self, idol_id):
        from models.fanidol import FanIdol

        fanidol = FanIdol.get_or_none(FanIdol.idol_id == int(idol_id),
                                      FanIdol.fan == self.id)

        fanidol.delete_instance()
예제 #5
0
def unblock(fan_username):
    fan = User.get_or_none(User.username == fan_username)
    fanidolrow = FanIdol.get_or_none(FanIdol.idol == current_user.id,
                                     FanIdol.fan == fan.id)

    fanidolrow.blocked = False
    fanidolrow.save()

    return redirect(url_for('users.blockeduser'))
예제 #6
0
    def follow(self, idol):
        from models.fanidol import FanIdol
        # if relationship/row exists, return false
        if FanIdol.get_or_none(FanIdol.fan == self.id,
                               FanIdol.idol == idol.id):
            return False
        else:
            if idol.is_private:
                FanIdol.create(fan=self.id, idol=idol.id, is_approved=False)
            else:
                FanIdol.create(fan=self.id, idol=idol.id, is_approved=True)

            return True
예제 #7
0
파일: user.py 프로젝트: dixondj/Nextagram
 def follow_status(self,idol):
     from models.fanidol import FanIdol
     # check following status : 
     # if already follow => return that row, 
     # else return None(mean not follow this idol before)
     return FanIdol.get_or_none(FanIdol.fan==self.id,FanIdol.idol==idol.id)
예제 #8
0
 def follow_status(self, idol):
     from models.fanidol import FanIdol
     return FanIdol.get_or_none(FanIdol.fan == self.id,
                                FanIdol.idol == idol.id)