def create_image(): '''This routine displays an editing page for creating an image.''' form = Images() if form.is_submitted(): if form.validate() and request.form.get('submit'): Images.create_unit(form) return redirect(url_for('web.display_image', name=form.getName())) else: return redirect(url_for('web.display_admin_images')) else: form.initialize(action='create') return display_content( form=form, title='Create Image', breadcrumbs=get_breadcrumbs('images', 'create') )
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'))