commit 1faf0b9c54de43f14170d321f5417b74df1cb3de
Author: Kostas Papadimitriou <kpap@grnet.gr>
Date:   Thu Jan 5 12:11:01 2012 +0200

    Improved owners of system images configuration, Refs #1748
    
    - allow multiple system owners
    - allow custom owner aliases (displayed in UI)

diff --git a/snf-app/synnefo/settings/common/ui.py b/snf-app/synnefo/settings/common/ui.py
index c09180a..3b6773e 100644
--- a/snf-app/synnefo/settings/common/ui.py
+++ b/snf-app/synnefo/settings/common/ui.py
@@ -93,6 +93,7 @@ UI_FLAVORS_DISK_TEMPLATES_INFO = {
              'description': 'DRBD storage.'},
 }
 
+
 #######################
 # UI BEHAVIOUR SETTINGS
 #######################
@@ -133,3 +134,11 @@ UI_GLANCE_API_URL = '/plankton'
 # set in UI_GLANCE_API_URL, if setting is set to False, ui will
 # request images from Compute API
 UI_ENABLE_GLANCE = True
+
+# a dict of image owner ids and their associate name
+# to be displayed on images list
+UI_SYSTEM_IMAGES_OWNERS = {
+    'admin@synnefo.gr': 'system',
+    'images@synnefo.gr': 'system'
+}
+
diff --git a/snf-app/synnefo/ui/static/snf/js/glance_models.js b/snf-app/synnefo/ui/static/snf/js/glance_models.js
index b5d3759..ed282f4 100644
--- a/snf-app/synnefo/ui/static/snf/js/glance_models.js
+++ b/snf-app/synnefo/ui/static/snf/js/glance_models.js
@@ -27,7 +27,17 @@
 
         display_size: function() {
             return this.get_readable_size();
+        },
+        
+        display_owner: function() {
+            var owner = this.get_owner();
+            if (_.include(_.keys(synnefo.config.system_images_owners)), owner) {
+                return synnefo.config.system_images_owners[owner];
+            } else {
+                return owner;
+            }
         }
+
     })
 
     models.GlanceImages = snf.models.Images.extend({
@@ -87,11 +97,16 @@
         },
 
         get_system_images: function() {
-            return _.filter(this.active(), function(i){ return i.get_owner() == snf.config.system_images_owner })
+            return _.filter(this.active(), function(i) { 
+                return _.include(_.keys(snf.config.system_images_owners), 
+                                 i.get_owner());
+            })
         },
 
         get_personal_images: function() {
-            return _.filter(this.active(), function(i) { return i.get_owner() == snf.user.username });
+            return _.filter(this.active(), function(i) { 
+                return i.get_owner() == snf.user.username 
+            });
         },
 
         get_public_images: function() {
@@ -99,9 +114,12 @@
         },
 
         get_shared_images: function() {
-            return _.filter(this.active(), function(i){ return i.get_owner() != snf.config.system_images_owner && 
+            return _.filter(this.active(), function(i){ 
+                return !_.include(_.keys(snf.config.system_images_owners), 
+                                  i.get_owner()) && 
                                i.get_owner() != snf.user.username &&
-                               !i.is_public() })
+                               !i.is_public();
+            });
         }
 
     })
