示例#1
0
文件: fb.py 项目: daasara/riba
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))
示例#2
0
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))
示例#3
0
文件: fb.py 项目: daasara/riba
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))
示例#4
0
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)
    )