Hi,

Please review the attached patch. Thanks!

https://fedorahosted.org/reviewboard/r/113/

The create_association_facets() has been modified such that it
does not generate duplicate links. This is done by assigning the
proper labels and hiding non-assignable associations.

Each association will get a label based on the attribute used:
 - memberof: <entity name> Membership
 - member.*: Member <entity name>
 - managedby: Managed by <entity name>
 - enrolledby: Enrolled by <entity name>

The following associations will be hidden:
 - memberindirect

The internal.py was modified to return localized labels.

The test data has been updated.

--
Endi S. Dewata
From 2b0332826343a0b90777c7ea49ea2d3a40e2e8e3 Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Thu, 2 Dec 2010 17:16:34 -0600
Subject: [PATCH] Fixed association links

The create_association_facets() has been modified such that it
does not generate duplicate links. This is done by assigning the
proper labels and hiding non-assignable associations.

Each association will get a label based on the attribute used:
 - memberof: <entity name> Membership
 - member.*: Member <entity name>
 - managedby: Managed by <entity name>
 - enrolledby: Enrolled by <entity name>

The following associations will be hidden:
 - memberindirect

The internal.py was modified to return localized labels.

The test data has been updated.
---
 install/static/entity.js               |   26 ++++++++++++++++++++++----
 install/static/group.js                |    2 +-
 install/static/hbacsvcgroup.js         |    2 +-
 install/static/host.js                 |    2 +-
 install/static/service.js              |    2 +-
 install/static/sudocmdgroup.js         |    2 +-
 install/static/test/data/ipa_init.json |    6 ++++++
 ipalib/plugins/internal.py             |    5 +++++
 8 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/install/static/entity.js b/install/static/entity.js
index 6e2b501b0989b4549123888bef0fcc69a7b23b0d..0c7c849d1aa99f263367f0d66dd043e93c399fe7 100644
--- a/install/static/entity.js
+++ b/install/static/entity.js
@@ -151,9 +151,7 @@ function ipa_entity(spec) {
         return config;
     };
 
