Merge branch 'fibre' of ssh://git.onelab.eu/git/myslice into fibre
[unfold.git] / portal / documentationview.py
1 # this somehow is not used anymore - should it not be ?
2 from django.core.context_processors import csrf
3 from django.http import HttpResponseRedirect
4 from django.contrib.auth import authenticate, login, logout
5 from django.template import RequestContext
6 from django.shortcuts import render_to_response
7 from django.shortcuts import render
8
9 from unfold.loginrequired import FreeAccessView
10
11 from manifoldapi.manifoldresult import ManifoldResult
12 from ui.topmenu import topmenu_items, the_user
13 from myslice.configengine import ConfigEngine
14
15 from myslice.theme import ThemeView
16
17 class DocumentationView (FreeAccessView, ThemeView):
18     template_name = 'documentationview.html'
19         
20     # expose this so we can mention the backend URL on the welcome page
21     def default_env (self):
22         return { 
23                  'MANIFOLD_URL':ConfigEngine().manifold_url(),
24                  }
25
26     def post (self,request):
27         env = self.default_env()
28         env['theme'] = self.theme
29         return render_to_response(self.template, env, context_instance=RequestContext(request))
30
31     def get (self, request, state=None):
32         env = self.default_env()
33
34         if request.user.is_authenticated(): 
35             env['person'] = self.request.user
36         else: 
37             env['person'] = None
38     
39         env['theme'] = self.theme
40     
41
42         env['username']=the_user(request)
43         env['topmenu_items'] = topmenu_items(None, request)
44         if state: env['state'] = state
45         elif not env['username']: env['state'] = None
46         # use one or two columns for the layout - not logged in users will see the login prompt
47         env['layout_1_or_2']="layout-unfold2.html" if not env['username'] else "layout-unfold1.html"
48         
49         
50         return render_to_response(self.template, env, context_instance=RequestContext(request))
51