comparison 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
comparison
equal deleted inserted replaced
820:9a0df7bd2409 821:71db8076dc3d
1 """Views for the bandmap application. 1 """Views for the bandmap application.
2 2
3 """ 3 """
4 from django.contrib.auth.decorators import login_required 4 from django.contrib.auth.decorators import login_required
5 from django.shortcuts import redirect, render 5 from django.shortcuts import redirect, render
6 from django.contrib import messages as django_messages
6 7
7 from bandmap.forms import BandForm 8 from bandmap.forms import BandForm
9
10
11 SUCCESS = "Successfully submitted {} for admin review. Thanks!"
8 12
9 13
10 def map_view(request): 14 def map_view(request):
11 return render(request, 'bandmap/map.html') 15 return render(request, 'bandmap/map.html')
12 16
21 form = BandForm(request.POST) 25 form = BandForm(request.POST)
22 if form.is_valid(): 26 if form.is_valid():
23 band = form.save(commit=False) 27 band = form.save(commit=False)
24 band.user = request.user 28 band.user = request.user
25 band.save() 29 band.save()
26 redirect('bandmap-thanks') 30 django_messages.success(request, SUCCESS.format(band.name))
31 redirect('bandmap-add')
27 else: 32 else:
28 form = BandForm() 33 form = BandForm()
29 34
30 return render(request, 'bandmap/add.html', { 35 return render(request, 'bandmap/add.html', {
31 'form': form, 36 'form': form,