X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fhomeview.py;h=efdf71e1e97a6f8ba4d513017c2c056eef273f88;hb=f0f76a08ca9dc5d208e1521a73ba1ba60a3c0065;hp=b6af0644e4baa0c4d5ffa58241052866f737c516;hpb=9d9c9d79c1bb1b54d1c402a7f4c0b895e294e5ef;p=myslice.git diff --git a/portal/homeview.py b/portal/homeview.py index b6af0644..efdf71e1 100644 --- a/portal/homeview.py +++ b/portal/homeview.py @@ -9,15 +9,14 @@ from unfold.loginrequired import FreeAccessView from manifold.manifoldresult import ManifoldResult from ui.topmenu import topmenu_items, the_user -from myslice.config import Config +from myslice.configengine import ConfigEngine class HomeView (FreeAccessView): # expose this so we can mention the backend URL on the welcome page def default_env (self): - config=Config() return { - 'MANIFOLD_URL':config.manifold_url(), + 'MANIFOLD_URL':ConfigEngine().manifold_url(), } def post (self,request): @@ -33,11 +32,13 @@ class HomeView (FreeAccessView): # . 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: @@ -48,10 +49,12 @@ class HomeView (FreeAccessView): 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,6 +63,8 @@ class HomeView (FreeAccessView): env['username']=the_user(request) env['topmenu_items'] = topmenu_items(None, request) if state: env['state'] = state - elif not env['username']: env['state'] = "Please sign in" + elif not env['username']: env['state'] = None + # 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))