forked from gergely/calendar-social
Create the @beta decorator
This commit is contained in:
parent
a97d884f42
commit
f7d807370d
@ -18,6 +18,11 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
from functools import wraps
|
||||||
|
|
||||||
|
from flask import flash, redirect, url_for
|
||||||
|
from flask_babelex import gettext as _
|
||||||
|
from flask_security import current_user
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
def force_locale(locale):
|
def force_locale(locale):
|
||||||
@ -119,3 +124,19 @@ class RoutedMixin:
|
|||||||
return func
|
return func
|
||||||
|
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
|
|
||||||
|
def beta(func):
|
||||||
|
"""Decorator to hide beta features from non-beta testers
|
||||||
|
"""
|
||||||
|
|
||||||
|
@wraps(func)
|
||||||
|
def decorated(*args, **kwargs): # pylint: disable=missing-docstring
|
||||||
|
if current_user.settings['beta'] != 'True':
|
||||||
|
flash(_('Join the beta testers to enable this functionality!'))
|
||||||
|
|
||||||
|
return redirect(url_for('account.settings'))
|
||||||
|
|
||||||
|
return func(*args, **kwargs)
|
||||||
|
|
||||||
|
return decorated
|
||||||
|
Loading…
Reference in New Issue
Block a user