dda1771889915ea1d1a1c6296055d08851a10309
[myslice.git] / sandbox / views.py
1 # -*- coding: utf-8 -*-
2 #
3 # portal/views.py: views for the portal application
4 # This file is part of the Manifold project.
5 #
6 # Authors:
7 #   Jordan AugĂ© <jordan.auge@lip6.fr>
8 #   Mohammed Yasin Rahman <mohammed-yasin.rahman@lip6.fr>
9 # Copyright 2013, UPMC Sorbonne UniversitĂ©s / LIP6
10 #
11 # This program is free software; you can redistribute it and/or modify it under
12 # the terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 3, or (at your option) any later version.
14
15 # This program is distributed in the hope that it will be useful, but WITHOUT
16 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
18 # details.
19
20 # You should have received a copy of the GNU General Public License along with
21 # this program; see the file COPYING.  If not, write to the Free Software
22 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24 import json
25
26 from django.http                import HttpResponseRedirect, HttpResponse
27 from django.shortcuts           import render
28 from django.template.loader     import render_to_string
29
30 from unfold.loginrequired       import FreeAccessView
31 from ui.topmenu                 import topmenu_items, the_user
32
33 from unfold.page                import Page
34
35 from plugins.myplugin           import MyPlugin
36
37 # NOTE
38 # initially all the portal views were defined in this single file
39 # all the other ones have now migrated into separate classes/files for more convenience
40 # I'm leaving these ones here for now as I could not exactly figure what the purpose was 
41 # (i.e. what the correct name should be, as presviewview was a bit cryptic)
42 class MyPluginView(FreeAccessView):
43     template_name = "view-unfold1.html"
44
45     def get_context_data(self, **kwargs):
46
47         page = Page(self.request)
48
49 #        pres_view = PresView(page = page)
50         plugin = MyPlugin(page = page, html="<h1>PresView needs to be integrated</h1>")
51
52         context = super(MyPluginView, self).get_context_data(**kwargs)
53
54         context['unfold_main'] = plugin.render(self.request)
55
56         # more general variables expected in the template
57         context['title'] = 'Sandbox for MyPlugin plugin'
58         # the menu items on the top
59         context['topmenu_items'] = topmenu_items('PresView', self.request)
60         # so we can sho who is logged
61         context['username'] = the_user(self.request)
62
63         prelude_env = page.prelude_env()
64         context.update(prelude_env)
65
66         return context
67