def resources(request, city_tag): city = all_cities.get(city_tag, None) #result = "" if city: #result += "Found match: %s" % city[0].name result = "<h2>%s, %s Resources:</h2>" % (city['name'], city['state']) if resource_data.has_key(city['tag']): result += resource_data[city['tag']] context = {'city': city, 'result':result} return render(request, 'resources.html', context ) else: url = "/city/new" return redirect(url)
def resources(request, city_tag): city = all_cities.get(city_tag, None) #result = "" if city: #result += "Found match: %s" % city[0].name result = "<h2>%s, %s Resources:</h2>" % (city['name'], city['state']) if resource_data.has_key(city['tag']): result += resource_data[city['tag']] context = {'city': city, 'result': result} return render(request, 'resources.html', context) else: url = "/city/new" return redirect(url)
def city_map(request, city_tag="bloomington_in"): #city = City.objects.filter(tag=city_tag) city = all_cities.get(city_tag, None) #default zoom = 14 if not city: url = "/city/new" return redirect(url) else: context = {'lat': city['lat'], 'lng': city['lng'], 'zoom': zoom, } return render(request, 'map.html', context )
def city_map(request, city_tag="bloomington_in"): #city = City.objects.filter(tag=city_tag) city = all_cities.get(city_tag, None) #default zoom = 14 if not city: url = "/city/new" return redirect(url) else: context = { 'lat': city['lat'], 'lng': city['lng'], 'zoom': zoom, } return render(request, 'map.html', context)
def change(request, city_tag=None): if request.method == 'POST': # If the form has been submitted... form = CitySelectForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass # Process the data in form.cleaned_data # ... #return HttpResponseRedirect('/thanks/') # Redirect after POST city_tag = form.cleaned_data['choice'] if city_tag == "other": context = {'city': None, 'result':"Adding a new city..."} return render(request, 'change_city.html', context ) else: #city = City.objects.filter(tag=city_tag) city = all_cities.get(city_tag, None) #result = "" if city: #result += "Found match: %s" % city[0].name #result += "Found match: %s" % city['name'] #update the city in our session for future reference: request.session['city'] = city assert city['tag'] == city_tag else: #result += "No match found!" pass #look latest city up from session (either just set, or previously): stored = request.session.get('city', None) if stored: url = "/city/%s" % stored['tag'] return redirect(url) else: context = {'city': city, 'result':"Unknown option..."} return render(request, 'change_city.html', context )
def change(request, city_tag=None): if request.method == 'POST': # If the form has been submitted... form = CitySelectForm(request.POST) # A form bound to the POST data if form.is_valid(): # All validation rules pass # Process the data in form.cleaned_data # ... #return HttpResponseRedirect('/thanks/') # Redirect after POST city_tag = form.cleaned_data['choice'] if city_tag == "other": context = {'city': None, 'result': "Adding a new city..."} return render(request, 'change_city.html', context) else: #city = City.objects.filter(tag=city_tag) city = all_cities.get(city_tag, None) #result = "" if city: #result += "Found match: %s" % city[0].name #result += "Found match: %s" % city['name'] #update the city in our session for future reference: request.session['city'] = city assert city['tag'] == city_tag else: #result += "No match found!" pass #look latest city up from session (either just set, or previously): stored = request.session.get('city', None) if stored: url = "/city/%s" % stored['tag'] return redirect(url) else: context = {'city': city, 'result': "Unknown option..."} return render(request, 'change_city.html', context)