diff --git a/snf-app/synnefo/ui/static/snf/js/models.js b/snf-app/synnefo/ui/static/snf/js/models.js
index 47b28ae..0df66ff 100644
--- a/snf-app/synnefo/ui/static/snf/js/models.js
+++ b/snf-app/synnefo/ui/static/snf/js/models.js
@@ -229,7 +229,7 @@
         },
 
         get_owner: function() {
-            return this.get('owner') || synnefo.config.system_images_owner;
+            return this.get('owner') || _.keys(synnefo.config.system_images_owners)[0];
         },
 
         get_readable_size: function() {
diff --git a/snf-app/synnefo/ui/static/snf/js/ui/web/ui_create_view.js b/snf-app/synnefo/ui/static/snf/js/ui/web/ui_create_view.js
index 267cb55..9ae0532 100644
--- a/snf-app/synnefo/ui/static/snf/js/ui/web/ui_create_view.js
+++ b/snf-app/synnefo/ui/static/snf/js/ui/web/ui_create_view.js
@@ -363,7 +363,7 @@
                 var value;
                 var method = 'get_' + key.toLowerCase();
                 var display_method = 'display_' + key.toLowerCase();
-                
+                 
                 if (image[display_method]) {
                     value = image[display_method]();
                 } else if (image[method]) {
@@ -425,7 +425,7 @@
                                                   snf.ui.helpers.os_icon_tag(img.escape("OS")),
                                                   _.escape(img.get_readable_size()),
                                                   util.truncate(img.escape("description"), 35),
-                                                  _.escape(img.get_owner())));
+                                                  _.escape(img.display_owner())));
             image.data("image", img);
             image.data("image_id", img.id);
             this.images_list.append(image);
diff --git a/snf-app/synnefo/ui/static/snf/js/ui/web/ui_custom_images.js b/snf-app/synnefo/ui/static/snf/js/ui/web/ui_custom_images.js
index 45203be..689d34f 100644
--- a/snf-app/synnefo/ui/static/snf/js/ui/web/ui_custom_images.js
+++ b/snf-app/synnefo/ui/static/snf/js/ui/web/ui_custom_images.js
@@ -172,4 +172,3 @@
     });
 })(this);
 
-
diff --git a/snf-app/synnefo/ui/templates/home.html b/snf-app/synnefo/ui/templates/home.html
index 535643a..03e67d0 100644
--- a/snf-app/synnefo/ui/templates/home.html
+++ b/snf-app/synnefo/ui/templates/home.html
@@ -587,7 +587,7 @@ We welcome any suggestions, questions and bug reports you may have.{% endblocktr
             synnefo.user.username = '{{ request.user.uniq }}';
             synnefo.user.token = $.cookie("X-Auth-Token");
             // images config
-            synnefo.config.system_images_owner = {{ system_images_owner|safe }};
+            synnefo.config.system_images_owners = {{ system_images_owners|safe }};
             synnefo.ui.init();
             synnefo.ui.main.bind("initial", function(){
             });
diff --git a/snf-app/synnefo/ui/views.py b/snf-app/synnefo/ui/views.py
index 1bd3320..8e6ad39 100644
--- a/snf-app/synnefo/ui/views.py
+++ b/snf-app/synnefo/ui/views.py
@@ -88,7 +88,7 @@ SKIP_TIMEOUTS = getattr(settings, "UI_SKIP_TIMEOUTS", 1)
 VM_NAME_TEMPLATE = getattr(settings, "VM_CREATE_NAME_TPL", "My {0} server")
 MAX_SSH_KEYS_PER_USER = getattr(settings, "USERDATA_MAX_SSH_KEYS_PER_USER")
 FLAVORS_DISK_TEMPLATES_INFO = getattr(settings, "UI_FLAVORS_DISK_TEMPLATES_INFO", {})
-SYSTEM_IMAGES_OWNER = getattr(settings, "UI_SYSTEM_IMAGES_OWNER", 'synnefo')
+SYSTEM_IMAGES_OWNERS = getattr(settings, "UI_SYSTEM_IMAGES_OWNERS", {})
 
 # MEDIA PATHS
 UI_MEDIA_URL = getattr(settings, "UI_MEDIA_URL",
@@ -158,9 +158,9 @@ def home(request):
                'support_ssh_os_list': json.dumps(SUPPORT_SSH_OS_LIST),
                'os_created_users': json.dumps(OS_CREATED_USERS),
                'userdata_keys_limit': json.dumps(MAX_SSH_KEYS_PER_USER),
-               'system_images_owner': json.dumps(SYSTEM_IMAGES_OWNER),
                'use_glance': json.dumps(ENABLE_GLANCE),
-               'glance_api_url': json.dumps(GLANCE_API_URL)
+               'glance_api_url': json.dumps(GLANCE_API_URL),
+               'system_images_owners': json.dumps(SYSTEM_IMAGES_OWNERS)
                }
     return template('home', context)
 
