On 4/13/2011 10:33 PM, Adam Young wrote:
BTW, are you planning on updating this patch, or do the validation work
in a follow on patch?

Attached is an updated version. There are a few more patches in the pipeline. After that I'll address the I18n labels, integer validation and builder cleanup.

--
Endi S. Dewata
From c561c581a6f46edce7d91e2a7f5d8c0eef0ae61a Mon Sep 17 00:00:00 2001
From: Endi S. Dewata <edew...@redhat.com>
Date: Mon, 11 Apr 2011 20:22:38 -0500
Subject: [PATCH] Entitlement registration.

The entitlement facet will show buttons according to the entitlement
status. If it's unregistered, the facet will show a Register button.
If it's registered, the facet will show a Consume button.
---
 install/ui/dialog.js                               |    3 +
 install/ui/entitle.js                              |  211 ++++++++---
 install/ui/entity.js                               |   16 +-
 install/ui/ipa.css                                 |    4 +
 install/ui/ipa.js                                  |   15 +-
 install/ui/test/data/entitle_get_unregistered.json |   11 +
 install/ui/test/data/entitle_register.json         |   26 ++
 install/ui/test/data/ipa_init.json                 |  401 ++++++++++++++++++++
 install/ui/widget.js                               |    3 +-
 ipalib/plugins/baseldap.py                         |   22 +-
 10 files changed, 659 insertions(+), 53 deletions(-)
 create mode 100644 install/ui/test/data/entitle_get_unregistered.json
 create mode 100644 install/ui/test/data/entitle_register.json

