From c5b4da52191579b5762f2571e6511c4a6f5abd22 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jordan=20Aug=C3=A9?= Date: Tue, 3 Dec 2013 17:27:17 +0100 Subject: [PATCH] added sandbox application to help new plugin developers experiment with their plugins --- myslice/settings.py | 1 + myslice/urls.py | 3 +- plugins/myplugin/__init__.py | 2 +- sandbox/__init__.py | 0 sandbox/urls.py | 30 ++++++++++++++++ sandbox/views.py | 67 ++++++++++++++++++++++++++++++++++++ 6 files changed, 101 insertions(+), 2 deletions(-) create mode 100644 sandbox/__init__.py create mode 100644 sandbox/urls.py create mode 100644 sandbox/views.py diff --git a/myslice/settings.py b/myslice/settings.py index c51010a4..ff355e40 100644 --- a/myslice/settings.py +++ b/myslice/settings.py @@ -197,6 +197,7 @@ INSTALLED_APPS = ( # temporary - not packaged # 'trash', 'sample', + 'sandbox' # DEPRECATED # 'django.contrib.formtools', # DEPRECATED ## 'crispy_forms', # DEPRECATED # diff --git a/myslice/urls.py b/myslice/urls.py index 8ff01f93..b204797b 100644 --- a/myslice/urls.py +++ b/myslice/urls.py @@ -56,7 +56,8 @@ urlpatterns = patterns( # # Portal url(r'^portal/', include('portal.urls')), - # Portal + # Sandbox + url(r'^sandbox/', include('sandbox.urls')), url(r'^sample/', include('sample.urls')), # Debug # url(r'^debug/', include('debug_platform.urls')), diff --git a/plugins/myplugin/__init__.py b/plugins/myplugin/__init__.py index 685407dd..958b5767 100644 --- a/plugins/myplugin/__init__.py +++ b/plugins/myplugin/__init__.py @@ -2,7 +2,7 @@ from unfold.plugin import Plugin class MyPlugin(Plugin): - def __init__ (self, query, **settings): + def __init__ (self, query=None, **settings): Plugin.__init__ (self, **settings) self.query=query diff --git a/sandbox/__init__.py b/sandbox/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/sandbox/urls.py b/sandbox/urls.py new file mode 100644 index 00000000..e5b210c9 --- /dev/null +++ b/sandbox/urls.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# +# portal/urls.py: URL mappings for the portal application +# This file is part of the Manifold project. +# +# Authors: +# Jordan Augé +# Copyright 2013, UPMC Sorbonne Universités / LIP6 +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; see the file COPYING. If not, write to the Free Software +# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +from django.views.generic.base import TemplateView +from django.conf.urls import patterns, include, url + +from sandbox.views import MyPluginView + +urlpatterns = patterns('', + url(r'^myplugin/?$', MyPluginView.as_view(), name='myplugin') +) diff --git a/sandbox/views.py b/sandbox/views.py new file mode 100644 index 00000000..dda17718 --- /dev/null +++ b/sandbox/views.py @@ -0,0 +1,67 @@ +# -*- coding: utf-8 -*- +# +# portal/views.py: views for the portal application +# This file is part of the Manifold project. +# +# Authors: +# Jordan Augé +# Mohammed Yasin Rahman +# Copyright 2013, UPMC Sorbonne Universités / LIP6 +# +# This program is free software; you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation; either version 3, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more +# details. +# +# You should have received a copy of the GNU General Public License along with +# this program; see the file COPYING. If not, write to the Free Software +# Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +import json + +from django.http import HttpResponseRedirect, HttpResponse +from django.shortcuts import render +from django.template.loader import render_to_string + +from unfold.loginrequired import FreeAccessView +from ui.topmenu import topmenu_items, the_user + +from unfold.page import Page + +from plugins.myplugin import MyPlugin + +# NOTE +# initially all the portal views were defined in this single file +# all the other ones have now migrated into separate classes/files for more convenience +# I'm leaving these ones here for now as I could not exactly figure what the purpose was +# (i.e. what the correct name should be, as presviewview was a bit cryptic) +class MyPluginView(FreeAccessView): + template_name = "view-unfold1.html" + + def get_context_data(self, **kwargs): + + page = Page(self.request) + +# pres_view = PresView(page = page) + plugin = MyPlugin(page = page, html="

PresView needs to be integrated

") + + context = super(MyPluginView, self).get_context_data(**kwargs) + + context['unfold_main'] = plugin.render(self.request) + + # more general variables expected in the template + context['title'] = 'Sandbox for MyPlugin plugin' + # the menu items on the top + context['topmenu_items'] = topmenu_items('PresView', self.request) + # so we can sho who is logged + context['username'] = the_user(self.request) + + prelude_env = page.prelude_env() + context.update(prelude_env) + + return context + -- 2.43.0