1
0
mirror of https://github.com/dkmstr/openuds.git synced 2025-01-11 05:17:55 +03:00

Fixed navbar to not allow "root" user to access preferences (root user

will never own services)
This commit is contained in:
Adolfo Gómez García 2015-01-15 09:24:58 +01:00
parent ea087fce53
commit 2959a878af
3 changed files with 13 additions and 3 deletions

View File

@ -124,8 +124,11 @@ class UserPrefsManager(object):
logger.debug(name)
prefs.append({'module': mod, 'name': p.getName(), 'value': form.cleaned_data[name]})
user.preferences.all().delete()
try:
for p in prefs:
user.preferences.create(module=p['module'], name=p['name'], value=p['value'])
except Exception: # User does not exists
logger.info('Trying to dave user preferences failed (probably root user?)')
return None
def processGuiForUserPreferences(self, user, data):

View File

@ -1,5 +1,6 @@
{% load i18n html5 static %}
{% preferences_allowed as show_prefs %}
{% root_id as rootid %}
<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
@ -37,7 +38,7 @@
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-user"></i> {{ user.real_name }} <b class="caret"></b></a>
<ul class="dropdown-menu">
{% if show_prefs %}
{% if show_prefs and user.id != rootid %}
<li><a href="{% url "uds.web.views.prefs" %}"><span class="fa fa-edit"></span> {% trans 'Preferences' %}</a></li>
{% endif %}
{% if user.staff_member or user.is_admin %}

View File

@ -34,6 +34,7 @@ from __future__ import unicode_literals
from django import template
from uds.core.util import html
from uds.core.auths.auth import ROOT_ID
from uds.core.util.Config import GlobalConfig
from uds.models.Image import Image
@ -95,6 +96,11 @@ def preferences_allowed():
return GlobalConfig.PREFERENCES_ALLOWED.getBool(True)
@register.assignment_tag
def root_id():
return ROOT_ID
@register.assignment_tag
def image_size():
return Image.MAX_IMAGE_SIZE