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 <sunil@medhas.org>
This commit is contained in:
Sunil Mohan Adapa committed 2017-03-30 12:04:48 +05:30
1 parent 6e2f70063b
commit 561f8f2d90
2 files changed
+24 -25

No files matched your search

+3 -6
View File
@@ -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
+21 -19
View File
@@ -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 %}
<div class="col-sm-3">
<ul class="nav nav-pills nav-stacked">
{% if selected_id == shortcut.id %}
<li class="active">
<a href="{{ shortcut.url }}" class="active">
{% else %}
<li>
<a href="{{ shortcut.url }}">
{% endif %}
<center>
<img src="{% static 'theme/icons/' %}{{ shortcut.icon }}.png" style="max-width: 100px; height: 100px" />
<br>
{{ shortcut.label|linebreaks }}
</center>
</a>
</li>
</ul>
</div>
{% if not shortcut.hidden %}
{% if user.is_authenticated or not shortcut.login_required %}
<div class="col-sm-3">
<ul class="nav nav-pills nav-stacked">
{% if selected_id == shortcut.id %}
<li class="active">
<a href="{{ shortcut.url }}" class="active">
{% else %}
<li>
<a href="{{ shortcut.url }}">
{% endif %}
<center>
<img src="{% static 'theme/icons/' %}{{ shortcut.icon }}.png" style="max-width: 100px; height: 100px" />
<br>
{{ shortcut.label|linebreaks }}
</center>
</a>
</li>
</ul>
</div>
{% endif %}
{% endif %}
{% endfor %}