Ejemplo n.º 1
0
def redirectIfLoggedIn(request):
    account = auth.getLoggedInAccount(request)
    if account:
        if account.account_type == 'FR':
            return HttpResponseRedirect('/recruiters/dashboard.htm')
        elif account.account_type == 'PU':
            return HttpResponseRedirect('/dashboard.htm')
        else:
            raise Exception('Invalid login state')
Ejemplo n.º 2
0
def render(request, html_file, dict=None, context=None):
    if not dict:    dict = {}
    account = auth.getLoggedInAccount(request)
    if account:
        dict['login_status'] = '<div id="loginStatus">\r\n<a href="/logout.htm">logout</a><br /> <span class="small">' + account.username + '</span>\r\n</div>'
    else:
        dict['login_status'] = '<div id="loginStatus">\r\n<a href="/login.htm">login</a>\r\n</div>'
    
    alerts = []
    if dict.has_key('flash_alerts'):    alerts = dict['flash_alerts']
    else:
        flash_id = dataplus.dictGetSafeVal(request.REQUEST, 'flashId','')
        if flash_id:    alerts = [sysmessages.getFlashMessage(flash_id)]
    if alerts:
        dict['py_scripts'] = '<script type="text/javascript">\n' + string.join(map(lambda x: 'alerts.register("' + x + '");', alerts), '\n') + '\n</script>\n'
    if context:
        return render_to_response(html_file, dict, context)
    else:
        return render_to_response(html_file, dict)        
Ejemplo n.º 3
0
def render(request, html_file, dict=None, context=None):
    if not dict: dict = {}
    account = auth.getLoggedInAccount(request)
    if account:
        dict[
            'login_status'] = '<div id="loginStatus">\r\n<a href="/logout.htm">logout</a><br /> <span class="small">' + account.username + '</span>\r\n</div>'
    else:
        dict[
            'login_status'] = '<div id="loginStatus">\r\n<a href="/login.htm">login</a>\r\n</div>'

    alerts = []
    if dict.has_key('flash_alerts'): alerts = dict['flash_alerts']
    else:
        flash_id = dataplus.dictGetSafeVal(request.REQUEST, 'flashId', '')
        if flash_id: alerts = [sysmessages.getFlashMessage(flash_id)]
    if alerts:
        dict['py_scripts'] = '<script type="text/javascript">\n' + string.join(
            map(lambda x: 'alerts.register("' + x + '");', alerts),
            '\n') + '\n</script>\n'
    if context:
        return render_to_response(html_file, dict, context)
    else:
        return render_to_response(html_file, dict)
Ejemplo n.º 4
0
def redirectIfLoggedIn(request):
    account = auth.getLoggedInAccount(request)
    if account:
        if account.account_type == 'FR':    return HttpResponseRedirect('/recruiters/dashboard.htm')
        elif account.account_type == 'PU':    return HttpResponseRedirect('/dashboard.htm')
        else:   raise Exception('Invalid login state')