From 7ad1e085bc705fddbf06357582afd42d03f4e5da Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Mon, 16 Dec 2013 12:11:43 +0100 Subject: [PATCH] renamed validatebutton into topmenuvalidation --- manifold/static/js/plugin.js | 2 +- .../__init__.py | 6 ++--- .../static/js/topmenuvalidation.opj} | 4 ++-- portal/sliceview.py | 17 +++++++------- ...buttonview.py => topmenuvalidationview.py} | 23 ++++++++++--------- sample/urls.py | 4 ++-- ui/topmenu.py | 4 ++-- 7 files changed, 31 insertions(+), 29 deletions(-) rename plugins/{validatebutton => topmenuvalidation}/__init__.py (85%) rename plugins/{validatebutton/static/js/validatebutton.js => topmenuvalidation/static/js/topmenuvalidation.opj} (92%) rename sample/{validatebuttonview.py => topmenuvalidationview.py} (74%) diff --git a/manifold/static/js/plugin.js b/manifold/static/js/plugin.js index a751e171..4530b518 100644 --- a/manifold/static/js/plugin.js +++ b/manifold/static/js/plugin.js @@ -266,7 +266,7 @@ var Plugin = Class.extend({ /* SPIN */ // use spin() to get our default spin settings (called presets) // use spin(true) to get spin's builtin defaults - // you can also call spin_presets() yourself and tweak what you need to, like validatebutton does + // you can also call spin_presets() yourself and tweak what you need to, like topmenuvalidation does spin: function (presets) { var presets = ( presets === undefined ) ? spin_presets() : presets; try { this.$element.spin(presets); } diff --git a/plugins/validatebutton/__init__.py b/plugins/topmenuvalidation/__init__.py similarity index 85% rename from plugins/validatebutton/__init__.py rename to plugins/topmenuvalidation/__init__.py index 69dddf37..ef7a7334 100644 --- a/plugins/validatebutton/__init__.py +++ b/plugins/topmenuvalidation/__init__.py @@ -1,11 +1,11 @@ from unfold.plugin import Plugin -class ValidateButton (Plugin): +class TopmenuValidation (Plugin): """This plugin is designed to work together with topmenu. It will check to see if user has PI rights at least on one authority, -and if so will enable corresponding button in topmenu. +and if so will enable corresponding validation button in topmenu. A realistic example would have incoming query as @@ -27,7 +27,7 @@ Query.get('ple:user').filter_by('user_hrn', '==', '$user_hrn').select('pi_author return "" def requirements (self): - return { 'js_files': [ 'js/validatebutton.js', 'js/manifold-query.js', + return { 'js_files': [ 'js/topmenuvalidation.js', 'js/manifold-query.js', "js/spin-presets.js", "js/spin.min.js", "js/jquery.spin.js", ], } diff --git a/plugins/validatebutton/static/js/validatebutton.js b/plugins/topmenuvalidation/static/js/topmenuvalidation.opj similarity index 92% rename from plugins/validatebutton/static/js/validatebutton.js rename to plugins/topmenuvalidation/static/js/topmenuvalidation.opj index e8cda230..6cfc383c 100644 --- a/plugins/validatebutton/static/js/validatebutton.js +++ b/plugins/topmenuvalidation/static/js/topmenuvalidation.opj @@ -7,7 +7,7 @@ var debug=false; // debug=true - var ValidateButton = Plugin.extend({ + var TopmenuValidation = Plugin.extend({ init: function(options, element) { this._super(options, element); @@ -39,6 +39,6 @@ }, }); - $.plugin('ValidateButton', ValidateButton); + $.plugin('TopmenuValidation', TopmenuValidation); })(jQuery); diff --git a/portal/sliceview.py b/portal/sliceview.py index ff4cc5e5..91d60ef3 100644 --- a/portal/sliceview.py +++ b/portal/sliceview.py @@ -10,7 +10,7 @@ from manifold.manifoldapi import execute_query from ui.topmenu import topmenu_items, the_user -from plugins.validatebutton import ValidateButton +from plugins.topmenuvalidation import TopmenuValidation from plugins.raw import Raw from plugins.stack import Stack from plugins.tabs import Tabs @@ -428,14 +428,15 @@ class SliceView (LoginRequiredAutoLogoutView): # even though this plugin does not have any html materialization, the corresponding domid # must exist because it is searched at init-time to create the JS plugin # so we simply piggy-back the target button here - validatebutton = ValidateButton (page=page, - # see above - domid='topmenu-validation', - query=query_pi_auths, - # this one is the target for a $.show() when the query comes back - button_domid="topmenu-validation") + topmenuvalidation = TopmenuValidation ( + page=page, + # see above + domid='topmenu-validation', + query=query_pi_auths, + # this one is the target for a $.show() when the query comes back + button_domid="topmenu-validation") # although the result does not matter, rendering is required for the JS init code to make it in the page - validatebutton.render(request) + topmenuvalidation.render(request) # end topmenu addition # variables that will get passed to the view-unfold1.html template diff --git a/sample/validatebuttonview.py b/sample/topmenuvalidationview.py similarity index 74% rename from sample/validatebuttonview.py rename to sample/topmenuvalidationview.py index 5c861f7c..4f33dda1 100644 --- a/sample/validatebuttonview.py +++ b/sample/topmenuvalidationview.py @@ -9,11 +9,11 @@ from unfold.page import Page from ui.topmenu import topmenu_items, the_user -from plugins.validatebutton import ValidateButton +from plugins.topmenuvalidation import TopmenuValidation -class ValidateButtonView (TemplateView): +class TopmenuValidationView (TemplateView): - # mention a user name in the URL as .../trash/simplevalidatebutton/ple.inria.thierry_parmentelat + # mention a user name in the URL as .../trash/simpletopmenuvalidation/ple.inria.thierry_parmentelat def get (self, request, username='ple.inria.thierry_parmentelat'): if username=='logged': username='$user_hrn' @@ -26,15 +26,16 @@ class ValidateButtonView (TemplateView): # even though this plugin does not have any html materialization, the corresponding domid # must exist because it is searched at init-time to create the JS plugin # so we simply piggy-back the target button here - validatebutton = ValidateButton (page=page, - # see above - domid='topmenu-validation', - query=query_pi_auths, - # this one is the target for enabling when the query comes back - button_domid="topmenu-validation") + topmenuvalidation = TopmenuValidation ( + page=page, + # see above + domid='topmenu-validation', + query=query_pi_auths, + # this one is the target for enabling when the query comes back + button_domid="topmenu-validation") # there is a need to call render() for exposing the query and creating the js plugin # even though this returns an empty string - validatebutton.render(request) + topmenuvalidation.render(request) # variables that will get passed to the view-unfold1.html template @@ -44,7 +45,7 @@ class ValidateButtonView (TemplateView): template_env ['unfold_main'] = '

Some title

' # more general variables expected in the template - template_env [ 'title' ] = 'simple validatebutton %(username)s'%locals() + template_env [ 'title' ] = 'simple topmenuvalidation %(username)s'%locals() # the menu items on the top template_env [ 'topmenu_items' ] = topmenu_items('Slice', request) # so we can see who is logged diff --git a/sample/urls.py b/sample/urls.py index 0d06e3e9..2edfcd0e 100644 --- a/sample/urls.py +++ b/sample/urls.py @@ -25,7 +25,7 @@ from sample.views import WebSocketsView, WebSockets2View import sample.querytableview import sample.querygridview -import sample.validatebuttonview +import sample.topmenuvalidationview urlpatterns = patterns( '', @@ -37,5 +37,5 @@ urlpatterns = patterns( url(r'^dashboard/?$', 'sample.dashboardview.dashboard_view'), url(r'^querytable/(?P[\w\.]+)/?$', sample.querytableview.QueryTableView.as_view()), url(r'^querygrid/(?P[\w\.]+)/?$', sample.querygridview.QueryGridView.as_view()), - url(r'^validatebutton/(?P[\w\._]+)/?$', sample.validatebuttonview.ValidateButtonView.as_view()), + url(r'^topmenuvalidation/(?P[\w\._]+)/?$', sample.topmenuvalidationview.TopmenuValidationView.as_view()), ) diff --git a/ui/topmenu.py b/ui/topmenu.py index d0238788..c23adf7b 100644 --- a/ui/topmenu.py +++ b/ui/topmenu.py @@ -13,7 +13,7 @@ from manifold.core.query import Query # , ..] # see also templates/widget-topmenu.html for how these items are put together -# and plugins/validatebutton for how this hident button is turned on when necessary +# and plugins/topmenuvalidation for how this hident button is turned on when necessary # current: the beginning of the label in the menu that you want to outline def topmenu_items (current,request=None): @@ -59,7 +59,7 @@ def topmenu_items (current,request=None): #### result.append({'label':'Validation', 'href': '/portal/validate/'}) ### result.append({'label':'Validation', 'href': '/portal/validate/'}) # always create a disabled button for validation, and let the - # validatebutton plugin handle that asynchroneously, based on this domid + # topmenuvalidation plugin handle that asynchroneously, based on this domid result.append({'label':'Validation', 'href': '/portal/validate/', 'domid':'topmenu-validation', 'disabled':True}) dropdown = [] dropdown.append({'label':'Platforms', 'href': '/portal/platforms/'}) -- 2.43.0