diff --git a/install/ui/dialog.js b/install/ui/dialog.js
index 964d5f5fcdd4a6012954ac4bdc1098af7d5e7b52..08fba45801abf7419ba7f8309ad10b468eea26f0 100644
--- a/install/ui/dialog.js
+++ b/install/ui/dialog.js
@@ -105,6 +105,9 @@ IPA.dialog = function(spec) {
     };
 
     that.init = function() {
+
+        that.entity = IPA.get_entity(that.entity_name);
+
         for (var i=0; i<that.fields.length; i++) {
             var field = that.fields[i];
             field.entity_name = that.entity_name;
diff --git a/install/ui/entitle.js b/install/ui/entitle.js
index 47143347fb348be8bd6acf9ff79d3c47afc60bc7..1853f38d4d84d583ba286cb9500e1529816fc2d4 100644
--- a/install/ui/entitle.js
+++ b/install/ui/entitle.js
@@ -25,12 +25,18 @@
 
 IPA.entitle = {};
 
+IPA.entitle.unregistered = 0;
+IPA.entitle.registered = 1;
+
 IPA.entity_factories.entitle = function() {
 
     var builder = IPA.entity_builder();
 
     builder.
-        entity('entitle').
+        entity({
+            factory: IPA.entitle.entity,
+            name: 'entitle'
+        }).
         facet({
             factory: IPA.entitle.search_facet,
             columns: [
@@ -50,21 +56,8 @@ IPA.entity_factories.entitle = function() {
                     name: 'end',
                     label: 'End'
                 }
-            ],
-            search_all: true
+            ]
         }).
-            dialog({
-                factory: IPA.entitle.consume_dialog,
-                name: 'consume',
-                title: 'Consume Entitlements',
-                fields: [
-                    {
-                        name: 'quantity',
-                        label: 'Quantity',
-                        undo: false
-                    }
-                ]
-            }).
         details_facet({
             sections: [
                 {
@@ -74,11 +67,101 @@ IPA.entity_factories.entitle = function() {
                 }
             ]
         }).
-        standard_association_facets();
+        standard_association_facets().
+        dialog({
+            factory: IPA.entitle.register_dialog,
+            name: 'register',
+            title: 'Register Entitlements',
+            fields: [
+                {
+                    name: 'username',
+                    label: 'Username',
+                    undo: false
+                },
+                {
+                    name: 'password',
+                    label: IPA.get_method_param('entitle_register', 'password').label,
+                    type: 'password',
+                    undo: false
+                }
+            ]
+        }).
+        dialog({
+            factory: IPA.entitle.consume_dialog,
+            name: 'consume',
+            title: 'Consume Entitlements',
+            fields: [
+                {
+                    name: 'quantity',
+                    label: 'Quantity',
+                    undo: false
+                }
+            ]
+        });
 
     return builder.build();
 };
 
+IPA.entitle.entity = function(spec) {
+
+    spec = spec || {};
+
+    var that = IPA.entity(spec);
+
+    that.get_certificates = function(on_success, on_error) {
+
+        var command = IPA.command({
+            name: 'entitle_get' + (that.status == IPA.entitle.registered ? '' : '_unregistered'),
+            entity: 'entitle',
+            method: 'get',
+            on_success: function(data, text_status, xhr) {
+                that.status = IPA.entitle.registered;
+                if (on_success) {
+                    on_success.call(this, data, text_status, xhr);
+                }
+            },
+            on_error: on_error,
+            retry: false
+        });
+
+        command.execute();
+    };
+
+    that.register = function(username, password, on_success, on_error) {
+
+        var command = IPA.command({
+            entity: 'entitle',
+            method: 'register',
+            args: [ username ],
+            options: { password: password },
+            on_success: function(data, text_status, xhr) {
+                that.status = IPA.entitle.registered;
+                if (on_success) {
+                    on_success.call(this, data, text_status, xhr);
+                }
+            },
+            on_error: on_error
+        });
+
+        command.execute();
+    };
+
+    that.consume = function(quantity, on_success, on_error) {
+
+        var command = IPA.command({
+            entity: 'entitle',
+            method: 'consume',
+            args: [ quantity ],
+            on_success: on_success,
+            on_error: on_error
+        });
+
+        command.execute();
+    };
+
+    return that;
+};
+
 IPA.entitle.search_facet = function(spec) {
 
     spec = spec || {};
@@ -97,6 +180,12 @@ IPA.entitle.search_facet = function(spec) {
 
         $('<input/>', {
             type: 'button',
+            name: 'register',
+            value: 'Register'
+        }).appendTo(buttons);
+
+        $('<input/>', {
+            type: 'button',
             name: 'consume',
             value: 'Consume'
         }).appendTo(buttons);
@@ -108,15 +197,29 @@ IPA.entitle.search_facet = function(spec) {
 
         var action_panel = that.get_action_panel();
 
-        var button = $('input[name=consume]', action_panel);
+        var button = $('input[name=register]', action_panel);
+        that.register_button = IPA.action_button({
+            label: 'Register',
+            icon: 'ui-icon-plus',
+            click: function() {
+                var dialog = that.entity.get_dialog('register');
+                dialog.open(that.container);
+            }
+        });
+        that.register_button.css('display', 'none');
+        button.replaceWith(that.register_button);
+
+        button = $('input[name=consume]', action_panel);
         that.consume_button = IPA.action_button({
             label: 'Consume',
             icon: 'ui-icon-plus',
+            style: 'display: none;',
             click: function() {
-                var dialog = that.get_dialog('consume');
+                var dialog = that.entity.get_dialog('consume');
                 dialog.open(that.container);
             }
         });
+        that.consume_button.css('display', 'none');
         button.replaceWith(that.consume_button);
     };
 
@@ -124,6 +227,9 @@ IPA.entitle.search_facet = function(spec) {
 
         function on_success(data, text_status, xhr) {
 
+            that.register_button.css('display', 'none');
+            that.consume_button.css('display', 'inline');
+
             that.table.empty();
 
             var result = data.result.result;
@@ -132,7 +238,7 @@ IPA.entitle.search_facet = function(spec) {
                 that.table.add_record(record);
             }
 
-            var summary = $('span[name=summary]', that.table.tfoot);
+            var summary = $('span[name=summary]', that.table.tfoot).empty();
             if (data.result.truncated) {
                 var message = IPA.messages.search.truncated;
                 message = message.replace('${counter}', data.result.count);
@@ -143,28 +249,50 @@ IPA.entitle.search_facet = function(spec) {
         }
 
         function on_error(xhr, text_status, error_thrown) {
+
+            that.register_button.css('display', 'inline');
+            that.consume_button.css('display', 'none');
+
             var summary = $('span[name=summary]', that.table.tfoot).empty();
-            summary.append('<p>Error: '+error_thrown.name+'</p>');
-            summary.append('<p>'+error_thrown.title+'</p>');
-            summary.append('<p>'+error_thrown.message+'</p>');
+            summary.append(error_thrown.message);
         }
 
-        var command = IPA.command({
-            entity: 'entitle',
-            method: 'get',
-            options: {
-                all: that.search_all
-            },
-            on_success: on_success,
-            on_error: on_error
-        });
-
-        command.execute();
+        that.entity.get_certificates(
+            on_success,
+            on_error);
     };
 
     return that;
 };
 
+IPA.entitle.register_dialog = function(spec) {
+
+    spec = spec || {};
+
+    var that = IPA.dialog(spec);
+
+    that.add_button('Register', function() {
+        var record = {};
+        that.save(record);
+
+        that.entity.register(
+            record.username,
+            record.password,
+            function() {
+                var facet = that.entity.get_facet('search');
+                facet.refresh();
+                that.close();
+            }
+        );
+    });
+
+    that.add_button('Cancel', function() {
+        that.close();
+    });
+
+    return that;
+};
+
 IPA.entitle.consume_dialog = function(spec) {
 
     spec = spec || {};
@@ -175,19 +303,14 @@ IPA.entitle.consume_dialog = function(spec) {
         var record = {};
         that.save(record);
 
-        var command = IPA.command({
-            entity: 'entitle',
-            method: 'consume',
-            args: [ record.quantity ],
-            on_success: function() {
-                var entity = IPA.get_entity(that.entity_name);
-                var facet = entity.get_facet('search');
-                facet.table.refresh();
+        that.entity.consume(
+            record.quantity,
+            function() {
+                var facet = that.entity.get_facet('search');
+                facet.refresh();
                 that.close();
             }
-        });
-
-        command.execute();
+        );
     });
 
     that.add_button('Cancel', function() {
diff --git a/install/ui/entity.js b/install/ui/entity.js
index 4db58465d29a36622e475db32426669bbc5e2b63..23f792d1eb9bd63284c2da937570ef764732ed0a 100644
--- a/install/ui/entity.js
+++ b/install/ui/entity.js
@@ -64,6 +64,9 @@ IPA.facet = function (spec) {
     };
 
     function init() {
+
+        that.entity = IPA.get_entity(that.entity_name);
+
         for (var i=0; i<that.dialogs.length; i++){
             var dialog = that.dialogs[i];
             dialog.entity_name = that._entity_name;
@@ -220,7 +223,6 @@ IPA.entity = function (spec) {
 
     that.standard_associations = that.create_association_facets;
 
-
     that.init = function() {
 
         if (!that.label) {
@@ -576,8 +578,14 @@ IPA.entity_builder = function(){
         }
     }
 
-    that.entity = function(name){
-        entity = IPA.entity({name: name});
+    that.entity = function(spec) {
+        if (spec instanceof Object){
+            var factory = spec.factory || IPA.entity;
+            entity = factory(spec);
+        } else {
+            var name = spec;
+            entity = IPA.entity({name: name});
+        }
         return that;
     };
 
@@ -588,7 +596,7 @@ IPA.entity_builder = function(){
         } else {
             dialog = IPA.dialog(spec);
         }
-        facet.dialog(dialog);
+        entity.dialog(dialog);
         return that;
     };
 
diff --git a/install/ui/ipa.css b/install/ui/ipa.css
index 20f5dd6c913748f3e5c81063dc99d6814eee0aac..4fe040135a34b05c3eb4d5d98ba06a01a5253e35 100644
--- a/install/ui/ipa.css
+++ b/install/ui/ipa.css
@@ -471,6 +471,10 @@ span.ui-icon-search {
         margin-left: 1em !important;
 }
 
+[title="Register"] {
+        margin-left: 1em !important;
+}
+
 [title="Consume"] {
         margin-left: 1em !important;
 }
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index 7ffac51ad2968fd92122ae55d6aa47d99c20cec9..a4fbec4014202956799d1a058f1e0ec767f7959a 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -252,6 +252,8 @@ IPA.command = function(spec) {
     that.on_success = spec.on_success;
     that.on_error = spec.on_error;
 
+    that.retry = typeof spec.retry == 'undefined' ? true : spec.retry;
+
     that.get_command = function() {
         return (that.entity ? that.entity+'_' : '') + that.method;
     };
@@ -352,14 +354,19 @@ IPA.command = function(spec) {
             if (!error_thrown.title) {
                 error_thrown.title = 'AJAX Error: '+error_thrown.name;
             }
-            dialog_open.call(this, xhr, text_status, error_thrown);
+
+            if (that.retry) {
+                dialog_open.call(this, xhr, text_status, error_thrown);
+
+            } else if (that.on_error) {
+                that.on_error.call(this, xhr, text_status, error_thrown);
+            }
         }
 
         function success_handler(data, text_status, xhr) {
 
-            IPA.hide_activity_icon();
-
             if (!data) {
+                IPA.hide_activity_icon();
                 var error_thrown = {
                     title: 'HTTP Error '+xhr.status,
                     url: this.url,
@@ -368,12 +375,14 @@ IPA.command = function(spec) {
                 dialog_open.call(this, xhr, text_status, error_thrown);
 
             } else if (data.error) {
+                // error_handler() calls IPA.hide_activity_icon()
                 error_handler.call(this, xhr, text_status,  /* error_thrown */ {
                     title: 'IPA Error '+data.error.code,
                     message: data.error.message
                 });
 
             } else if (that.on_success) {
+                IPA.hide_activity_icon();
                 that.on_success.call(this, data, text_status, xhr);
             }
         }
diff --git a/install/ui/test/data/entitle_get_unregistered.json b/install/ui/test/data/entitle_get_unregistered.json
new file mode 100644
index 0000000000000000000000000000000000000000..47dce1f18a08ee04b430cce43c7413024be44081
--- /dev/null
+++ b/install/ui/test/data/entitle_get_unregistered.json
@@ -0,0 +1,11 @@
+{
+    "error": {
+        "code": 4306,
+        "message": "Not registered yet",
+        "name": {
+            "__base64__": "Tm90UmVnaXN0ZXJlZEVycm9y"
+        }
+    },
+    "id": 0,
+    "result": null
+}
\ No newline at end of file
diff --git a/install/ui/test/data/entitle_register.json b/install/ui/test/data/entitle_register.json
new file mode 100644
index 0000000000000000000000000000000000000000..8644801da623763d051bfb07879a61a19160f7fc
--- /dev/null
+++ b/install/ui/test/data/entitle_register.json
@@ -0,0 +1,26 @@
+{
+    "error": null,
+    "id": 0,
+    "result": {
+        "result": {
+            "dn": "ipaentitlementid=cf9d9755-7445-438c-a40c-23b1c60e1f9b,cn=entitlements,cn=etc,dc=idm,dc=lab,dc=bos,dc=redhat,dc=com",
+            "ipaentitlementid": [
+                "cf9d9755-7445-438c-a40c-23b1c60e1f9b"
+            ],
+            "ipauniqueid": [
+                "50afc3cc-649c-11e0-ab97-00163e2fe6de"
+            ],
+            "objectclass": [
+                "ipaobject",
+                "ipaentitlement"
+            ],
+            "userpkcs12": [
+                {
+                    "__base64__": "MIIKBAIBAzCCCcoGCSqGSIb3DQEHAaCCCbsEggm3MIIJszCCBEcGCSqGSIb3DQEHBqCCBDgwggQ0AgEAMIIELQYJKoZIhvcNAQcBMBwGCiqGSIb3DQEMAQYwDgQIxnjz6Zlw3KwCAggAgIIEABj2ncaXXZKd82QKa6p1SAKmIoSY3/Nw8y7RPCtOJdTbcSimEjWXEvcL7V9Y5pa7dn9P8T6bnKzTreA39d4gBpsQtPDknwuTyrcZc1XaMdwtOh2nLMvMLye/fhD5XP0jgospdzg9vf/drq7IHG2e8hK735PesmFj4Jx01oGyS7SzuEQ8Mf44l35pOdGhjBvnZTTaLdtQFR1Atu1EyX7+KHz6ZRkuv8+aVXTuV/EkFm18FW5LgoetYnHb4YvgukFQE1ZDxBebyUvB5MIVuJnBn4kPkHfNg32+sQpFwQoB6RAro9Kwkb25I+x8XTv7BTMwfGEr7e2LRlhsWmm5oQz24XCUpeSJb4LNmBuiqb+gBCpAiG++uZczrWHvdolBQY4igX2/1fd/PMK6NUFJbzL8dikyIHxZyo8gSb01wMk1Bq9uVM+R7fzyBUtqitz7+rXp8hc/BbamVvyfVeG31KR59WJDxbVtgLQmuDxJWBsG86YWoujV/1iheMiknLfI4prKcbtaGuJCvD9ZdiBooUBWi6l9zt2paoH+8zQPu/BPmOYt5onv+LeXBy//awEw78VXmA27kc9TTsQpIZu9busMWBaL0735fCjIoQIQhumwcuRwiWi/9QRgE/+uYbnBu+PtBV2nC+6AjPDbpebZqPQ2hDZeQ5YleSd5wSkSWtbLkAyouFi9uhnKAXyIpH+lJzVqOPrntOTljCFVNrvdxH6AjVUVfP+VIZALM+7H2TBoUtylauWe39G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E0mzhWsfPa2oZXbhUsa/UwSO4y3E/v/wTnWujzjIx56DHa+PeL0n/3iIb2W3YM1UcISKeHR/W1pAl7P7bEXwU840QrVuuPRDXoO5WRV4YGesWkk1Y0s8CwveyPKkPk5EMGOYenT5Hl2iobwPQ0nB2grB2Xf7Mz+PxN80IrZ7EpKkkJDFIMCEGCSqGSIb3DQEJFDEUHhIAYwBhAG4AZABsAGUAcABpAG4wIwYJKoZIhvcNAQkVMRYEFCSRjVYZWlcYO2q3RujbLY3xz3w9MDEwITAJBgUrDgMCGgUABBRTgMXTmP9+Z+fIVhw4Etyj7dd6zgQI8DqMKrvKUjcCAggA"
+                }
+            ]
+        },
+        "summary": "Registered to entitlement server.",
+        "value": ""
+    }
+}
\ No newline at end of file
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index 55e4c7094bbe7ff6e885a1b5199cc9c4afd138e8..48b80851aacfe5c21e51a1c773b28cfa20d34353 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -693,6 +693,407 @@
                     "dnszone_show": {
                         "__base64__": ""
                     },
+                    "entitle_consume": {
+                        "takes_args": [
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": false,
+                                "class": "Int",
+                                "cli_name": "quantity",
+                                "cli_short_name": null,
+                                "default": null,
+                                "doc": "Quantity",
+                                "exclude": null,
+                                "flags": [],
+                                "hint": null,
+                                "include": null,
+                                "label": "Quantity",
+                                "maxvalue": 2147483647,
+                                "minvalue": 1,
+                                "multivalue": false,
+                                "name": "quantity",
+                                "primary_key": false,
+                                "query": false,
+                                "required": true,
+                                "type": "int"
+                            }
+                        ],
+                        "takes_options": [
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": true,
+                                "class": "Int",
+                                "cli_name": "hidden",
+                                "cli_short_name": null,
+                                "default": 1,
+                                "doc": "Quantity",
+                                "exclude": null,
+                                "flags": [
+                                    "no_option",
+                                    "no_output"
+                                ],
+                                "hint": null,
+                                "include": null,
+                                "label": "Quantity",
+                                "maxvalue": 2147483647,
+                                "minvalue": 1,
+                                "multivalue": false,
+                                "name": "hidden",
+                                "primary_key": false,
+                                "query": false,
+                                "required": true,
+                                "type": "int"
+                            }
+                        ]
+                    },
+                    "entitle_find": {
+                        "takes_options": [
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": false,
+                                "class": "Int",
+                                "cli_name": "timelimit",
+                                "cli_short_name": null,
+                                "default": null,
+                                "doc": "Time limit of search in seconds",
+                                "exclude": null,
+                                "flags": [
+                                    "no_display"
+                                ],
+                                "hint": null,
+                                "include": null,
+                                "label": "Time Limit",
+                                "maxvalue": 2147483647,
+                                "minvalue": 0,
+                                "multivalue": false,
+                                "name": "timelimit",
+                                "primary_key": false,
+                                "query": false,
+                                "required": false,
+                                "type": "int"
+                            },
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": false,
+                                "class": "Int",
+                                "cli_name": "sizelimit",
+                                "cli_short_name": null,
+                                "default": null,
+                                "doc": "Maximum number of entries returned",
+                                "exclude": null,
+                                "flags": [
+                                    "no_display"
+                                ],
+                                "hint": null,
+                                "include": null,
+                                "label": "Size Limit",
+                                "maxvalue": 2147483647,
+                                "minvalue": 0,
+                                "multivalue": false,
+                                "name": "sizelimit",
+                                "primary_key": false,
+                                "query": false,
+                                "required": false,
+                                "type": "int"
+                            }
+                        ]
+                    },
+                    "entitle_import": {
+                        "takes_args": [
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": false,
+                                "class": "File",
+                                "cli_name": "certificate_file",
+                                "cli_short_name": null,
+                                "default": null,
+                                "doc": "<usercertificate>",
+                                "exclude": null,
+                                "flags": [],
+                                "hint": null,
+                                "include": null,
+                                "label": "<usercertificate>",
+                                "length": null,
+                                "maxlength": null,
+                                "minlength": null,
+                                "multivalue": true,
+                                "name": "usercertificate",
+                                "pattern": null,
+                                "pattern_errmsg": null,
+                                "primary_key": false,
+                                "query": false,
+                                "required": false,
+                                "stdin_if_missing": false,
+                                "type": "unicode"
+                            }
+                        ],
+                        "takes_options": [
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": false,
+                                "class": "Str",
+                                "cli_name": "addattr",
+                                "cli_short_name": null,
+                                "default": null,
+                                "doc": "Add an attribute/value pair. Format is attr=value. The attribute must be part of the schema.",
+                                "exclude": [
+                                    "webui"
+                                ],
+                                "flags": [],
+                                "hint": null,
+                                "include": null,
+                                "label": "<addattr>",
+                                "length": null,
+                                "maxlength": null,
+                                "minlength": null,
+                                "multivalue": true,
+                                "name": "addattr",
+                                "pattern": null,
+                                "pattern_errmsg": null,
+                                "primary_key": false,
+                                "query": false,
+                                "required": false,
+                                "type": "unicode"
+                            },
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": false,
+                                "class": "Str",
+                                "cli_name": "setattr",
+                                "cli_short_name": null,
+                                "default": null,
+                                "doc": "Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.",
+                                "exclude": [
+                                    "webui"
+                                ],
+                                "flags": [],
+                                "hint": null,
+                                "include": null,
+                                "label": "<setattr>",
+                                "length": null,
+                                "maxlength": null,
+                                "minlength": null,
+                                "multivalue": true,
+                                "name": "setattr",
+                                "pattern": null,
+                                "pattern_errmsg": null,
+                                "primary_key": false,
+                                "query": false,
+                                "required": false,
+                                "type": "unicode"
+                            },
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": true,
+                                "class": "Str",
+                                "cli_name": "uuid",
+                                "cli_short_name": null,
+                                "default": "IMPORTED",
+                                "doc": "Enrollment UUID",
+                                "exclude": null,
+                                "flags": [
+                                    "no_update",
+                                    "no_create"
+                                ],
+                                "hint": null,
+                                "include": null,
+                                "label": "UUID",
+                                "length": null,
+                                "maxlength": null,
+                                "minlength": null,
+                                "multivalue": false,
+                                "name": "uuid",
+                                "pattern": null,
+                                "pattern_errmsg": null,
+                                "primary_key": false,
+                                "query": false,
+                                "required": false,
+                                "type": "unicode"
+                            }
+                        ]
+                    },
+                    "entitle_register": {
+                        "takes_args": [
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": false,
+                                "class": "Str",
+                                "cli_name": "username",
+                                "cli_short_name": null,
+                                "default": null,
+                                "doc": "Username",
+                                "exclude": null,
+                                "flags": [],
+                                "hint": null,
+                                "include": null,
+                                "label": "Username",
+                                "length": null,
+                                "maxlength": null,
+                                "minlength": null,
+                                "multivalue": false,
+                                "name": "username",
+                                "pattern": null,
+                                "pattern_errmsg": null,
+                                "primary_key": false,
+                                "query": false,
+                                "required": true,
+                                "type": "unicode"
+                            }
+                        ],
+                        "takes_options": [
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": false,
+                                "class": "Str",
+                                "cli_name": "addattr",
+                                "cli_short_name": null,
+                                "default": null,
+                                "doc": "Add an attribute/value pair. Format is attr=value. The attribute must be part of the schema.",
+                                "exclude": [
+                                    "webui"
+                                ],
+                                "flags": [],
+                                "hint": null,
+                                "include": null,
+                                "label": "<addattr>",
+                                "length": null,
+                                "maxlength": null,
+                                "minlength": null,
+                                "multivalue": true,
+                                "name": "addattr",
+                                "pattern": null,
+                                "pattern_errmsg": null,
+                                "primary_key": false,
+                                "query": false,
+                                "required": false,
+                                "type": "unicode"
+                            },
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": false,
+                                "class": "Str",
+                                "cli_name": "setattr",
+                                "cli_short_name": null,
+                                "default": null,
+                                "doc": "Set an attribute to a name/value pair. Format is attr=value.\nFor multi-valued attributes, the command replaces the values already present.",
+                                "exclude": [
+                                    "webui"
+                                ],
+                                "flags": [],
+                                "hint": null,
+                                "include": null,
+                                "label": "<setattr>",
+                                "length": null,
+                                "maxlength": null,
+                                "minlength": null,
+                                "multivalue": true,
+                                "name": "setattr",
+                                "pattern": null,
+                                "pattern_errmsg": null,
+                                "primary_key": false,
+                                "query": false,
+                                "required": false,
+                                "type": "unicode"
+                            },
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": false,
+                                "class": "Str",
+                                "cli_name": "ipaentitlementid",
+                                "cli_short_name": null,
+                                "default": null,
+                                "doc": "Enrollment UUID",
+                                "exclude": null,
+                                "flags": [
+                                    "no_update",
+                                    "no_create"
+                                ],
+                                "hint": null,
+                                "include": null,
+                                "label": "UUID",
+                                "length": null,
+                                "maxlength": null,
+                                "minlength": null,
+                                "multivalue": false,
+                                "name": "ipaentitlementid",
+                                "pattern": null,
+                                "pattern_errmsg": null,
+                                "primary_key": false,
+                                "query": false,
+                                "required": false,
+                                "type": "unicode"
+                            },
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": false,
+                                "class": "Password",
+                                "cli_name": "password",
+                                "cli_short_name": null,
+                                "default": null,
+                                "doc": "Registration password",
+                                "exclude": null,
+                                "flags": [],
+                                "hint": null,
+                                "include": null,
+                                "label": "Password",
+                                "length": null,
+                                "maxlength": null,
+                                "minlength": null,
+                                "multivalue": false,
+                                "name": "password",
+                                "pattern": null,
+                                "pattern_errmsg": null,
+                                "primary_key": false,
+                                "query": false,
+                                "required": true,
+                                "type": "unicode"
+                            }
+                        ]
+                    },
+                    "entitle_sync": {
+                        "takes_args": [],
+                        "takes_options": [
+                            {
+                                "alwaysask": false,
+                                "attribute": false,
+                                "autofill": true,
+                                "class": "Int",
+                                "cli_name": "hidden",
+                                "cli_short_name": null,
+                                "default": 1,
+                                "doc": "Quantity",
+                                "exclude": null,
+                                "flags": [
+                                    "no_option",
+                                    "no_output"
+                                ],
+                                "hint": null,
+                                "include": null,
+                                "label": "Quantity",
+                                "maxvalue": 2147483647,
+                                "minvalue": 1,
+                                "multivalue": false,
+                                "name": "hidden",
+                                "primary_key": false,
+                                "query": false,
+                                "required": true,
+                                "type": "int"
+                            }
+                        ]
+                    },
                     "group_add": {
                         "takes_options": [
                             {
diff --git a/install/ui/widget.js b/install/ui/widget.js
index fa102737c581519019cd467375693c44ffdc45a8..744e6ed4a9cffe12afef5e2fb2beccb9e2b21e5b 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -282,6 +282,7 @@ IPA.text_widget = function(spec) {
     var that = IPA.widget(spec);
 
     that.size = spec.size || 30;
+    that.type = spec.type || 'text';
 
     that.create = function(container) {
 
@@ -291,7 +292,7 @@ IPA.text_widget = function(spec) {
         }).appendTo(container);
 
         $('<input/>', {
-            type: 'text',
+            type: that.type,
             name: that.name,
             disabled: that.disabled,
             size: that.size,
diff --git a/ipalib/plugins/baseldap.py b/ipalib/plugins/baseldap.py
index 8053b27864e5e30cbe706a877df3420d364577fe..22b552f5a199c8f53f969653b5cbfe01d2ba6de1 100644
--- a/ipalib/plugins/baseldap.py
+++ b/ipalib/plugins/baseldap.py
@@ -631,7 +631,7 @@ class LDAPCreate(CallbackInterface, crud.Create):
 
     # list of attributes we want exported to JSON
     json_friendly_attributes = (
-        'takes_options',
+        'takes_args', 'takes_options',
     )
 
     def __json__(self):
@@ -652,6 +652,16 @@ class LDAPQuery(CallbackInterface, crud.PKQuery):
         for arg in super(crud.PKQuery, self).get_args():
             yield arg
 
+    # list of attributes we want exported to JSON
+    json_friendly_attributes = (
+        'takes_args', 'takes_options',
+    )
+
+    def __json__(self):
+        json_dict = dict(
+            (a, getattr(self, a)) for a in self.json_friendly_attributes
+        )
+        return json_dict
 
 class LDAPMultiQuery(LDAPQuery):
     """
@@ -1436,6 +1446,16 @@ class LDAPSearch(CallbackInterface, crud.Search):
     def exc_callback(self, args, options, exc, call_func, *call_args, **call_kwargs):
         raise exc
 
+    # list of attributes we want exported to JSON
+    json_friendly_attributes = (
+        'takes_options',
+    )
+
+    def __json__(self):
+        json_dict = dict(
+            (a, getattr(self, a)) for a in self.json_friendly_attributes
+        )
+        return json_dict
 
 class LDAPModReverseMember(LDAPQuery):
     """
-- 
1.7.4

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

Reply via email to