def register_for_deals(request): form = DealRegisterForm() if request.method == 'POST': form = DealRegisterForm(request.POST) error = [] if form.is_valid(): name = form.cleaned_data['name'].strip() email_id = form.cleaned_data['email'].strip() mobile_no = form.cleaned_data['mobile'].strip() info = subscribe_user(request, name, email_id, mobile_no, None) # if info['is_valid']: log.info("Email:%s and Mobile:%s subscribed " % (email_id, mobile_no)) # response = HttpResponse(simplejson.dumps(dict(status='ok',msg='subscribed'))) info['status'] = 'ok' temp = render_to_string('fb/subscription_popup.html', info) info['html'] = temp response = HttpResponse(simplejson.dumps(info)) utils.set_user_subscribed_for_deals(request) utils.set_cookie(request, response, 'nevermissadeal', True) return response # errors = info['errors'] # return HttpResponse(simplejson.dumps(dict(status='failed',error=errors))) else: errors = [] # we are restricting to on error per field. for e in form['email'].errors[:1]: errors.append(e) for e in form['mobile'].errors[:1]: errors.append(e) return HttpResponse(simplejson.dumps(dict(status='failed',error=errors))) return render_to_response('fb/popup.html', {'form':form}, context_instance = RequestContext(request))
def register_for_deals(request): form = DealRegisterForm() if request.method == "POST": form = DealRegisterForm(request.POST) error = [] if form.is_valid(): name = form.cleaned_data["name"].strip() email_id = form.cleaned_data["email"].strip() mobile_no = form.cleaned_data["mobile"].strip() info = subscribe_user(request, name, email_id, mobile_no, None) # if info['is_valid']: log.info("Email:%s and Mobile:%s subscribed " % (email_id, mobile_no)) # response = HttpResponse(simplejson.dumps(dict(status='ok',msg='subscribed'))) info["status"] = "ok" temp = render_to_string("fb/subscription_popup.html", info) info["html"] = temp response = HttpResponse(simplejson.dumps(info)) utils.set_user_subscribed_for_deals(request) utils.set_cookie(request, response, "nevermissadeal", True) return response # errors = info['errors'] # return HttpResponse(simplejson.dumps(dict(status='failed',error=errors))) else: errors = [] # we are restricting to on error per field. for e in form["email"].errors[:1]: errors.append(e) for e in form["mobile"].errors[:1]: errors.append(e) return HttpResponse(simplejson.dumps(dict(status="failed", error=errors))) return render_to_response("fb/popup.html", {"form": form}, context_instance=RequestContext(request))
def third_party_register_for_deals(request, source): form = DealRegisterForm() errors = [] if request.method == 'POST': form = DealRegisterForm(request.POST) if form.is_valid(): name = form.cleaned_data['name'].strip() email_id = form.cleaned_data['email'].strip() mobile_no = form.cleaned_data['mobile'].strip() info = subscribe_user(request, name, email_id, mobile_no, source) log.info("Email:%s and Mobile:%s subscribed via %s" % (email_id, mobile_no, source)) utils.set_user_subscribed_for_deals(request) return render_to_response('fb/%s-register-success.html' % source) else: # we are restricting to on error per field. for e in form['email'].errors[:1]: errors.append(e) for e in form['mobile'].errors[:1]: errors.append(e) return render_to_response('fb/%s-register.html' % source, { 'form':form, 'errors': errors }, context_instance = RequestContext(request))
def third_party_register_for_deals(request, source): form = DealRegisterForm() errors = [] if request.method == "POST": form = DealRegisterForm(request.POST) if form.is_valid(): name = form.cleaned_data["name"].strip() email_id = form.cleaned_data["email"].strip() mobile_no = form.cleaned_data["mobile"].strip() info = subscribe_user(request, name, email_id, mobile_no, source) log.info("Email:%s and Mobile:%s subscribed via %s" % (email_id, mobile_no, source)) utils.set_user_subscribed_for_deals(request) return render_to_response("fb/%s-register-success.html" % source) else: # we are restricting to on error per field. for e in form["email"].errors[:1]: errors.append(e) for e in form["mobile"].errors[:1]: errors.append(e) return render_to_response( "fb/%s-register.html" % source, {"form": form, "errors": errors}, context_instance=RequestContext(request) )