def create_jinja_environment(self): env = Flask.create_jinja_environment(self) env.globals.update( app=current_app, csrf=csrf, get_locale=babel_get_locale, local_dt=abilian.core.util.local_dt, url_for=url_for, NO_VALUE=NO_VALUE, ) init_filters(env) return env
def create_jinja_environment(self): env = Flask.create_jinja_environment(self) env.globals.update(app=current_app, csrf=csrf, get_locale=babel_get_locale, local_dt=abilian.core.util.local_dt, _n=abilian.i18n._n, url_for=url_for, user_photo_url=user_photo_url, NO_VALUE=NO_VALUE, NEVER_SET=NEVER_SET) init_filters(env) return env
def create_jinja_environment(self): env = Flask.create_jinja_environment(self) env.globals.update( app=current_app, csrf=csrf, get_locale=babel_get_locale, local_dt=abilian.core.util.local_dt, _n=abilian.i18n._n, url_for=url_for, user_photo_url=user_photo_url, NO_VALUE=NO_VALUE, NEVER_SET=NEVER_SET, ) init_filters(env) return env
def setup_filters_and_processors(app): # Register generic filters from Abilian Core init_filters(app) @app.template_filter() def to_rfc2822(dt): if not dt: return current_locale = locale.getlocale(locale.LC_TIME) locale.setlocale(locale.LC_TIME, "en_US.UTF-8") formatted = dt.strftime("%a, %d %b %Y %H:%M:%S +0000") locale.setlocale(locale.LC_TIME, current_locale) return formatted @app.url_defaults def add_language_code(endpoint, values): if g.lang: values.setdefault('lang', g.lang) @app.url_value_preprocessor def pull_lang(endpoint, values): m = re.match("/(..)/", request.path) if m: g.lang = m.group(1) else: g.lang = '' if g.lang and not g.lang in app.config['ALLOWED_LANGS']: return redirect("/en/") @app.context_processor def inject_context(): return dict(app=app, linuxipsum=linuxipsum.generate) @app.before_request def before_request(): m = re.match("/(..)/", request.path) if m and not m.group(1) in app.config['ALLOWED_LANGS']: return redirect("/en/") if request.path.startswith("/crm"): if not current_user.is_authenticated(): return redirect("/login") g.recent_items = []
def setup_filters_and_processors(app): # Register generic filters from Abilian Core init_filters(app) @app.template_filter() def to_rfc2822(dt): if not dt: return current_locale = locale.getlocale(locale.LC_TIME) locale.setlocale(locale.LC_TIME, "en_US") formatted = dt.strftime("%a, %d %b %Y %H:%M:%S +0000") locale.setlocale(locale.LC_TIME, current_locale) return formatted @app.url_defaults def add_language_code(endpoint, values): values.setdefault('lang', g.lang) @app.url_value_preprocessor def pull_lang(endpoint, values): m = re.match("/(..)/", request.path) if m: g.lang = m.group(1) else: g.lang = '' if g.lang and not g.lang in app.config['ALLOWED_LANGS']: abort(404) @app.context_processor def inject_context(): return dict(app=app, linuxipsum=linuxipsum.generate) @app.before_request def before_request(): if request.path.startswith("/crm"): if not current_user.is_authenticated(): return redirect("/login") # FIXME g.user = None #g.user = current_user._get_current_object() g.recent_items = []
def setup_filters_and_processors(app): # Register generic filters from Abilian Core init_filters(app) @app.template_filter() def to_rfc2822(dt): if not dt: return current_locale = locale.getlocale(locale.LC_TIME) locale.setlocale(locale.LC_TIME, "en_US") formatted = dt.strftime("%a, %d %b %Y %H:%M:%S +0000") locale.setlocale(locale.LC_TIME, current_locale) return formatted @app.url_defaults def add_language_code(endpoint, values): values.setdefault('lang', g.lang) @app.url_value_preprocessor def pull_lang(endpoint, values): m = re.match("/(..)/", request.path) if m: g.lang = m.group(1) else: g.lang = 'fr' if not g.lang in app.config['ALLOWED_LANGS']: abort(404) @app.context_processor def inject_app(): return dict(app=app) @app.before_request def before_request(): # FIXME g.user = None g.recent_items = []