mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
Hide apps and sys icons if user is not an admin
This commit is contained in:
parent
018324a6fc
commit
3248c2573d
@ -23,6 +23,7 @@ from django.utils.translation import ugettext as _, ugettext_noop
|
||||
import re
|
||||
|
||||
from plinth import cfg
|
||||
from plinth.utils import is_user_admin
|
||||
|
||||
|
||||
def common(request):
|
||||
@ -41,5 +42,6 @@ def common(request):
|
||||
'cfg': cfg,
|
||||
'submenu': cfg.main_menu.active_item(request),
|
||||
'active_menu_urls': active_menu_urls,
|
||||
'box_name': _(cfg.box_name)
|
||||
'box_name': _(cfg.box_name),
|
||||
'user_is_admin': is_user_admin(request.user)
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@
|
||||
</div>
|
||||
<div class="collapse navbar-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
{% if user.is_authenticated %}
|
||||
{% if user.is_authenticated and user_is_admin %}
|
||||
<li>
|
||||
<a href="{% url 'index' %}" title="{% trans "Home" %}">
|
||||
{% trans "Home" %}
|
||||
|
||||
@ -18,7 +18,9 @@
|
||||
"""
|
||||
Test module for Plinth's custom context processors.
|
||||
"""
|
||||
from unittest.mock import Mock
|
||||
|
||||
from django.contrib.auth.models import User
|
||||
from django.http import HttpRequest
|
||||
from django.test import TestCase
|
||||
|
||||
@ -35,6 +37,8 @@ class ContextProcessorsTestCase(TestCase):
|
||||
|
||||
request = HttpRequest()
|
||||
request.path = '/aaa/bbb/ccc/'
|
||||
request.user = Mock()
|
||||
request.user.groups.filter().exists = Mock(return_value=True)
|
||||
response = cp.common(request)
|
||||
self.assertIsNotNone(response)
|
||||
|
||||
@ -55,6 +59,8 @@ class ContextProcessorsTestCase(TestCase):
|
||||
"""Verify that the common() function works for border conditions."""
|
||||
request = HttpRequest()
|
||||
request.path = ''
|
||||
request.user = Mock()
|
||||
request.user.groups.filter().exists = Mock(return_value=True)
|
||||
response = cp.common(request)
|
||||
self.assertEqual([], response['active_menu_urls'])
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user