def edit_tutee(request, tutee_id): tutee = get_object_or_404(Tutee, id=tutee_id) submitted = False if request.method == "POST": form = TuteeForm(request.POST, instance=tutee) if form.is_valid(): submitted = True form.save() Notification.objects.edit_tutee(request.user, tutee) else: form = TuteeForm(instance=tutee) return render_to_response('tutees/edit_tutee.html', {'form': form, 'tutee_id': tutee_id, 'tutee': tutee, 'submitted': submitted }, context_instance=RequestContext(request))
def register(request): if request.method == "POST": form = TuteeForm(data=request.POST) if form.is_valid(): tutee = form.save(commit=False) tutee.added_on = datetime.now() tutee.active = True tutee.save() Notification.objects.register_tutee(tutee) messages.success(request, "Tutee successfully added.") return HttpResponseRedirect(reverse('tutees.views.register',args=[])) else: messages.error(request, "Error adding tutee, please see errors below.") else: form = TuteeForm return render_to_response('tutees/register_tutee.html', { 'form':form, 'tutor_or_tutee': 'tutee', }, context_instance=RequestContext(request))