コード例 #1
0
ファイル: user.py プロジェクト: arsm100/nextagram_api
 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')
コード例 #2
0
ファイル: views.py プロジェクト: suzukisteven/Instagram-Clone
def accept_request(id):
    user = User.get_or_none(id=id)
    followings = Following.update(is_approved = True).where(Following.id == id)
    following = Following.get_by_id(id)
    fan_name = following.fan.user_name
    if followings.execute():
        flash(f"You have approved {fan_name}", "success")
        followings = Following.select().where((Following.idol_id == current_user.id) & (Following.is_approved == False))
        return redirect(url_for('users.request', id=current_user.id, user=user, followings=followings))
    else:
        # Can't think of a scenario where this may happen but handle the scenario anyway.
        flash(f"Could not accept. Please try again.", "danger")
コード例 #3
0
ファイル: user.py プロジェクト: arsm100/nextagram_api
 def approve(self, fan_id):
     Following.update(is_approved=True).where(
         Following.fan_id == fan_id,
         Following.idol_id == self.id).execute()