Beispiel #1
0
def signUpMail(request):
    ## User has agreed to the TOS, send e-mail with token.
    try :
        if ('signup_token' in request.session) and ('signupemail' in request.session):
            signup_token = request.session['signup_token']
            to_address = request.session['signupemail']
            from webapp.views.email import activationEmail
            activationEmail(request, signup_token, to_address)
            showPopup = True
            return render_to_response('activate_done.html' if not request.is_ajax() else 'partial_activate_done.html',locals(),context_instance=RequestContext(request))
        else:
            return HttpResponse('Token not found.')
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)
Beispiel #2
0
def signUpMail(request):
    ## User has agreed to the TOS, send e-mail with token.
    try:
        if ('signup_token' in request.session) and ('signupemail'
                                                    in request.session):
            signup_token = request.session['signup_token']
            to_address = request.session['signupemail']
            from webapp.views.email import activationEmail
            activationEmail(request, signup_token, to_address)
            showPopup = True
            return render_to_response(
                'activate_done.html'
                if not request.is_ajax() else 'partial_activate_done.html',
                locals(),
                context_instance=RequestContext(request))
        else:
            return HttpResponse('Token not found.')
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
Beispiel #3
0
def signUpPost(request):
    try:
        form = SignUpForm()
        context = {'suform': form}
        pagename = 'standalone_signup.html'
        partial = 'partial_standalone_signup.html'
        errormessages = {
            '0': ' has already been used.',
            '1':
            ' is not activated yet. Check your email for the activation link.',
            '2': ' is available.'
        }
        if request.method == 'POST':
            form = SignUpForm(request.POST)
            if request.is_ajax():
                pagename = 'ajax_signuppost.html'
            if form.is_valid():
                # serviceResponse = ttagServiceSignupRequest(form.getUser_Name(), form.getFull_Name(), form.getEmail(), form.getPassword(), form.getSN_method(), form.getSN_id())
                # ttagServiceSignupRequestNew(user_name, full_name, email, password, location="",
                #                     site_link="", self_description="", country="", time_zone="", google_map_address="",
                #                     gender="", avatar_url="",
                #                     sn_method="", sn_id="")

                serviceResponse = ttagServiceSignupRequestNew(
                    form.getUser_Name(),
                    form.getFull_Name(),
                    form.getEmail(),
                    form.getPassword(),
                    location=form.clean_location(),
                    site_link=form.clean_website(),
                    self_description=form.clean_bio(),
                    avatar_url=form.clean_avatar(),
                    sn_method=form.clean_sn_method(),
                    sn_id=form.clean_sn_id())
                if serviceResponse.status == 200:
                    respData = serviceResponse.read()
                    import simplejson
                    json_obj = simplejson.loads(respData)
                    #localprint(request, json_obj['msg'])
                    if json_obj['result'] == 'OK':
                        ## user-provided sign-up information is OK
                        request.session['signupemail'] = form.getEmail()
                        request.session['signup_token'] = json_obj[
                            'signup_token']
                        request.session.modified = True
                        if request.is_ajax():
                            showPopup = True
                            suform = SignUpForm()
                            from webapp.views.email import activationEmail
                            activationEmail(request,
                                            request.session['signup_token'],
                                            request.session['signupemail'])
                            return HttpResponse(
                                simplejson.dumps({
                                    'popup':
                                    mark_safe(
                                        render_to_response(
                                            'partial_activate_done.html',
                                            locals(),
                                            context_instance=RequestContext(
                                                request)).content),
                                    'homepageMain':
                                    mark_safe(
                                        render_to_response(
                                            partial,
                                            context,
                                            context_instance=RequestContext(
                                                request)).content)
                                }))
                        else:
                            return HttpResponseRedirect(paths.HTTPS +
                                                        request.get_host() +
                                                        '/signupmail/')
                    else:
                        if form.clean_sn_method(
                        ) == 'twitter' and 'twitter_id' in request.session:
                            twitter_user = get_twitter_user_from_twitter_id(
                                request, request.session.get('twitter_id'))
                            if twitter_user:
                                context['twitter_user'] = twitter_user
                                pagename = 'standalone_twitter.html'
                                partial = 'partial_standalone_twitter.html'
                        if isinstance(json_obj['msg'], dict):
                            if json_obj['msg']['user_name'] == '1' and json_obj[
                                    'msg']['email'] == '1':
                                request.session['activate'] = {
                                    'user_name': form.getUser_Name(),
                                    'email': form.getEmail()
                                }
                                if request.is_ajax():
                                    showPopup = True
                                    return HttpResponse(
                                        simplejson.dumps({
                                            'popup':
                                            mark_safe(
                                                render_to_response(
                                                    'partial_activate.html',
                                                    locals(),
                                                    context_instance=
                                                    RequestContext(
                                                        request)).content)
                                        }))
                                else:
                                    return HttpResponseRedirect(
                                        paths.HTTPS + request.get_host() +
                                        '/signupactivate/')
                            context['signuperror'] = json_obj['msg']
                            context['errormsg'] = {
                                'user_name':
                                'Username ' +
                                errormessages[json_obj['msg']['user_name']],
                                'email':
                                'Email ' +
                                errormessages[json_obj['msg']['email']],
                                "social_network_id":
                                "This social network profile is already associated with another account"
                            }
                            if json_obj['msg']['user_name'] == '0':
                                form._errors['user_name'] = form.error_class(
                                    [context['errormsg']['user_name']])
                            elif json_obj['msg']['email'] == '0':
                                form._errors['email'] = form.error_class(
                                    [context['errormsg']['email']])
                            elif json_obj['msg']['social_network_id'] == '0':
                                form._errors['su_id'] = form.error_class([
                                    "This social network profile is already associated with another account"
                                ])
                        else:
                            return HttpResponse(simplejson.dumps(json_obj))
                else:
                    return HttpResponse(serviceResponse.read())
        else:
            form = SignUpForm()
        context['suform'] = form
        context['siform'] = SignInForm()
        context['loggedin'] = False
        context['request'] = request
        if request.is_ajax():
            import simplejson
            return HttpResponse(
                simplejson.dumps({
                    'headerOuter':
                    mark_safe(
                        render_to_response(
                            'partial_user_dashboard.html',
                            locals(),
                            context_instance=RequestContext(request)).content),
                    'homepageMain':
                    mark_safe(
                        render_to_response(
                            partial,
                            context,
                            context_instance=RequestContext(request)).content)
                }))
        return render_to_response(pagename,
                                  context,
                                  context_instance=RequestContext(request))
    except:
        logger = logging.getLogger(__name__)
        return errorscreen(request, logger, sys)
