summaryrefslogtreecommitdiffstats
path: root/ipa-server
diff options
context:
space:
mode:
authorRob Crittenden <rcritten@redhat.com>2007-12-13 04:32:22 -0500
committerRob Crittenden <rcritten@redhat.com>2007-12-13 04:32:22 -0500
commitbaaead2709855c71329c4961d64477cb07536316 (patch)
tree48d44801f6b0f0f05d51c058a7879a8544c9c1b7 /ipa-server
parentb5af99c51d1ea8d4e6593a634d347b38a5d97271 (diff)
downloadfreeipa-baaead2709855c71329c4961d64477cb07536316.tar.gz
freeipa-baaead2709855c71329c4961d64477cb07536316.tar.xz
freeipa-baaead2709855c71329c4961d64477cb07536316.zip
Allow for direct entry of group names when creating delegations.
This requires a bit of trickery. I use the onblur() javascript function to note when the field is left and store whatever was entered there. Then when the page is submitted if a dn doesn't exist for that field but they did enter something, do a lookup to see if there is a group by that name.
Diffstat (limited to 'ipa-server')
-rw-r--r--ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py19
-rw-r--r--ipa-server/ipa-gui/ipagui/templates/delegateform.kid11
2 files changed, 28 insertions, 2 deletions
diff --git a/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py b/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
index 9f4ec6c43..2319b944a 100644
--- a/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
+++ b/ipa-server/ipa-gui/ipagui/subcontrollers/delegation.py
@@ -56,6 +56,25 @@ class DelegationController(IPAController):
turbogears.flash("Add delegation cancelled")
raise turbogears.redirect('/delegate/list')
+ # Try to handle the case where the user entered just some data
+ # into the source/dest group name but didn't do a Find. We'll do
+ # our best to see if a group by that name exists and if so, use it.
+ dest_group_dn = kw.get('dest_group_dn')
+ dest_group_cn = kw.get('dest_group_cn')
+ if not dest_group_dn and dest_group_cn:
+ try:
+ group = client.get_entry_by_cn(dest_group_cn, ['dn'])
+ kw['dest_group_dn'] = group.dn
+ except:
+ kw['dest_group_cn'] = "Please choose:"
+ source_group_dn = kw.get('source_group_dn')
+ source_group_cn = kw.get('source_group_cn')
+ if not source_group_dn and source_group_cn:
+ try:
+ group = client.get_entry_by_cn(source_group_cn, ['dn'])
+ kw['source_group_dn'] = group.dn
+ except:
+ kw['source_group_cn'] = "Please choose:"
tg_errors, kw = self.delegatevalidate(**kw)
if tg_errors:
turbogears.flash("There were validation errors.<br/>" +
diff --git a/ipa-server/ipa-gui/ipagui/templates/delegateform.kid b/ipa-server/ipa-gui/ipagui/templates/delegateform.kid
index d2be336c8..3f885fa03 100644
--- a/ipa-server/ipa-gui/ipagui/templates/delegateform.kid
+++ b/ipa-server/ipa-gui/ipagui/templates/delegateform.kid
@@ -4,6 +4,13 @@
<?python searchurl = tg.url('/delegate/group_search') ?>
<script type="text/javascript">
+ function lostFocus(which_group) {
+ /* The user has left the field, save what they put in there in case
+ * they don't do a Find. */
+ group_cn_field = $('form_' + which_group + '_group_cn');
+ group_criteria_field = $(which_group + '_criteria')
+ group_cn_field.value = group_criteria_field.value
+ }
function enterDoSearch(e, which_group) {
var keyPressed;
@@ -105,7 +112,7 @@
</div>
<div id="source_searcharea" style="display:none">
<input class="requiredfield" id="source_criteria" type="text"
- onkeypress="return enterDoSearch(event, 'source');" />
+ onkeypress="return enterDoSearch(event, 'source');" onblur="return lostFocus('source');"/>
<input class="searchbutton" type="button" value="Find"
onclick="return doSearch('source');"
/>
@@ -143,7 +150,7 @@
<div id="dest_searcharea" style="display:none">
<div>
<input class="requiredfield" id="dest_criteria" type="text"
- onkeypress="return enterDoSearch(event, 'dest');" />
+ onkeypress="return enterDoSearch(event, 'dest');" onblur="return lostFocus('dest');"/>
<input class="searchbutton" type="button" value="Find"
onclick="return doSearch('dest');"
/>