From 561f8f2d90afd2ae4da7c1ee7271dc09754dead2 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Thu, 30 Mar 2017 11:47:03 +0530 Subject: [PATCH] frontpage: Fix issues with hidden property - Fix incorrect use of compound boolean expression in if statement. 'a and b or c' is treated as '((a and b) or c)'. - Allow unhiding a shortcut. - Raise exception when shortcut requested does not exist. This is the Python way. Signed-off-by: Sunil Mohan Adapa --- plinth/frontpage.py | 9 +++------ plinth/templates/index.html | 40 +++++++++++++++++++------------------ 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/plinth/frontpage.py b/plinth/frontpage.py index 29fc06fa1..d50a8a782 100644 --- a/plinth/frontpage.py +++ b/plinth/frontpage.py @@ -68,10 +68,7 @@ def remove_shortcut(shortcut_id): if not match(shortcut)} -def hide_shortcut(shortcut_id): - """ - Makes the shortcut hidden - """ +def hide_shortcut(shortcut_id, hide=True): + """Mark a shortcut as hidden or not hidden.""" global shortcuts - if shortcut_id in shortcuts.keys(): - shortcuts[shortcut_id]['hidden'] = True + shortcuts[shortcut_id]['hidden'] = hide diff --git a/plinth/templates/index.html b/plinth/templates/index.html index 66b3cda2c..2ccb01321 100644 --- a/plinth/templates/index.html +++ b/plinth/templates/index.html @@ -27,25 +27,27 @@ {% if shortcuts %} {% for shortcut in shortcuts %} - {% if shortcut.hidden is False and user.is_authenticated or shortcut.login_required is False %} - + {% if not shortcut.hidden %} + {% if user.is_authenticated or not shortcut.login_required %} + + {% endif %} {% endif %} {% endfor %}