From 33fab300b363b1cc124028466917186e3079ac76 Mon Sep 17 00:00:00 2001 From: Cédric Bonhomme Date: Sat, 26 Apr 2014 17:11:11 +0200 Subject: This fixes #3. --- pyaggr3g470r/decorators.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'pyaggr3g470r') diff --git a/pyaggr3g470r/decorators.py b/pyaggr3g470r/decorators.py index f4192605..565d25a6 100644 --- a/pyaggr3g470r/decorators.py +++ b/pyaggr3g470r/decorators.py @@ -4,7 +4,7 @@ from threading import Thread from functools import wraps -from flask import g +from flask import g, redirect, url_for, flash from pyaggr3g470r.models import Feed @@ -23,8 +23,10 @@ def feed_access_required(func): def decorated(*args, **kwargs): if kwargs.get('feed_id', None) != None: feed = Feed.query.filter(Feed.id == kwargs.get('feed_id', None)).first() - if (feed == None or feed.subscriber.id != g.user.id) and not g.user.is_admin(): - flash("This feed do not exist.", "danger") - return redirect(url_for('home')) - return func(*args, **kwargs) + if feed != None and (feed.subscriber.id == g.user.id or g.user.is_admin()): + return func(*args, **kwargs) + flash("This feed do not exist.", "danger") + return redirect(url_for('home')) + else: + return func(*args, **kwargs) return decorated -- cgit