Skip to content

Commit

Permalink
Merge pull request #218 from airbnb/redirects
Browse files Browse the repository at this point in the history
Redirecting URL from previous names to caravel
  • Loading branch information
mistercrunch committed Mar 31, 2016
2 parents a3f92f6 + eeba80c commit 167fb64
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions caravel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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('/<regex("panoramix\/.*"):url>')
def panoramix(url): # noqa
return redirect(request.full_path.replace('panoramix', 'caravel'))


@app.route('/<regex("dashed\/.*"):url>')
def dashed(url): # noqa
return redirect(request.full_path.replace('dashed', 'caravel'))
# ---------------------------------------------------------------------

0 comments on commit 167fb64

Please sign in to comment.