X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=portal%2Fhomeview.py;h=5b822212892597b916a91a675a7c88d219afe456;hb=83f238a32f62a34370f24d69e85823c709d95627;hp=fb0124022644327adca9026f57ca2f9f9d0aa8bf;hpb=6a8cd8d5f11411cdb4bf2510c9be5fd60d72cb50;p=myslice.git diff --git a/portal/homeview.py b/portal/homeview.py index fb012402..5b822212 100644 --- a/portal/homeview.py +++ b/portal/homeview.py @@ -1,20 +1,23 @@ # 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 myslice.viewutils import topmenu_items, the_user +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): + config=Config() return { - 'manifold_url':Config.manifold_url, + 'MANIFOLD_URL':config.manifold_url(), } def post (self,request): @@ -30,6 +33,8 @@ 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 + env['layout_1_or_2']="layout-unfold2.html" if not username else "layout-unfold1.html" # high-level errors, like connection refused or the like if isinstance (auth_result, ManifoldResult): manifoldresult = auth_result @@ -55,8 +60,10 @@ class HomeView (View): def get (self, request, state=None): env = self.default_env() env['username']=the_user(request) - env['topmenu_items'] = topmenu_items('', request) + 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))