Beispiel #1
0
def handle(request):
    if request.method == 'GET':
        if (dataplus.dictGetVal(request.REQUEST, 'action') == 'logout'):
            siteaction.doLogout(request)
        return siteaction.render_to_response('alt-index.htm')
        
    elif request.method == 'POST':
        return {
            'login':siteaction.doLogin
        }[dataplus.dictGetVal(request.REQUEST,'action')](request)
Beispiel #2
0
def handle(request):
    if not (request.method == 'GET' and dataplus.dictGetVal(request.REQUEST, 'action') == 'logout'):
        #handling the user specific sub domain request...
        user = siteaction.getUserFromRequest(request)
        if user:
            return profiles_show.handle(request, user.username)
        #handling over
    
    if request.method == 'GET': 
        if (dataplus.dictGetVal(request.REQUEST, 'action') == 'logout'):
            siteaction.doLogout(request)
            
        if siteaction.getLoggedInUser(request):
            return HttpResponseRedirect('/me/')
        
        countries = models.Country.objects.all().order_by('name')
        country_select_html = hotmetal.elemSelect([('Select', '')], countries,
            lambda x:x.name, lambda x:x.code, '', 'name="country" id="country" style="width:160px"')
        
        industry_cats = models.IndustryCategory.objects.all().order_by('id')
        industry_cats_html = hotmetal.elemSelect([('Select', '')], industry_cats,
            lambda x:x.name, lambda x:x.name, '', 'name="industry_category" id="industry_category" style="width:160px"')
        
        experience_select_html = hotmetal.elemSelect([('Select', '-1')], range(0,51),
            lambda x:x, lambda x:x, '', 'name="experience" id="experience" style="width:90px"')
            
        return siteaction.render_to_response('index.htm',
            {'country_select_html':country_select_html,
            'industry_categories_html':industry_cats_html,
            'experience_select_html':experience_select_html})
        
    elif request.method == 'POST':
        return {
            'login':siteaction.doLogin,
            'signup':signupUser,
        }[dataplus.dictGetVal(request.REQUEST,'action')](request)
def handle(request):
    action_id = ''
    random_key = ''
    if dataplus.dictGetVal(request.REQUEST, 'inviteId'):
        action_id = 'inviteId'
        random_key = dataplus.dictGetVal(request.REQUEST, 'inviteId')
    elif dataplus.dictGetVal(request.REQUEST, 'commInviteId'):
        action_id = 'commInviteId'
        random_key = dataplus.dictGetVal(request.REQUEST, 'commInviteId')
    elif dataplus.dictGetVal(request.REQUEST, 'commFriendInviteId'):
        action_id = 'commFriendInviteId'
        random_key = dataplus.dictGetVal(request.REQUEST, 'commFriendInviteId')
    
    if not action_id:
        return HttpResponseRedirect('/')
    
    username = dataplus.dictGetVal(request.REQUEST, 'user')
    if username:        
        myself = siteaction.getLoggedInUser(request)
        if myself and myself.username == username:
            success, response = codejar_invites.processInvitations(myself, [action_id + '=' + random_key])
            return response
        else:
            siteaction.doLogout(request)
    
    if action_id == 'inviteId':
        friend_invite = dataplus.returnIfExists(models.FriendInvitation.objects.filter(invite_random_key=random_key))
    elif action_id == 'commInviteId':
        comm_invite = dataplus.returnIfExists(models.CommunityInvitation.objects.filter(invite_random_key=random_key))
    elif action_id == 'commFriendInviteId':
        friend_invite = dataplus.returnIfExists(models.FriendInvitation.objects.filter(invite_random_key=random_key))
        comm_invite = dataplus.returnIfExists(models.CommunityInvitation.objects.filter(invite_random_key=random_key))
    
    invited_by = None
    if action_id == 'inviteId' or action_id == 'commFriendInviteId':
        if friend_invite:
            invited_by = friend_invite.sent_by
            invited_by.image_url = dataplus.getStaticUrl(invited_by.image_size3_file_path)
        else:
            return HttpResponseRedirect('/login.htm')   ##TODO: Have to show a better response that invite doesn't exist
    
    if action_id == 'commInviteId' or action_id == 'commFriendInviteId':
        if comm_invite:
            invited_by = comm_invite.sent_by
            invited_by.image_url = dataplus.getStaticUrl(invited_by.image_size3_file_path)
            invited_comm = comm_invite.community
            invited_comm.image_url = dataplus.getStaticUrl(invited_comm.image_size3_file_path)
        else:
            return HttpResponseRedirect('/login.htm')   ##TODO: Have to show a better response that invite doesn't exist
    
    welcome_text = 'You have been invited to join Socialray by '+ invited_by.name + '. Socialray is a ' + \
        'Professional Networking site, where you can showcase your skills and expertise, ' + \
        'stay in touch with friends and colleagues, and a lot more. Come onboard, and find out!'
    
##    welcome_text = {'inviteId':'You were invited to join Socialray by ' + invited_by.name + '.',
##                    'commInviteId':'You were invited to join ' + invited_comm.name + ' by ' + invited_by.name + '.',
##                    'commFriendInviteId':'You were invited to join ' + invited_comm.name + ' by ' + invited_by.name + '.'}[action_id]
    
    login_url = '/login.htm?returnUrl=' + cgi.escape('/me/processinvites.htm?' + action_id + '=' + random_key)
    return siteaction.render_to_response('me/acceptinvite.htm', 
                                {'welcome_text':welcome_text,
                                'invited_by':invited_by,
                                'invited_comm':invited_comm,
                                'signup_url':'/me/signup.htm?' + action_id + '=' + random_key,
                                'login_url':login_url,
                                'invited_by_text':dataplus.getPreviewText(invited_by.hilite,500)})