summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Voborník <pvoborni@redhat.com>2012-02-23 13:54:07 +0100
committerPetr Vobornik <pvoborni@redhat.com>2012-02-29 13:07:22 +0100
commitd1c37067b5a4872564913ca0c13f6e33c16c4bfe (patch)
tree443a47f7b2f142fdb27d61785e4df415b5df491f
parent67a606d6729675e019ad42c9a2e08da10be9dc9c (diff)
downloadfreeipa.git-d1c37067b5a4872564913ca0c13f6e33c16c4bfe.tar.gz
freeipa.git-d1c37067b5a4872564913ca0c13f6e33c16c4bfe.tar.xz
freeipa.git-d1c37067b5a4872564913ca0c13f6e33c16c4bfe.zip
Added unsupported_validator
dnszone attributes idnsallowquery and idnsallowtransfer have valid but currently unsupported values: 'localhost' and 'localnets'. New validator was introduced for unsuported values. By using this validator user can see that the value is currently unsupported instead of showing 'invalid value' or passing the value to server and creating error there. https://fedorahosted.org/freeipa/ticket/2351
-rw-r--r--install/ui/dns.js12
-rw-r--r--install/ui/field.js19
-rw-r--r--install/ui/test/data/ipa_init.json3
-rw-r--r--ipalib/plugins/internal.py1
4 files changed, 30 insertions, 5 deletions
diff --git a/install/ui/dns.js b/install/ui/dns.js
index 42002192..4182074a 100644
--- a/install/ui/dns.js
+++ b/install/ui/dns.js
@@ -131,9 +131,11 @@ IPA.dns.zone_entity = function(spec) {
type: 'netaddr',
name: 'idnsallowquery',
validators: [
+ IPA.unsupported_validator({
+ unsupported: ['localhost', 'localnets']
+ }),
IPA.network_validator({
- specials: ['any', 'none',
- 'localhost', 'localnets'],
+ specials: ['any', 'none'],
allow_negation: true,
allow_host_address: true
})]
@@ -142,9 +144,11 @@ IPA.dns.zone_entity = function(spec) {
type: 'netaddr',
name: 'idnsallowtransfer',
validators: [
+ IPA.unsupported_validator({
+ unsupported: ['localhost', 'localnets']
+ }),
IPA.network_validator({
- specials: ['any', 'none',
- 'localhost', 'localnets'],
+ specials: ['any', 'none'],
allow_negation: true,
allow_host_address: true
})]
diff --git a/install/ui/field.js b/install/ui/field.js
index 09bf7a26..5c10abb6 100644
--- a/install/ui/field.js
+++ b/install/ui/field.js
@@ -460,6 +460,25 @@ IPA.metadata_validator = function(spec) {
return that;
};
+IPA.unsupported_validator = function(spec) {
+
+ var that = IPA.validator(spec);
+
+ that.unsupported = spec.unsupported || [];
+ that.message = spec.message || IPA.messages.widget.validation.unsupported;
+
+ that.validate = function(value, context) {
+
+ if (IPA.is_empty(value)) return that.true_result();
+
+ if (that.unsupported.indexOf(value) > -1) return that.false_result();
+
+ return that.true_result();
+ };
+
+ return that;
+};
+
IPA.checkbox_field = function(spec) {
spec = spec || {};
diff --git a/install/ui/test/data/ipa_init.json b/install/ui/test/data/ipa_init.json
index f0789d07..29880b2e 100644
--- a/install/ui/test/data/ipa_init.json
+++ b/install/ui/test/data/ipa_init.json
@@ -434,7 +434,8 @@
"max_value": "Maximum value is ${value}",
"min_value": "Minimum value is ${value}",
"net_address": "Not a valid network address",
- "required": "Required field"
+ "required": "Required field",
+ "unsupported": "Unsupported value"
}
}
}
diff --git a/ipalib/plugins/internal.py b/ipalib/plugins/internal.py
index 2ee4316f..c346b442 100644
--- a/ipalib/plugins/internal.py
+++ b/ipalib/plugins/internal.py
@@ -574,6 +574,7 @@ class i18n_messages(Command):
"min_value": _("Minimum value is ${value}"),
"net_address": _("Not a valid network address"),
"required": _("Required field"),
+ "unsupported": _("Unsupported value"),
},
},
}