Mercurial > public > sg101
view bandmap/views.py @ 821:71db8076dc3d
Bandmap WIP: geocoding integrated with add form.
Add form works. Before submitting the form, client side JS makes
a geocode request to Google and populates hidden lat/lon fields
with the result. Successfully created a model instance on the
server side.
Still need to update admin dashboard, admin approval, and give
out badges for adding bands to the map. Once that is done, then
work on displaying the map with filtering.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 23 Sep 2014 20:40:31 -0500 |
parents | 9a0df7bd2409 |
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, })