summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
author <bdauvergne@entrouvert.com>2009-09-21 16:32:22 (GMT)
committer <bdauvergne@entrouvert.com>2009-09-21 16:32:22 (GMT)
commit854c285854771c1b6b5e2da351f7d428cd8ed443 (patch)
tree2a7b9462f1a28bcb6e9291e75064fe9059302f8c
parent2f7809fa941d4535ed03e68d3386c70347e47631 (diff)
downloadpratic-854c285854771c1b6b5e2da351f7d428cd8ed443.zip
pratic-854c285854771c1b6b5e2da351f7d428cd8ed443.tar.gz
pratic-854c285854771c1b6b5e2da351f7d428cd8ed443.tar.bz2
- always show the error message which reports existing service instances of
service being deleted. - fix parsing of the dn of the service instance
-rw-r--r--idp/extra/modules/services_ui.ptl40
1 files changed, 19 insertions, 21 deletions
diff --git a/idp/extra/modules/services_ui.ptl b/idp/extra/modules/services_ui.ptl
index 4524e3e..b463962 100644
--- a/idp/extra/modules/services_ui.ptl
+++ b/idp/extra/modules/services_ui.ptl
@@ -7,6 +7,7 @@ import ldap
from quixote import get_request, get_response, get_session, redirect, get_publisher
from quixote.directory import Directory
+from quixote.html import htmltext, htmlescape, url_quote
from qommon.backoffice.menu import html_top
from qommon.admin.menu import command_icon
@@ -356,7 +357,6 @@ class ServiceDirectory(Directory):
return redirect('.')
def delete [html] (self):
- # XXX: check there are no instances of this service.
form = Form(enctype='multipart/form-data')
form.widgets.append(HtmlWidget('<p>%s</p>' % _(
'You are about to irrevocably delete this service.')))
@@ -364,30 +364,28 @@ class ServiceDirectory(Directory):
form.add_submit('cancel', _('Cancel'))
if form.get_submit() == 'cancel':
return redirect('../..')
- service_instances = None
- if form.is_submitted and not form.has_errors():
- service_instances = directory.get_service_instances_by_service_type(self.service.cdg59sid)
- if not service_instances:
- html_text = html_text('<p>%s :</p>' % _('Cannot delete service. There are still service instances for this service'))
- html_text += html_text('<ul>')
- for si in service_instances:
- sid=si.cdg59siid
- try:
- ou=[x[1] for x in ldap.dn.str2dn(si.dn, flags.DN_FORMAT_LDAPV3) if x[0] == 'ou' ]
- collectivity = directory.get_collectivity(ou)
- ou = collectivity.ou
- link = url_quote("../../%s/%s/edit" % (ou,sid))
- html_text += html_text('<li><a href="%s">%s - %s</a></li>' % (link, collectivity.cn, si.name))
- except:
- html_text += html_text('<li>%s</li>' % html_escape(si.dn))
-
- html_text += html_text('</ul>')
- get_session().message = ('error', html_text)
+ service_instances = directory.get_service_instances_by_service_type(self.service.cdg59sid)
+ if service_instances:
+ error_text = htmltext('<p>%s :</p>' % _('Cannot delete service. There are still service instances for this service'))
+ error_text += htmltext('<ul>')
+ for si in service_instances:
+ sid=si.cdg59siid
+ try:
+ ou=[x[0][1] for x in ldap.dn.str2dn(si.dn, flags=ldap.DN_FORMAT_LDAPV3) if x[0][0] == 'ou' ][0]
+ collectivity = directory.get_collectivity(ou)
+ ou = collectivity.ou
+ link = url_quote("../../%s/%s/delete" % (ou,sid))
+ error_text += htmltext('<li> %s - %s <a href="%s" target="_delete_%s">%s</a></li>' % (collectivity.cn, si.name, link, ou, _('Delete')))
+ except KeyError:
+ error_text += htmltext('<li>%s</li>' % htmlescape(si.dn))
+
+ error_text += htmltext('</ul>')
+ get_session().message = ('error', error_text)
if not form.is_submitted() or form.has_errors() or service_instances:
get_response().breadcrumb.append(('delete', _('Delete')))
html_top('services', title = _('Delete Service'))
-
+ get_session().display_message()
'<h2>%s</h2>' % _('Deleting Service: %s') % self.service.cn
form.render()
else: