X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fhomeview.py;h=a6656772ae9f08458d645953ea1b63a5bc93439b;hb=6525a09c12184206e7e90578d2e48d9b15006dba;hp=960c8f0d3e2119dcee2d945f90b1e4cff222ecea;hpb=fea9b7e286cc86f11844e371d67d184198afc287;p=myslice.git diff --git a/portal/homeview.py b/portal/homeview.py index 960c8f0d..a6656772 100644 --- a/portal/homeview.py +++ b/portal/homeview.py @@ -1,16 +1,17 @@ # this somehow is not used anymore - should it not be ? -from django.views.generic import View from django.core.context_processors import csrf from django.http import HttpResponseRedirect from django.contrib.auth import authenticate, login, logout from django.template import RequestContext from django.shortcuts import render_to_response +from unfold.loginrequired import FreeAccessView + from manifold.manifoldresult import ManifoldResult from ui.topmenu import topmenu_items, the_user from myslice.config import Config -class HomeView (View): +class HomeView (FreeAccessView): # expose this so we can mention the backend URL on the welcome page def default_env (self): @@ -32,11 +33,13 @@ class HomeView (View): # . a django User in case of success # . or None if the backend could be reached but the authentication failed auth_result = authenticate(token=token) + # use one or two columns for the layout - not logged in users will see the login prompt # high-level errors, like connection refused or the like if isinstance (auth_result, ManifoldResult): manifoldresult = auth_result # let's use ManifoldResult.__repr__ env['state']="%s"%manifoldresult + env['layout_1_or_2']="layout-unfold2.html" return render_to_response('home-view.html',env, context_instance=RequestContext(request)) # user was authenticated at the backend elif auth_result is not None: @@ -47,10 +50,12 @@ class HomeView (View): return HttpResponseRedirect ('/login-ok') else: env['state'] = "Your account is not active, please contact the site admin." + env['layout_1_or_2']="layout-unfold2.html" return render_to_response('home-view.html',env, context_instance=RequestContext(request)) # otherwise else: env['state'] = "Your username and/or password were incorrect." + env['layout_1_or_2']="layout-unfold2.html" return render_to_response('home-view.html',env, context_instance=RequestContext(request)) # login-ok sets state="Welcome to MySlice" in urls.py @@ -60,5 +65,7 @@ class HomeView (View): env['topmenu_items'] = topmenu_items(None, request) if state: env['state'] = state elif not env['username']: env['state'] = "Please sign in" + # use one or two columns for the layout - not logged in users will see the login prompt + env['layout_1_or_2']="layout-unfold2.html" if not env['username'] else "layout-unfold1.html" return render_to_response('home-view.html',env, context_instance=RequestContext(request))