def changeVol(request, id): ''' Change an existing volunteer ''' profile = profileOrRedirect(request.user) try: volunteer = Volunteer.objects.get(user=profile, id=id) except: return HttpResponseRedirect('/records/') if request.method == 'POST': form = VolunteerForm(request.POST, instance=volunteer) if form.is_valid(): vol = form.save(commit=False) vol.date = datetime.date.today() vol.save() return HttpResponseRedirect('/records/') else: form = VolunteerForm(instance=volunteer) context = {'form':form, 'profile':profile} addToContext(profile, context) return render_to_response('records/changeVol.html', context, context_instance=RequestContext(request))
def volunteer(request): ''' Add a new volunteer ''' profile = profileOrRedirect(request.user) if request.method == 'POST': form = VolunteerForm(request.POST) if form.is_valid(): new_volunteer = form.save(commit=False) new_volunteer.user = request.user.get_profile() new_volunteer.date = datetime.date.today() new_volunteer.save() if request.path == '/records/apply/volunteer/': return HttpResponseRedirect('/records/apply/complete/') else: return HttpResponseRedirect('/') else: form = VolunteerForm() context = {'form':form, 'profile':profile} addToContext(profile, context) return render_to_response('records/volunteer.html', context, context_instance=RequestContext(request))
def volunteer(request): ''' Add a new volunteer ''' profile = profileOrRedirect(request.user) if request.method == 'POST': form = VolunteerForm(request.POST) if form.is_valid(): new_volunteer = form.save(commit=False) new_volunteer.user = request.user.get_profile() new_volunteer.date = datetime.date.today() new_volunteer.save() if request.path == '/records/apply/volunteer/': return HttpResponseRedirect('/records/apply/complete/') else: return HttpResponseRedirect('/') else: form = VolunteerForm() context = {'form': form, 'profile': profile} addToContext(profile, context) return render_to_response('records/volunteer.html', context, context_instance=RequestContext(request))
def changeVol(request, id): ''' Change an existing volunteer ''' profile = profileOrRedirect(request.user) try: volunteer = Volunteer.objects.get(user=profile, id=id) except: return HttpResponseRedirect('/records/') if request.method == 'POST': form = VolunteerForm(request.POST, instance=volunteer) if form.is_valid(): vol = form.save(commit=False) vol.date = datetime.date.today() vol.save() return HttpResponseRedirect('/records/') else: form = VolunteerForm(instance=volunteer) context = {'form': form, 'profile': profile} addToContext(profile, context) return render_to_response('records/changeVol.html', context, context_instance=RequestContext(request))