-    that.create_association_facet = function(other_entity, attribute_member) {
-
-        var label = IPA.metadata[other_entity].label;
+    that.create_association_facet = function(attribute_member, other_entity, label) {
 
         if (!attribute_member) {
             attribute_member = ipa_get_member_attribute(
@@ -173,12 +171,32 @@ function ipa_entity(spec) {
         var attribute_members = IPA.metadata[that.name].attribute_members;
 
         for (var attribute_member in attribute_members) {
+
+            // skip memberindirect
+            if (attribute_member === 'memberindirect') continue;
+
             var other_entities = attribute_members[attribute_member];
 
             for (var j = 0; j < other_entities.length; j++) {
                 var other_entity = other_entities[j];
+                var other_entity_name = IPA.metadata[other_entity].label;
 
-                var facet = that.create_association_facet(other_entity, attribute_member);
+                var label = other_entity_name;
+
+                if (attribute_member.match(/^memberof$/)) {
+                    label = other_entity_name+' '+IPA.messages.association.memberof;
+
+                } else if (attribute_member.match(/^member/)) {
+                    label = IPA.messages.association.member+' '+other_entity_name;
+
+                } else if (attribute_member.match(/^managedby$/)) {
+                    label = IPA.messages.association.managedby+' '+other_entity_name;
+
+                } else if (attribute_member.match(/^enrolledby$/)) {
+                    label = IPA.messages.association.enrolledby+' '+other_entity_name;
+                }
+
+                var facet = that.create_association_facet(attribute_member, other_entity, label);
                 if (that.get_facet(facet.name)) continue;
                 that.add_facet(facet);
             }
diff --git a/install/static/group.js b/install/static/group.js
index bcac40982d1bddaec55bdb46173df0b65e2bfb68..afc4ca271b20f0cb1f6911f1391150e00c699894 100644
--- a/install/static/group.js
+++ b/install/static/group.js
@@ -64,7 +64,7 @@ function ipa_group() {
 
         facet = ipa_group_member_user_facet({
             'name': 'member_user',
-            'label': 'Users',
+            'label': IPA.messages.association.member+' '+IPA.metadata['user'].label,
             'other_entity': 'user'
         });
         that.add_facet(facet);
diff --git a/install/static/hbacsvcgroup.js b/install/static/hbacsvcgroup.js
index 9cc1cdea4fba86c36ab99fbcf2f96ceda50b99b1..2aab5d0e247aef8ee90e3a05aedc3aa73eae9c43 100755
--- a/install/static/hbacsvcgroup.js
+++ b/install/static/hbacsvcgroup.js
@@ -55,7 +55,7 @@ function ipa_hbacsvcgroup() {
 
         facet = ipa_hbacsvcgroup_member_hbacsvc_facet({
             'name': 'member_hbacsvc',
-            'label': 'Services',
+            'label': IPA.messages.association.member+' '+IPA.metadata['hbacsvc'].label,
             'other_entity': 'hbacsvc'
         });
         that.add_facet(facet);
diff --git a/install/static/host.js b/install/static/host.js
index 4f3a636ebe3169cea87dd59536d822015191b041..484b64771ecf6f1be948974f424606476375a276 100644
--- a/install/static/host.js
+++ b/install/static/host.js
@@ -60,7 +60,7 @@ function ipa_host() {
 
         facet = ipa_host_managedby_host_facet({
             'name': 'managedby_host',
-            'label': 'Managed by Hosts',
+            'label': IPA.messages.association.managedby+' '+IPA.metadata['host'].label,
             'other_entity': 'host'
         });
         that.add_facet(facet);
diff --git a/install/static/service.js b/install/static/service.js
index 670737468103eabf25544592635f1852f31e4b7b..5d9e21ad118d9ece595dc413aa65149e5113cbde 100644
--- a/install/static/service.js
+++ b/install/static/service.js
@@ -55,7 +55,7 @@ function ipa_service() {
 
         facet = ipa_service_managedby_host_facet({
             'name': 'managedby_host',
-            'label': 'Hosts',
+            'label': IPA.messages.association.managedby+' '+IPA.metadata['host'].label,
             'other_entity': 'host'
         });
         that.add_facet(facet);
diff --git a/install/static/sudocmdgroup.js b/install/static/sudocmdgroup.js
index 09b2a741c9a7656b50abfedc2bf754a955581db8..eb417cfc0b417a750212729cf87ff13b5ba7bfdc 100755
--- a/install/static/sudocmdgroup.js
+++ b/install/static/sudocmdgroup.js
@@ -55,7 +55,7 @@ function ipa_sudocmdgroup() {
 
         facet = ipa_sudocmdgroup_member_sudocmd_facet({
             'name': 'member_sudocmd',
-            'label': 'Commands',
+            'label': IPA.messages.association.member+' '+IPA.metadata['sudocmd'].label,
             'other_entity': 'sudocmd'
         });
         that.add_facet(facet);
diff --git a/install/static/test/data/ipa_init.json b/install/static/test/data/ipa_init.json
index 1de6849040f2f886f1ecc44467c7a44d35f78c72..fc22a7f12b8f379278edb06ed6dcc9c2d8c8bc89 100644
--- a/install/static/test/data/ipa_init.json
+++ b/install/static/test/data/ipa_init.json
@@ -4082,6 +4082,12 @@
                     "ajax": {
                         "401": "Your kerberos ticket no longer valid.Please run KInit and then click 'retry'If this is your first time running the IPA Web UI<a href='/ipa/errors/ssbrowser.html'> Follow these directions</a> to configure your browser."
                     },
+                    "association": {
+                        "enrolledby": "Enrolled by",
+                        "managedby": "Managed by",
+                        "member": "Member",
+                        "memberof": "Membership"
+                    },
                     "button": {
                         "add": "Add",
                         "enroll": "Enroll",
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 708d829bea90d9b827e19d817f9761bda8341226..674124a0acc8faa6e597204b34ba2a46010b39da 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -97,6 +97,11 @@ class i18n_messages(Command):
             "employee":_("      Employee Information"),
             "misc":_("Misc. Information"),
             "to_top":_("Back to Top")},
+        "association":{
+            "enrolledby":_("Enrolled by"),
+            "managedby":_("Managed by"),
+            "member":_("Member"),
+            "memberof":_("Membership")},
         "ajax":{
             "401":_("Your kerberos ticket no longer valid."+
                 "Please run KInit and then click 'retry'"+
-- 
1.6.6.1

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to