From 2b71b7206523273442705229e65fd0d812f4e958 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Thu, 31 Mar 2016 09:27:21 -0700 Subject: [PATCH] Redirecting URL from previous names to caravel --- caravel/views.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/caravel/views.py b/caravel/views.py index f6aa4123a0913..8c96be962c71a 100644 --- a/caravel/views.py +++ b/caravel/views.py @@ -20,6 +20,7 @@ import pandas as pd from sqlalchemy import select, text from sqlalchemy.sql.expression import TextAsFrom +from werkzeug.routing import BaseConverter from caravel import appbuilder, db, models, viz, utils, app, sm, ascii_art @@ -823,3 +824,23 @@ class CssTemplateModelView(CaravelModelView, DeleteMixin): icon="fa-css3", category="Sources", category_icon='') + + +# --------------------------------------------------------------------- +# Redirecting URL from previous names +class RegexConverter(BaseConverter): + def __init__(self, url_map, *items): + super(RegexConverter, self).__init__(url_map) + self.regex = items[0] +app.url_map.converters['regex'] = RegexConverter + + +@app.route('/') +def panoramix(url): # noqa + return redirect(request.full_path.replace('panoramix', 'caravel')) + + +@app.route('/') +def dashed(url): # noqa + return redirect(request.full_path.replace('dashed', 'caravel')) +# ---------------------------------------------------------------------