Mercurial > public > sg101
view bandmap/views.py @ 823:5892c05886a9
Band map WIP: add approve new band map entries in admin.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 24 Sep 2014 20:09:05 -0500 |
parents | 71db8076dc3d |
children | d91356818cef |
line wrap: on
line source
"""Views for the bandmap application. """ from django.contrib.auth.decorators import login_required from django.shortcuts import redirect, render from django.contrib import messages as django_messages from bandmap.forms import BandForm SUCCESS = "Successfully submitted {} for admin review. Thanks!" def map_view(request): return render(request, 'bandmap/map.html') @login_required def add_band(request): """ Provides the ability for a user to submit a new band to the map. """ if request.method == 'POST': form = BandForm(request.POST) if form.is_valid(): band = form.save(commit=False) band.user = request.user band.save() django_messages.success(request, SUCCESS.format(band.name)) redirect('bandmap-add') else: form = BandForm() return render(request, 'bandmap/add.html', { 'form': form, })