1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-12 09:17:41 +03:00

bug #2978: Honor default group views. Allow users to use secondary groups default views

This commit is contained in:
Ruben S. Montero 2014-07-22 20:49:21 +02:00
parent 1cd80dc69e
commit 7ecf1bcd7b

View File

@ -19,10 +19,19 @@ require 'json'
require 'pp'
VIEWS_CONFIGURATION_FILE = ETC_LOCATION + "/sunstone-views.yaml"
VIEWS_CONFIGURATION_DIR = ETC_LOCATION + "/sunstone-views/"
# This class is used by Sunstone to set and return the views available to a user
# as well as available tabs.
class SunstoneViews
############################################################################
# Class Constants:
# - Configuration files
# - sunstone-views.yaml includes default group views
############################################################################
VIEWS_CONFIGURATION_FILE = ETC_LOCATION + "/sunstone-views.yaml"
VIEWS_CONFIGURATION_DIR = ETC_LOCATION + "/sunstone-views/"
def initialize
@views_config = YAML.load_file(VIEWS_CONFIGURATION_FILE)
@ -49,7 +58,8 @@ class SunstoneViews
end
# Return the name of the views avialable to a user. Those defined in the
# group template and configured in this sunstone.
# group template and configured in sunstone. If no view is defined in a
# group defaults in sunstone-views.yaml will be used.
#
def available_views(user_name, group_name)
onec = $cloud_auth.client(user_name)
@ -67,14 +77,15 @@ class SunstoneViews
if group["TEMPLATE/SUNSTONE_VIEWS"]
views_array = group["TEMPLATE/SUNSTONE_VIEWS"].split(",")
available << views_array.each{|v| v.strip!}
elsif @views_config['groups']
available << @views_config['groups'][group.name]
end
gadmins = group["TEMPLATE/GROUP_ADMINS"]
gadmins = group["TEMPLATE/GROUP_ADMINS"]
gadmins_views = group["TEMPLATE/GROUP_ADMIN_VIEWS"]
if gadmins &&
gadmins.split(',').include?(user_name) &&
group["TEMPLATE/GROUP_ADMIN_VIEWS"]
views_array = group["TEMPLATE/GROUP_ADMIN_VIEWS"].split(",")
if gadmins && gadmins.split(',').include?(user_name) && gadmins_views
views_array = gadmins_views.split(",")
available << views_array.each{|v| v.strip!}
end
}