Fix youtube user not unfollowed, had to click twice
This commit is contained in:
parent
8f9838df10
commit
47696d60ca
@ -41,12 +41,16 @@ ALLOWED_EXTENSIONS = {'json', 'db'}
|
|||||||
#########################
|
#########################
|
||||||
#### Twitter Logic ######
|
#### Twitter Logic ######
|
||||||
#########################
|
#########################
|
||||||
|
@app.before_request
|
||||||
|
def before_request():
|
||||||
|
if current_user.is_authenticated:
|
||||||
|
current_user.set_last_seen()
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/')
|
||||||
@app.route('/index')
|
@app.route('/index')
|
||||||
@login_required
|
@login_required
|
||||||
def index():
|
def index():
|
||||||
current_user.set_last_seen()
|
|
||||||
db.session.commit()
|
|
||||||
return render_template('home.html', config=config)
|
return render_template('home.html', config=config)
|
||||||
|
|
||||||
@app.route('/twitter')
|
@app.route('/twitter')
|
||||||
@ -281,18 +285,23 @@ def followYoutubeChannel(channelId):
|
|||||||
def ytunfollow(channelId):
|
def ytunfollow(channelId):
|
||||||
form = EmptyForm()
|
form = EmptyForm()
|
||||||
if form.validate_on_submit():
|
if form.validate_on_submit():
|
||||||
r = unfollowYoutubeChannel(channelId)
|
unfollowYoutubeChannel(channelId)
|
||||||
return redirect(request.referrer)
|
return redirect(request.referrer)
|
||||||
|
|
||||||
def unfollowYoutubeChannel(channelId):
|
def unfollowYoutubeChannel(channelId):
|
||||||
try:
|
try:
|
||||||
channel = youtubeFollow.query.filter_by(channelId=channelId).first()
|
channel = youtubeFollow.query.filter_by(channelId=channelId).first()
|
||||||
|
name = channel.channelName
|
||||||
db.session.delete(channel)
|
db.session.delete(channel)
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
flash("{} unfollowed!".format(channel.channelName))
|
channel = youtubeFollow.query.filter_by(channelId=channelId).first()
|
||||||
|
if channel:
|
||||||
|
db.session.delete(channel)
|
||||||
|
db.session.commit()
|
||||||
|
print(channel)
|
||||||
|
flash("{} unfollowed!".format(name))
|
||||||
except:
|
except:
|
||||||
flash("There was an error unfollowing the user. Try again.")
|
flash("There was an error unfollowing the user. Try again.")
|
||||||
return redirect(request.referrer)
|
|
||||||
|
|
||||||
@app.route('/channel/<id>', methods=['GET'])
|
@app.route('/channel/<id>', methods=['GET'])
|
||||||
@app.route('/user/<id>', methods=['GET'])
|
@app.route('/user/<id>', methods=['GET'])
|
||||||
@ -411,7 +420,7 @@ def settings():
|
|||||||
t = datetime.datetime.utcnow() - u.last_seen
|
t = datetime.datetime.utcnow() - u.last_seen
|
||||||
s = t.total_seconds()
|
s = t.total_seconds()
|
||||||
m = s/60
|
m = s/60
|
||||||
if m < 40:
|
if m < 10:
|
||||||
active = active+1
|
active = active+1
|
||||||
|
|
||||||
instanceInfo = {
|
instanceInfo = {
|
||||||
|
Reference in New Issue
Block a user