Esempio n. 1
0
 def has_requests(self):
     from models.relationship import Relationship
     # Returns list of pending follow request for current_user
     return Relationship.select().join(
         User, on=(User.id == Relationship.following_id)).where(
             Relationship.is_approved == False,
             Relationship.following_id == self.id)
Esempio n. 2
0
 def is_approved(self, user_id):
     from models.relationship import Relationship
     # Return boolean if relationship between current_user and approved user is approved
     return Relationship.select(Relationship.is_approved).join(
         User, on=(User.id == Relationship.following_id)).where(
             Relationship.follower_id == user_id,
             Relationship.following_id == self.id).first().is_approved
Esempio n. 3
0
def index():
    if current_user.is_authenticated:

        idols = (Relationship.select(Relationship.idol).where(
            Relationship.fan == current_user.id,
            Relationship.approved == True))
        images = (
            Image.select().where((Image.user.in_(idols))
                                 | (Image.user == current_user.id)).order_by(
                                     Image.created_at.desc()))

        return render_template('users/index.html', images=images)
    else:

        return render_template('sessions/new.html')
 def my_follower(self):
     from models.relationship import Relationship
     my_follower = Relationship.select(Relationship.following).where(
         Relationship.followed == self, Relationship.pending == False)
     return my_follower
 def pending_request(self):
     from models.relationship import Relationship
     p_following_list = Relationship.select(Relationship.followed).where(
         Relationship.following == self, Relationship.pending == True)
     return p_following_list
 def my_following_total(self):
     from models.relationship import Relationship
     im_following = Relationship.select(Relationship.followed).where(
         Relationship.following == self, Relationship.pending == False)
     return len(im_following)
Esempio n. 7
0
def show():
    followers = Relationship.select().where(
        Relationship.idol == current_user.id, Relationship.approved == False)
    return render_template('fanidols/show.html', followers=followers)