[CORD-1538] Hiding model/fields from xProto

Change-Id: I25ecfe1ce860e561ea2f9c7ce8eeecdcd9e8e3c4
diff --git a/lib/xos-genx/tests/translator_test.py b/lib/xos-genx/tests/translator_test.py
index a8212f4..40e1b50 100644
--- a/lib/xos-genx/tests/translator_test.py
+++ b/lib/xos-genx/tests/translator_test.py
@@ -111,6 +111,48 @@
         yaml_ir = yaml.load(output)
         self.assertEqual(len(yaml_ir['items']), 4)
 
+    def test_gui_hidden_models(self):
+        xproto = \
+"""
+option app_label = "test";
+
+message Foo {
+    option gui_hidden = "True";
+    required string name = 1 [ null = "False", blank="False"];
+}
+
+message Bar {
+    option gui_hidden = "False";
+    required string name = 1 [ null = "False", blank="False"];
+}
+"""
+        args = FakeArgs()
+        args.inputs = xproto
+        args.target = 'modeldefs.xtarget'
+        output = XOSGenerator.generate(args)
+        yaml_ir = yaml.load(output)
+        self.assertEqual(len(yaml_ir['items']), 1)
+        self.assertIn('Bar', output)
+        self.assertNotIn('Foo', output)
+
+    def test_gui_hidden_model_fields(self):
+        xproto = \
+"""
+option app_label = "test";
+
+message Foo {
+    required string name = 1 [ null = "False", blank="False"];
+    required string secret = 1 [ null = "False", blank="False", gui_hidden = "True"];
+}
+"""
+        args = FakeArgs()
+        args.inputs = xproto
+        args.target = 'modeldefs.xtarget'
+        output = XOSGenerator.generate(args)
+        yaml_ir = yaml.load(output)
+        self.assertEqual(len(yaml_ir['items']), 1)
+        self.assertIn('name', output)
+        self.assertNotIn('secret', output)
 if __name__ == '__main__':
     unittest.main()
 
diff --git a/lib/xos-genx/xosgenx/targets/modeldefs.xtarget b/lib/xos-genx/xosgenx/targets/modeldefs.xtarget
index 23a1de1..8c4771f 100644
--- a/lib/xos-genx/xosgenx/targets/modeldefs.xtarget
+++ b/lib/xos-genx/xosgenx/targets/modeldefs.xtarget
@@ -1,11 +1,11 @@
 items:
 {%- for m in proto.messages | sort(attribute='name') %}
-{%- if m.name != 'XOSBase' %}
+{%- if m.name != 'XOSBase'  and xproto_unquote(xproto_first_non_empty([m.options.gui_hidden, 'False'])) != 'True' %}
 - app: {{ xproto_unquote(xproto_first_non_empty([m.options.name, m.options.app_label, options.name, context.app_label])) }}
   fields: 
   {%- set id_field = {'type':'int32', 'name':'id', 'options':{}} %}
   {% for f in (xproto_base_fields(m, proto.message_table) + m.fields + [id_field]) | sort(attribute='name') -%}
-  {% if not f.link or f.options.link_type != 'manytomany' -%}
+  {% if xproto_unquote(xproto_first_non_empty([f.options.gui_hidden, 'False'])) != 'True' and (not f.link or f.options.link_type != 'manytomany') -%}
   - hint: {% if f.options.help_text %}{{ xproto_unquote(f.options.help_text) }}{% else %}''{% endif %}
     {% if not f.link -%}
     name: {{ f.name }}