Пример #1
0
def display_image(name):
    '''This routine displays a given image. We included only to support
    generally unused breadcrumb trails. It is password protected at the
    moment to ensure that users access raw images as part of actual pages.
    '''
    image = check_unit(Images.read_unit(name))
    return display_content(
        breadcrumbs=get_breadcrumbs('images', name),
        title=image.get('name'),
        primary='<img src="/static/images/' + image.get('filename') + '">',
        primaryListHr=False,
        editable=True,
        editableUrl=url_for('web.update_image', name=name)
    )
Пример #2
0
def update_image(name):
    '''For GET requests, this method allows the administrator to edit the named
       image. For POST requests, this method saves the edits made by the
       administrator and then reloads/redisplays the image admin page.
       Non-authenticated users are redirected to the login page. Images that
       don't exist can't be edited. Because we don't show individual images,
       all redirects go to the images admin page.
    '''
    form = Images()
    if form.is_submitted():
        if form.validate() and request.form.get('submit'):
            Images.update_unit(form)
            return redirect(url_for('web.display_image',
                            name=form.getName()))
    else:
        image = Images.read_unit(name)
        if image:
            form.initialize(name=name, action='update', image=image)
            return display_content(
                form=form,
                title='Edit: ' + name,
                breadcrumbs=get_breadcrumbs('images', name, 'edit')
            )
    return redirect(url_for('web.display_admin_images'))