From 83f238a32f62a34370f24d69e85823c709d95627 Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Tue, 12 Nov 2013 16:39:46 +0100 Subject: [PATCH] homeview and platformsview now use layout-unfold1 or layout-unfold2 depending on whether user is logged in or not --- debug_platform/views.py | 2 +- portal/homeview.py | 4 ++++ portal/platformsview.py | 2 ++ portal/portalpage.py | 4 ++-- portal/sliceview.py | 4 ++-- portal/templates/account-view.html | 2 +- portal/templates/contact.html | 2 +- portal/templates/contact_sent.html | 2 +- portal/templates/dashboard.html | 2 +- portal/templates/home-view.html | 13 ++++++------- portal/templates/platform.html | 2 +- portal/templates/platforms.html | 9 +++++++-- portal/templates/register_user_wizard.html | 2 +- portal/templates/registration_view.html | 2 +- portal/templates/resource.html | 2 +- portal/templates/slice-request-ack-view.html | 2 +- portal/templates/slice-request-view.html | 2 +- portal/templates/user_register.html | 2 +- portal/templates/user_register_complete.html | 2 +- portal/templates/validate_pending.html | 2 +- portal/views.py | 2 +- trash/dashboard.py | 6 +++--- trash/pluginview.py | 4 ++-- trash/sampleviews.py | 6 +++--- trash/templates/view-scroll.html | 8 ++++---- trash/templates/view-tab.html | 8 ++++---- trash/templates/view-unfold2.html | 12 ++++++------ ui/templates/layout-unfold1.html | 6 +++--- ui/templates/layout-unfold2.html | 12 ++++++------ ui/templates/view-unfold1.html | 6 +++--- 30 files changed, 72 insertions(+), 62 deletions(-) diff --git a/debug_platform/views.py b/debug_platform/views.py index e6b0c955..ead4ed7e 100644 --- a/debug_platform/views.py +++ b/debug_platform/views.py @@ -45,7 +45,7 @@ class PlatformView(TemplateView): context = super(PlatformView, self).get_context_data(**kwargs) context['ALL_STATIC'] = "all_static" - context['unfold1_main'] = debug_platform.render(self.request) + context['unfold_main'] = debug_platform.render(self.request) # XXX This is repeated in all pages # more general variables expected in the template diff --git a/portal/homeview.py b/portal/homeview.py index b6af0644..5b822212 100644 --- a/portal/homeview.py +++ b/portal/homeview.py @@ -33,6 +33,8 @@ 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 + 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 @@ -61,5 +63,7 @@ class HomeView (FreeAccessView): 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)) diff --git a/portal/platformsview.py b/portal/platformsview.py index 12e9485e..67446436 100644 --- a/portal/platformsview.py +++ b/portal/platformsview.py @@ -48,4 +48,6 @@ class PlatformsView(FreeAccessView): context.update(page.prelude_env()) + context['layout_1_or_2']="layout-unfold2.html" if not context['username'] else "layout-unfold1.html" + return context diff --git a/portal/portalpage.py b/portal/portalpage.py index b5470fd2..f592444d 100644 --- a/portal/portalpage.py +++ b/portal/portalpage.py @@ -15,8 +15,8 @@ class PortalPage(Page): def render(self): template_env = {} - # define 'unfold1_main' to the template engine - the main contents - template_env [ 'unfold1_main' ] = "\n".join(self._content) + # define 'unfold_main' to the template engine - the main contents + template_env [ 'unfold_main' ] = "\n".join(self._content) # more general variables expected in the template template_env [ 'title' ] = 'Test view that combines various plugins' diff --git a/portal/sliceview.py b/portal/sliceview.py index 96bb2184..4037e753 100644 --- a/portal/sliceview.py +++ b/portal/sliceview.py @@ -324,8 +324,8 @@ class SliceView (LoginRequiredAutoLogoutView): # variables that will get passed to the view-unfold1.html template template_env = {} - # define 'unfold1_main' to the template engine - the main contents - template_env [ 'unfold1_main' ] = main_stack.render(request) + # define 'unfold_main' to the template engine - the main contents + template_env [ 'unfold_main' ] = main_stack.render(request) # more general variables expected in the template template_env [ 'title' ] = '%(slicename)s'%locals() diff --git a/portal/templates/account-view.html b/portal/templates/account-view.html index 98da579f..f3c731a9 100644 --- a/portal/templates/account-view.html +++ b/portal/templates/account-view.html @@ -8,7 +8,7 @@ {% endblock %} -{% block unfold1_main %} +{% block unfold_main %}

