view piecrust/admin/views/__init__.py @ 1149:be74ba54a06f

admin: Improvements to micropub endpoint's photo handling. - Add `.jpg` extension to photos that don't have any extension. - Add photos in the config section instead of the body, so that the layout can put them in separate `u-photo` tags.
author Ludovic Chabant <ludovic@chabant.com>
date Tue, 10 Jul 2018 21:03:58 -0700
parents b1a00c2c0c7f
children
line wrap: on
line source

from flask import current_app, render_template, request
from flask.views import View
from .menu import get_menu_context


class FoodTruckView(View):
    template_name = 'index.html'
    requires_menu = True

    def render_template(self, context):
        if self.requires_menu:
            context = with_menu_context()
        return render_template(self.template_name, **context)

    def get_context(self):
        return None

    def dispatch_request(self):
        ctx = self.get_context()
        return render_template(ctx)


def with_menu_context(context=None):
    if context is None:
        context = {}
    context['menu'] = get_menu_context()
    return context