Example #1
0
 def follow(self, idol_id):
     idol = User.get(id=idol_id)
     Following.create(fan_id=self.id, idol_id=idol_id)
     if not idol.is_private:
         Following.update(is_approved=True).where(
             Following.fan_id == self.id,
             Following.idol_id == idol_id).execute()
         flash(f'Successfully followed {idol.username}', 'success')
     else:
         flash(f'follow request sent to {idol.username}. Pending approval',
               'info')
Example #2
0
def follow(id):
    user = User.get_or_none(id=id)
    fan_id = current_user.id
    idol_id = user.id
    if user.profile_privacy:
        Following.create(fan_id=fan_id, idol_id=idol_id, is_approved=False)
        flash(f"You have sent a request to follow { user.user_name }. Please wait for their approval.", "success")
        return redirect(url_for('users.show', id=user.id))
    else:
        Following.create(fan_id=fan_id, idol_id=idol_id, is_approved=True)
        flash(f"You are now following { user.user_name }", "success")
        return redirect(url_for('users.show', id=user.id))