comparison piecrust/admin/views/__init__.py @ 935:7ecb946bfafd

admin: Lots of fixes for running the admin panel in a WSGI server. - Use new source APIs in the dashboard to open WIP files. - Fixed broken/outdated code in some views. - Fixed cases when Flask is not running at the root URL by using the `SCRIPT_NAME` variable somewhat more properly.
author Ludovic Chabant <ludovic@chabant.com>
date Wed, 04 Oct 2017 09:15:16 -0700
parents 5b4c02ed9bb2
children b1a00c2c0c7f
comparison
equal deleted inserted replaced
934:98430e7143d2 935:7ecb946bfafd
1 from flask import render_template, current_app 1 from flask import current_app, render_template, request
2 from flask.views import View 2 from flask.views import View
3 from .menu import get_menu_context 3 from .menu import get_menu_context
4 4
5 5
6 class FoodTruckView(View): 6 class FoodTruckView(View):
29 29
30 30
31 def with_base_data(context=None): 31 def with_base_data(context=None):
32 if context is None: 32 if context is None:
33 context = {} 33 context = {}
34 context['base_url'] = current_app.config['FOODTRUCK_URL_PREFIX'] 34
35 script_root = request.script_root or ''
36 root_url = current_app.config.get('FOODTRUCK_ROOT_URL') or ''
37 context['base_url'] = script_root + root_url