def student_donation(request, identifier=None): c = Context(dict( page_title='Donate', teachers=Teacher().get_donate_list(), make_donation=True, )) if identifier == 'search': c['search'] = True if request.GET: first_name = request.GET.get('student_first_name') or None last_name = request.GET.get('student_last_name') or None teacher_name = request.GET.get('teacher_last_name') or None if first_name or last_name or teacher_name: if first_name and last_name: c['search'] = '{0} {1}'.format(first_name, last_name) else: c['search'] = first_name or last_name or teacher_name students = Student().find(first_name, last_name, teacher_name) if students.count(): c['students'] = students else: messages.error(request, 'Could not find Records matching: {0}'.format(c['search'])) c['error'] = True else: messages.error(request, 'You must provide a first or last name') c['error'] = True elif identifier: try: c['student'] = Student.objects.get(identifier=identifier) except: messages.error(request, 'Could not find Student for identity: {0}'.format(identifier)) c['error'] = True c['messages'] = messages.get_messages(request) return render_to_response('donate.html', c, context_instance=RequestContext(request))
def student_donation(request, identifier=None): c = Context(dict(page_title="Donate", teachers=Teacher().get_donate_list(), make_donation=True)) if identifier == "search": c["search"] = True if request.GET: first_name = request.GET.get("student_first_name") or None last_name = request.GET.get("student_last_name") or None teacher_name = request.GET.get("teacher_last_name") or None if first_name or last_name or teacher_name: if first_name and last_name: c["search"] = "{0} {1}".format(first_name, last_name) else: c["search"] = first_name or last_name or teacher_name students = Student().find(first_name, last_name, teacher_name) if students.count(): c["students"] = students else: messages.error(request, "Could not find Records matching: {0}".format(c["search"])) c["error"] = True else: messages.error(request, "You must provide a first or last name") c["error"] = True elif identifier: try: c["student"] = Student.objects.get(identifier=identifier) except: messages.error(request, "Could not find Student for identity: {0}".format(identifier)) c["error"] = True c["messages"] = messages.get_messages(request) return render_to_response("donate.html", c, context_instance=RequestContext(request))