def create(idol_id):
    #people to follow you in instagram from db

    idol = User.get_or_none(
        User.id == idol_id)  #this will take bring me the rows from db

    new_follower = FanIdol(fan_id=current_user.id, idol_id=idol.id)
    #new follower is creating me the fan_id and idol_id from me in db

    new_follower.save()  #this will help us save
    flash(f"You are now following {idol.name}")
    return redirect(url_for('users.show', id=idol.id))
def create(idol_id):

    idol = User.get_or_none(
        User.id == idol_id)  #this is to get everything from row from database

    new_follower = FanIdol(  #this is to create a new follower which takes in fan_id and idol_id (refer back to db)
        fan_id=current_user.id,
        idol_id=idol.id)

    new_follower.save()
    flash(f"You are now following {idol.name}")
    return redirect(
        url_for('users.show', username=idol.username)
    )  #this need to refer back to users.show parameter, because it pass in username then here have to pass it into here
Пример #3
0
 def follow(self, idol):
     from models.fan_idol import FanIdol
     if self.follow_status(idol) == None:
         new_relationship = FanIdol(fan=self.id, idol=idol.id)
         if idol.is_private == False:
             new_relationship.is_approved = True
         return new_relationship.save()
     else:
         return 0
Пример #4
0
 def follow(self, idol):
     from models.fan_idol import FanIdol
     # check whether current user follow idol before
     # relationship = FanIdol.get_or_none(fan=self.id, idol=idol.id)
     if self.follow_status(idol) == None:
         new_rel = FanIdol(fan=self.id, idol=idol.id)
         if idol.is_private == False:  # public idol
             new_rel.is_approved = True
         return new_rel.save()
     else:
         return 0
    def follow(self,idol):
        #check existing relationship in fanidol table
        from models.fan_idol import FanIdol
        # relationship = FanIdol.get_or_none(fan=self.id, idol = idol.id)
        if self.follow_status(idol) == None:
            new_rel = FanIdol(fan=self.id, idol = idol.id)

            if idol.is_private == False: #public idol
                new_rel.is_approved = True
            return new_rel.save()
        else:
            return 0
Пример #6
0
def follow(id):
    fan_idol = FanIdol(fan_id=current_user.id, idol_id=id)
    fan_idol.save()
    user = User.get_by_id(id)
    flash('Thank you for following.', 'success')
    return redirect(url_for('users.show', username=user.username))