def match_post(request): """ Form posted to this url, creates the match and returns a link to send the next one to """ if request.method != 'POST': return HttpResponseRedirect("http://keen.to/match") chosen = request.POST.getlist('chosen[]') email = request.POST.get('email') suggested = [] for c in chosen: if c not in options: suggested.append(c) new_match = Match(email_1 = email, chose_1 = chosen, views=[get_client_ip(request)], suggested = suggested) new_match.save() id_ = new_match.id hasher = hashlib.sha1(str(id_)) hash_ = base64.urlsafe_b64encode(hasher.digest())[:5] new_match.hash = hash_ new_match.save() #Email them the number? return render_to_response('match_post.html', {'link' : 'http://keen.to/match/' + hash_, 'hash' : hash_, 'showform' : True}, context_instance=RequestContext(request))