Platform Access

diff --git a/portal/templates/contact.html b/portal/templates/contact.html index 43adfa5c..3aa9f191 100644 --- a/portal/templates/contact.html +++ b/portal/templates/contact.html @@ -4,7 +4,7 @@ {{ wizard.form.media }} {% endblock %} -{% block unfold1_main %} +{% block unfold_main %}
diff --git a/portal/templates/contact_sent.html b/portal/templates/contact_sent.html index ca12d5f5..62a2ab98 100644 --- a/portal/templates/contact_sent.html +++ b/portal/templates/contact_sent.html @@ -1,6 +1,6 @@ {% extends "layout-unfold1.html" %} -{% block unfold1_main %} +{% block unfold_main %}

Query Received !

diff --git a/portal/templates/dashboard.html b/portal/templates/dashboard.html index 5ca062db..cd136088 100644 --- a/portal/templates/dashboard.html +++ b/portal/templates/dashboard.html @@ -3,7 +3,7 @@ {% block head %} {% endblock %} -{% block unfold1_main %} +{% block unfold_main %}
diff --git a/portal/templates/home-view.html b/portal/templates/home-view.html index 123bc28b..1c887a3b 100644 --- a/portal/templates/home-view.html +++ b/portal/templates/home-view.html @@ -1,12 +1,11 @@ -{% extends 'layout-unfold2.html' %} +{# fine for either layout-unfold1.html (logged in) or layout-unfold2.html (needs a login prompt) #} +{% extends layout_1_or_2 %} -{% block unfold2_margin %} -{% if not username %} +{% block unfold_margin %} {% include 'widget-login.html' %} -{% endif %} -{% endblock unfold2_margin %} +{% endblock unfold_margin %} -{% block unfold2_main %} +{% block unfold_main %} @@ -28,4 +27,4 @@ federated testbeds.

This UI server is connected to the manifold backend running at {{ MANIFOLD_URL }}.

-{% endblock unfold2_main %} +{% endblock unfold_main %} diff --git a/portal/templates/platform.html b/portal/templates/platform.html index d24d9ede..48afd944 100644 --- a/portal/templates/platform.html +++ b/portal/templates/platform.html @@ -4,7 +4,7 @@ {% endblock %} -{% block unfold1_main %} +{% block unfold_main %}

Platform

{{networks}} diff --git a/portal/templates/platforms.html b/portal/templates/platforms.html index 22340661..ee86241b 100644 --- a/portal/templates/platforms.html +++ b/portal/templates/platforms.html @@ -1,10 +1,15 @@ -{% extends "layout-unfold1.html" %} +{# fine for either layout-unfold1.html (logged in) or layout-unfold2.html (needs a login prompt) #} +{% extends layout_1_or_2 %} + +{% block unfold_margin %} +{% include 'widget-login.html' %} +{% endblock unfold_margin %} {% block head %} {% endblock %} -{% block unfold1_main %} +{% block unfold_main %}

Platforms

{{platforms}} diff --git a/portal/templates/register_user_wizard.html b/portal/templates/register_user_wizard.html index 8d1d5280..1f480a1b 100644 --- a/portal/templates/register_user_wizard.html +++ b/portal/templates/register_user_wizard.html @@ -8,7 +8,7 @@ {% endblock %} -{% block unfold1_main %} +{% block unfold_main %}

User registration

diff --git a/portal/templates/registration_view.html b/portal/templates/registration_view.html index 2780d60a..b942b171 100644 --- a/portal/templates/registration_view.html +++ b/portal/templates/registration_view.html @@ -1,6 +1,6 @@ {% extends "layout-unfold1.html" %} -{% block unfold1_main %} +{% block unfold_main %}

OneLab Experimenter Registration

diff --git a/portal/templates/resource.html b/portal/templates/resource.html index 27089a72..63466674 100644 --- a/portal/templates/resource.html +++ b/portal/templates/resource.html @@ -4,7 +4,7 @@ {% endblock %} -{% block unfold1_main %} +{% block unfold_main %}

Resource

{{resource}} diff --git a/portal/templates/slice-request-ack-view.html b/portal/templates/slice-request-ack-view.html index 7ea26ed8..dc98c27a 100644 --- a/portal/templates/slice-request-ack-view.html +++ b/portal/templates/slice-request-ack-view.html @@ -1,6 +1,6 @@ {% extends "layout-unfold1.html" %} -{% block unfold1_main %} +{% block unfold_main %}

Slice request Received !

diff --git a/portal/templates/slice-request-view.html b/portal/templates/slice-request-view.html index 502e380b..7c7a53f0 100644 --- a/portal/templates/slice-request-view.html +++ b/portal/templates/slice-request-view.html @@ -5,7 +5,7 @@ {{ wizard.form.media }} {% endblock %} -{% block unfold1_main %} +{% block unfold_main %} diff --git a/portal/templates/user_register.html b/portal/templates/user_register.html index baa56675..bfb08f12 100644 --- a/portal/templates/user_register.html +++ b/portal/templates/user_register.html @@ -5,7 +5,7 @@ {% endblock %} -{% block unfold1_main %} +{% block unfold_main %}

User registration

diff --git a/portal/templates/user_register_complete.html b/portal/templates/user_register_complete.html index 9e134cfb..35b252e8 100644 --- a/portal/templates/user_register_complete.html +++ b/portal/templates/user_register_complete.html @@ -1,6 +1,6 @@ {% extends "layout-unfold1.html" %} -{% block unfold1_main %} +{% block unfold_main %}

User registration complete !

diff --git a/portal/templates/validate_pending.html b/portal/templates/validate_pending.html index 24a6dbcb..c46fda39 100644 --- a/portal/templates/validate_pending.html +++ b/portal/templates/validate_pending.html @@ -45,7 +45,7 @@ {% endblock %} -{% block unfold1_main %} +{% block unfold_main %}

Pending requests

diff --git a/portal/views.py b/portal/views.py index 167f324e..d454502e 100644 --- a/portal/views.py +++ b/portal/views.py @@ -62,7 +62,7 @@ class PresViewView(FreeAccessView): context = super(PresViewView, self).get_context_data(**kwargs) #context['ALL_STATIC'] = "all_static" - context['unfold1_main'] = pres_view.render(self.request) + context['unfold_main'] = pres_view.render(self.request) # XXX This is repeated in all pages # more general variables expected in the template diff --git a/trash/dashboard.py b/trash/dashboard.py index a9742267..f4bde8fc 100644 --- a/trash/dashboard.py +++ b/trash/dashboard.py @@ -65,8 +65,8 @@ def dashboard_view (request): # variables that will get passed to the view-unfold2.html template template_env = {} - # define 'unfold2_main' to the template engine - template_env [ 'unfold2_main' ] = main_plugin.render(request) + # define 'unfold_main' to the template engine + template_env [ 'unfold_main' ] = main_plugin.render(request) # more general variables expected in the template template_env [ 'title' ] = 'Test view for a full request cycle' @@ -87,7 +87,7 @@ def dashboard_view (request): query=slices_query, ) # likewise but on the side view - template_env [ 'unfold2_margin' ] = related_plugin.render (request) + template_env [ 'unfold_margin' ] = related_plugin.render (request) # add our own css in the mix #page.add_css_files ( 'css/dashboard.css') diff --git a/trash/pluginview.py b/trash/pluginview.py index 491900af..f2003127 100644 --- a/trash/pluginview.py +++ b/trash/pluginview.py @@ -84,8 +84,8 @@ function issue_debug() {console.log("issue_debug");messages.debug("issue_debug") $(function(){$("#bouton").click(issue_debug);}); """) - # define 'unfold1_main' to the template engine - template_env [ 'unfold1_main' ] = main_plugin.render(request) + # define 'unfold_main' to the template engine + template_env [ 'unfold_main' ] = main_plugin.render(request) # more general variables expected in the template template_env [ 'title' ] = 'Single Plugin View' diff --git a/trash/sampleviews.py b/trash/sampleviews.py index 5d257a4f..e1c66d8c 100644 --- a/trash/sampleviews.py +++ b/trash/sampleviews.py @@ -84,8 +84,8 @@ def test_plugin_view (request): title='QuickFilter in main content', criterias=quickfilter_criterias, ) ] ) - # define 'unfold2_main' to the template engine - template_env [ 'unfold2_main' ] = main_plugin.render(request) + # define 'unfold_main' to the template engine + template_env [ 'unfold_main' ] = main_plugin.render(request) ########## related_plugin = StaticList (page=page, @@ -94,7 +94,7 @@ def test_plugin_view (request): list=hard_wired_slice_names, header='Slices') # likewise but on the side view - template_env [ 'unfold2_margin' ] = related_plugin.render (request) + template_env [ 'unfold_margin' ] = related_plugin.render (request) # more general variables expected in the template template_env [ 'title' ] = 'Test Plugin View' diff --git a/trash/templates/view-scroll.html b/trash/templates/view-scroll.html index 5fa9400b..f6f6b933 100644 --- a/trash/templates/view-scroll.html +++ b/trash/templates/view-scroll.html @@ -1,6 +1,6 @@ {% extends 'layout-unfold2.html' %} -{% block unfold2_main %} +{% block unfold_main %} {% insert_str prelude "css/sample.css" %} @@ -11,9 +11,9 @@
scroll3 area {{ lorem }}
scroll4 area {{ lorem }} {{ lorem }} {{ lorem }}
-{% endblock unfold2_main %} +{% endblock unfold_main %} -{% block unfold2_margin %} +{% block unfold_margin %}
-{% endblock unfold2_margin %} +{% endblock unfold_margin %} diff --git a/trash/templates/view-tab.html b/trash/templates/view-tab.html index c3ba335c..6b4472bd 100644 --- a/trash/templates/view-tab.html +++ b/trash/templates/view-tab.html @@ -1,6 +1,6 @@ {% extends 'layout-unfold2.html' %} -{% block unfold2_main %} +{% block unfold_main %} {% insert_str prelude "css/sample.css" %} {% insert prelude_js %} @@ -58,13 +58,13 @@ $(function() {$('#mylougout').click(foo);}) decima et quinta decima. Eodem modo typi, qui nunc nobis videntur parum clari, fiant sollemnes in futurum.
-{% endblock unfold2_main %} +{% endblock unfold_main %} -{% block unfold2_margin %} +{% block unfold_margin %} This text is shorter on purpose Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. -{% endblock unfold2_margin %} +{% endblock unfold_margin %} diff --git a/trash/templates/view-unfold2.html b/trash/templates/view-unfold2.html index 7626ab1e..e1e43171 100644 --- a/trash/templates/view-unfold2.html +++ b/trash/templates/view-unfold2.html @@ -1,9 +1,9 @@ {% extends 'layout-unfold2.html' %} -{% block unfold2_main %} -{{ unfold2_main|safe }} -{% endblock unfold2_main %} +{% block unfold_main %} +{{ unfold_main|safe }} +{% endblock unfold_main %} -{% block unfold2_margin %} -{{ unfold2_margin|safe }} -{% endblock unfold2_margin %} +{% block unfold_margin %} +{{ unfold_margin|safe }} +{% endblock unfold_margin %} diff --git a/ui/templates/layout-unfold1.html b/ui/templates/layout-unfold1.html index fa796b93..7d3ee2e6 100644 --- a/ui/templates/layout-unfold1.html +++ b/ui/templates/layout-unfold1.html @@ -2,8 +2,8 @@ {% block base_content %}
- {% block unfold1_main %} - "The main content area (define block 'unfold1_main')" - {% endblock unfold1_main %} + {% block unfold_main %} + "The main content area (define block 'unfold_main')" + {% endblock unfold_main %}
{% endblock %} diff --git a/ui/templates/layout-unfold2.html b/ui/templates/layout-unfold2.html index 345f57f2..7022aa59 100644 --- a/ui/templates/layout-unfold2.html +++ b/ui/templates/layout-unfold2.html @@ -2,13 +2,13 @@ {% block base_content %}
- {% block unfold2_main %} - "The main content area (define block 'unfold2_main')" - {% endblock unfold2_main %} + {% block unfold_main %} + "The main content area (define block 'unfold_main')" + {% endblock unfold_main %}
- {% block unfold2_margin %} - "The related content area (define block 'unfold2_margin')" - {% endblock unfold2_margin %} + {% block unfold_margin %} + "The related content area (define block 'unfold_margin')" + {% endblock unfold_margin %}
{% endblock %} diff --git a/ui/templates/view-unfold1.html b/ui/templates/view-unfold1.html index 75a10096..8fc17f1f 100644 --- a/ui/templates/view-unfold1.html +++ b/ui/templates/view-unfold1.html @@ -1,5 +1,5 @@ {% extends 'layout-unfold1.html' %} -{% block unfold1_main %} -{{ unfold1_main|safe }} -{% endblock unfold1_main %} +{% block unfold_main %} +{{ unfold_main|safe }} +{% endblock unfold_main %} -- 2.43.0