pgreco / rpms / ipa

Forked from forks/areguera/rpms/ipa 4 years ago
Clone
Blob Blame History Raw
From 6ed7f2846c04c5b6a570787b8022797c279aaaee Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvoborni@redhat.com>
Date: Tue, 25 Aug 2015 16:26:00 +0200
Subject: [PATCH] fix missing information in object metadata

Missing 'required' values in takes_params causes Web UI to treat required
fields as optional.

Regression caused by ba0a1c6b33e2519a48754602413c8379fb1f0ff1

https://fedorahosted.org/freeipa/ticket/5258

Reviewed-By: Martin Basti <mbasti@redhat.com>
---
 ipalib/parameters.py | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/ipalib/parameters.py b/ipalib/parameters.py
index 6cc6f8c9244abb9e895782f40cbdde63b2144d22..5ced5067ed2657962c35d7d675c4ddd822df6a36 100644
--- a/ipalib/parameters.py
+++ b/ipalib/parameters.py
@@ -922,12 +922,23 @@ class Param(ReadOnly):
 
     def __json__(self):
         json_dict = {}
-        for key in self.__kw:
-            json_dict[key] = json_serialize(self.__kw[key])
+        for (a, k, d) in self.kwargs:
+            if k in (callable, DefaultFrom):
+                continue
+            elif isinstance(getattr(self, a), frozenset):
+                json_dict[a] = [k for k in getattr(self, a, [])]
+            else:
+                val = getattr(self, a, '')
+                if val is None:
+                    # ignore 'not set' because lack of their presence is
+                    # the information itself
+                    continue
+                json_dict[a] = json_serialize(val)
+
         json_dict['class'] = self.__class__.__name__
         json_dict['name'] = self.name
         json_dict['type'] = self.type.__name__
-        json_dict['flags'] = json_serialize([f for f in self.flags])
+
         return json_dict
 
 
-- 
2.4.3