mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2024-12-28 01:41:14 -06:00
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.
This commit is contained in:
parent
b5af99c51d
commit
baaead2709
@ -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/>" +
|
||||
|
@ -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');"
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user