Mercurial > public > sg101
comparison bandmap/views.py @ 820:9a0df7bd2409
Bandmap application work in progress.
Model defined.
Map is displaying.
Initial display of add form.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 21 Sep 2014 18:20:29 -0500 |
parents | |
children | 71db8076dc3d |
comparison
equal
deleted
inserted
replaced
819:38db6ec61af3 | 820:9a0df7bd2409 |
---|---|
1 """Views for the bandmap application. | |
2 | |
3 """ | |
4 from django.contrib.auth.decorators import login_required | |
5 from django.shortcuts import redirect, render | |
6 | |
7 from bandmap.forms import BandForm | |
8 | |
9 | |
10 def map_view(request): | |
11 return render(request, 'bandmap/map.html') | |
12 | |
13 | |
14 @login_required | |
15 def add_band(request): | |
16 """ | |
17 Provides the ability for a user to submit a new band to the map. | |
18 | |
19 """ | |
20 if request.method == 'POST': | |
21 form = BandForm(request.POST) | |
22 if form.is_valid(): | |
23 band = form.save(commit=False) | |
24 band.user = request.user | |
25 band.save() | |
26 redirect('bandmap-thanks') | |
27 else: | |
28 form = BandForm() | |
29 | |
30 return render(request, 'bandmap/add.html', { | |
31 'form': form, | |
32 }) |