Changed result status of thesaurus term add form
authorThierry Florac <thierry.florac@onf.fr>
Tue, 30 Jun 2015 14:21:10 +0200
changeset 9 cef1c49d26b0
parent 8 2064d2a24a70
child 10 bfd9acbe4224
Changed result status of thesaurus term add form
src/pyams_thesaurus/zmi/thesaurus.py
--- a/src/pyams_thesaurus/zmi/thesaurus.py	Tue Jun 30 14:20:38 2015 +0200
+++ b/src/pyams_thesaurus/zmi/thesaurus.py	Tue Jun 30 14:21:10 2015 +0200
@@ -9,7 +9,6 @@
 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
 # FOR A PARTICULAR PURPOSE.
 #
-from pyams_utils.request import check_request
 
 __docformat__ = 'restructuredtext'
 
@@ -49,6 +48,7 @@
 from pyams_thesaurus.zmi.extract import ThesaurusExtractsTable
 from pyams_utils.adapter import adapter_config, ContextRequestAdapter
 from pyams_utils.registry import query_utility, get_utility
+from pyams_utils.request import check_request
 from pyams_utils.traversing import get_parent
 from pyams_utils.url import absolute_url
 from pyams_viewlet.manager import viewletmanager_config
@@ -94,7 +94,7 @@
     """Thesaurus add form"""
 
     title = _("Utilities")
-    legend = _("Add thesaurus")
+    legend = _("Add new thesaurus")
     icon_css_class = 'fa fa-fw fa-language'
 
     fields = field.Fields(IThesaurusInfo).select('name', 'title', 'subject', 'description', 'language', 'creator',
@@ -114,7 +114,7 @@
         manager['thesaurus::{0}'.format(object.name.lower())] = object
 
     def nextURL(self):
-        return absolute_url(self.context, self.request, 'utilities.html')
+        return absolute_url(self.context, self.request, 'thesaurus.html')
 
 
 @subscriber(IDataExtractedEvent, form_selector=ThesaurusAddForm)
@@ -134,6 +134,11 @@
 class ThesaurusAJAXAddForm(AJAXAddForm, ThesaurusAddForm):
     """Thesaurus add form, AJAX view"""
 
+    def get_ajax_output(self, changes):
+        return {'status': 'redirect',
+                'location': absolute_url(self.context, self.request, 'admin.html#thesaurus.html'),
+                'close_form': True}
+
 
 @adapter_config(context=(IThesaurus, IAdminLayer, Interface), provides=ITableElementEditor)
 class ThesaurusTableElementEditor(DefaultElementEditorAdapter):
@@ -154,7 +159,7 @@
     @property
     def back_url(self):
         site = get_parent(self.context, ISite)
-        return absolute_url(site, self.request, 'admin.html#utilities.html')
+        return absolute_url(site, self.request, 'admin.html#thesaurus.html')
 
     back_target = None
     icon_class = 'fa fa-fw fa-language'
@@ -163,7 +168,7 @@
     def title(self):
         request = check_request()
         translate = request.localizer.translate
-        return translate(_("Thesaurus « {0} »")).format(self.context.name)
+        return translate(_("Thesaurus « {0} »")).format(self.context.title)
 
 
 @viewlet_config(name='properties.menu', layer=IAdminLayer, context=IThesaurus, manager=ISiteManagementMenu,