Beispiel #4
0
def signUpPost(request):
    try :
        form = SignUpForm()
        context = {'suform':form}
        pagename = 'standalone_signup.html'
        partial = 'partial_standalone_signup.html'
        errormessages = {'0':' has already been used.','1':' is not activated yet. Check your email for the activation link.','2':' is available.'}
        if request.method == 'POST':
            form = SignUpForm(request.POST)
            if request.is_ajax():
                pagename = 'ajax_signuppost.html'
            if form.is_valid():
                # serviceResponse = ttagServiceSignupRequest(form.getUser_Name(), form.getFull_Name(), form.getEmail(), form.getPassword(), form.getSN_method(), form.getSN_id())
                # ttagServiceSignupRequestNew(user_name, full_name, email, password, location="", 
                #                     site_link="", self_description="", country="", time_zone="", google_map_address="",
                #                     gender="", avatar_url="",
                #                     sn_method="", sn_id="")
                
                serviceResponse = ttagServiceSignupRequestNew(form.getUser_Name(), form.getFull_Name(), form.getEmail(), form.getPassword(), 
                                    location=form.clean_location(), 
                                    site_link=form.clean_website(), 
                                    self_description=form.clean_bio(),  
                                    avatar_url=form.clean_avatar(),
                                    sn_method=form.clean_sn_method(), 
                                    sn_id=form.clean_sn_id()
                                    )
                if serviceResponse.status == 200:
                    respData = serviceResponse.read()
                    import simplejson
                    json_obj = simplejson.loads(respData)
                    #localprint(request, json_obj['msg'])
                    if json_obj['result'] == 'OK':
                        ## user-provided sign-up information is OK
                        request.session['signupemail'] = form.getEmail()
                        request.session['signup_token'] = json_obj['signup_token']
                        request.session.modified = True
                        if request.is_ajax() :
                            showPopup = True
                            suform = SignUpForm()
                            from webapp.views.email import activationEmail
                            activationEmail(request, request.session['signup_token'], request.session['signupemail'])
                            return HttpResponse(simplejson.dumps({
                                                  'popup':mark_safe(render_to_response('partial_activate_done.html',locals(),context_instance=RequestContext(request)).content),
                                                  'homepageMain':mark_safe(render_to_response(partial,context,context_instance=RequestContext(request)).content)
                                                  }))
                        else : 
                            return HttpResponseRedirect(paths.HTTPS+request.get_host()+'/signupmail/')
                    else:
                        if form.clean_sn_method() == 'twitter' and 'twitter_id' in request.session :
                            twitter_user = get_twitter_user_from_twitter_id(request, request.session.get('twitter_id'))
                            if twitter_user :
                                context['twitter_user'] = twitter_user
                                pagename = 'standalone_twitter.html'
                                partial = 'partial_standalone_twitter.html'
                        if isinstance(json_obj['msg'], dict):
                            if json_obj['msg']['user_name'] == '1' and json_obj['msg']['email'] == '1':
                                request.session['activate'] = {'user_name':form.getUser_Name(),'email':form.getEmail()}
                                if request.is_ajax() :
                                    showPopup = True
                                    return HttpResponse(simplejson.dumps({'popup':mark_safe(render_to_response('partial_activate.html',locals(),context_instance=RequestContext(request)).content)}))
                                else :
                                    return HttpResponseRedirect(paths.HTTPS+request.get_host()+'/signupactivate/')
                            context['signuperror'] = json_obj['msg']
                            context['errormsg'] = {
                                'user_name':'Username '+errormessages[json_obj['msg']['user_name']],
                                'email':'Email '+errormessages[json_obj['msg']['email']],
                                "social_network_id": "This social network profile is already associated with another account"
                            }
                            if json_obj['msg']['user_name'] == '0' :
                                form._errors['user_name'] = form.error_class([context['errormsg']['user_name']])
                            elif json_obj['msg']['email'] == '0' :
                                form._errors['email'] = form.error_class([context['errormsg']['email']])
                            elif json_obj['msg']['social_network_id'] == '0' :
                                form._errors['su_id'] = form.error_class(["This social network profile is already associated with another account"])
                        else:
                            return HttpResponse(simplejson.dumps(json_obj))
                else:
                    return HttpResponse(serviceResponse.read())
        else:
            form = SignUpForm()
        context['suform'] = form    
        context['siform'] = SignInForm()
        context['loggedin'] = False
        context['request'] = request
        if request.is_ajax() :
            import simplejson
            return HttpResponse(simplejson.dumps({
                                                  'headerOuter':mark_safe(render_to_response('partial_user_dashboard.html',locals(),context_instance=RequestContext(request)).content),
                                                  'homepageMain':mark_safe(render_to_response(partial,context,context_instance=RequestContext(request)).content)
                                                  }))
        return render_to_response(pagename, context, context_instance=RequestContext(request))
    except :
        logger=logging.getLogger(__name__)
        return errorscreen(request,logger, sys)