This is an automated email from the ASF dual-hosted git repository. brondsem pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/allura.git
commit 491b9237cd36bcd4a9cde68c85bc265427c2fff9 Author: Dave Brondsema <[email protected]> AuthorDate: Mon Jun 14 13:40:29 2021 -0400 [#8368] server-side logic instead of JS to control nav bar download button display --- Allura/allura/nf/allura/css/site_style.css | 1 - Allura/allura/templates/jinja_master/master.html | 23 ---------------------- Allura/allura/templates/jinja_master/nav_menu.html | 2 +- ForgeFiles/forgefiles/files_main.py | 10 ++++------ 4 files changed, 5 insertions(+), 31 deletions(-) diff --git a/Allura/allura/nf/allura/css/site_style.css b/Allura/allura/nf/allura/css/site_style.css index 1f8b4d0..c4755e2 100644 --- a/Allura/allura/nf/allura/css/site_style.css +++ b/Allura/allura/nf/allura/css/site_style.css @@ -4089,5 +4089,4 @@ Nav bar styles moved out of navbar.css since they are more stylistic than layout cursor: pointer !important; height: 3em !important; color:#0077aa !important; - display: none; } diff --git a/Allura/allura/templates/jinja_master/master.html b/Allura/allura/templates/jinja_master/master.html index 3e8b0d8..c905b54 100644 --- a/Allura/allura/templates/jinja_master/master.html +++ b/Allura/allura/templates/jinja_master/master.html @@ -44,10 +44,6 @@ {% do g.register_forge_js('js/memorable.js') %} {% do g.resource_manager.register_widgets(c) %} -{% if c.project %} -{% set files_appconfig = c.project.app_config_by_tool_type('files') %} -{% endif %} - {# paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ #} <!--[if lt IE 7 ]> <html lang="en" class="no-js ie6"> <![endif]--> <!--[if IE 7 ]> <html lang="en" class="no-js ie7"> <![endif]--> @@ -202,25 +198,6 @@ }); }); - -{% if files_appconfig %} -$(document).ready(function(){ - $.ajax({ - url:'{{ files_appconfig.url() }}project_file/', - type:'GET', - success: function(res){ - var count = parseInt(res); - if (count != 0){ - $('#download_button').show(); - } - else{ - $('#download_button').hide(); - } - } -}); -}); -{% endif %} - </script> </body> </html> diff --git a/Allura/allura/templates/jinja_master/nav_menu.html b/Allura/allura/templates/jinja_master/nav_menu.html index 1d754f6..1172e0e 100644 --- a/Allura/allura/templates/jinja_master/nav_menu.html +++ b/Allura/allura/templates/jinja_master/nav_menu.html @@ -45,7 +45,7 @@ {%- endif -%} </a> </h1> - {% if files_appconfig %} + {% if files_appconfig and c.project.app_instance(files_appconfig).has_linked_download() %} <a href="{{ files_appconfig.url() }}download_file" > <button class="btn-home btn-danger" id="download_button" >Download</button> </a> diff --git a/ForgeFiles/forgefiles/files_main.py b/ForgeFiles/forgefiles/files_main.py index 5f32e56..7a48c11 100755 --- a/ForgeFiles/forgefiles/files_main.py +++ b/ForgeFiles/forgefiles/files_main.py @@ -85,6 +85,10 @@ class FilesApp(Application): file_object.delete() super(FilesApp, self).uninstall(project) + def has_linked_download(self): + return UploadFiles.query.find({ + 'app_config_id': c.app.config._id, 'linked_to_download': True, 'disabled': False}).count() + def get_parent_folders(linked_file_object=None): @@ -464,12 +468,6 @@ class FilesController(BaseController): else: flash('No file exists') - @expose() - def project_file(self): - files_count = UploadFiles.query.find({ - 'app_config_id': c.app.config._id, 'linked_to_download': True, 'disabled': False}).count() - return str(files_count) - @expose('json:') @require_post() def subscribe(self, subscribe=None, unsubscribe=None):
