diff options
author | François Schmidts <francois.schmidts@gmail.com> | 2015-12-12 21:14:28 +0100 |
---|---|---|
committer | François Schmidts <francois.schmidts@gmail.com> | 2015-12-17 09:42:56 +0100 |
commit | b35e9773198ef2d8b37c4ca223f08147db47de0b (patch) | |
tree | ba4b1b171b3c1ab9414a96ad264c47b0f9d1246b /web/decorators.py | |
parent | Updated link to Heroku deploy button on the About page. (diff) | |
download | newspipe-b35e9773198ef2d8b37c4ca223f08147db47de0b.tar.gz newspipe-b35e9773198ef2d8b37c4ca223f08147db47de0b.tar.bz2 newspipe-b35e9773198ef2d8b37c4ca223f08147db47de0b.zip |
moving the root of source code from / to /src/
Diffstat (limited to 'web/decorators.py')
-rw-r--r-- | web/decorators.py | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/web/decorators.py b/web/decorators.py deleted file mode 100644 index 6572b9f4..00000000 --- a/web/decorators.py +++ /dev/null @@ -1,50 +0,0 @@ -#! /usr/bin/env python -# -*- coding: utf-8 -*- - -from threading import Thread -from functools import wraps - -from flask import g, redirect, url_for, flash -from flask.ext.babel import gettext -from flask.ext.login import login_required - -from web.models import Feed - - -def async(f): - """ - This decorator enables to launch a task (for examle sending an email or - indexing the database) in background. - This prevent the server to freeze. - """ - def wrapper(*args, **kwargs): - thr = Thread(target=f, args=args, kwargs=kwargs) - thr.start() - return wrapper - - -def feed_access_required(func): - """ - This decorator enables to check if a user has access to a feed. - The administrator of the platform is able to access to the feeds - of a normal user. - """ - @wraps(func) - def decorated(*args, **kwargs): - if kwargs.get('feed_id', None) is not None: - feed = Feed.query.filter(Feed.id == kwargs.get('feed_id', None)).first() - if feed is not 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 - - -def pyagg_default_decorator(func): - @login_required - @wraps(func) - def wrapper(*args, **kwargs): - return func(*args, **kwargs) - return wrapper |