[Products.SilvaExternalSources][Sylvain Viollon] Add a screen to...

[email protected] Tue, 29 Oct 2013 15:05:36 +0100
Newsgroups gmane.comp.web.zope.silva.cvs
Message-ID <[email protected]>
author:    Sylvain Viollon
date:      Tue Oct 29 15:05:31 2013 +0100
revision:  1128:771cd7f2f9d4 in Products.SilvaExternalSources
branch:    2.4
details:   https://hg.infrae.com/Products.SilvaExternalSources?cmd=changeset;node=771cd7f2f9d4
modified:  Products/SilvaExternalSources/CodeSourceService.py Products/SilvaExternalSources/CodeSourceService_templates/configureinstallcodesources.cpt
added:     
removed:   
log:       Add a screen to install sources from SMI.


diffstat:

 Products/SilvaExternalSources/CodeSourceService.py                                        |  14 +-
 Products/SilvaExternalSources/CodeSourceService_templates/configureinstallcodesources.cpt |  81 +++++++++-
 2 files changed, 91 insertions(+), 4 deletions(-)

diffs (128 lines):

diff -r cac70275e114 -r 771cd7f2f9d4 Products/SilvaExternalSources/CodeSourceService.py
--- a/Products/SilvaExternalSources/CodeSourceService.py	Mon Oct 28 15:46:54 2013 +0100
+++ b/Products/SilvaExternalSources/CodeSourceService.py	Tue Oct 29 15:05:31 2013 +0100
@@ -35,11 +35,12 @@
 from silva.core import conf as silvaconf
 from silva.core.interfaces import IContainer, ISilvaConfigurableService
 from silva.core.interfaces import IMimeTypeClassifier
+from silva.core.messages.interfaces import IMessageService
 from silva.core.services.base import SilvaService
 from silva.core.services.utils import walk_silva_tree
 from silva.core.views import views as silvaviews
+from silva.fanstatic import need
 from silva.translations import translate as _
-from silva.fanstatic import need
 from silva.ui import rest
 from zeam.form import silva as silvaforms
 
@@ -768,7 +769,7 @@
 class InstallCodeSourcesMixin(object):
 
     def update(self, install=False, refresh=False, locations=[]):
-        self.status = []
+        self.status = None
         if install:
             notfound = []
             installed = []
@@ -850,6 +851,15 @@
     def get_menu_title(self):
         return _('Install code sources')
 
+    def update(self, install=False, refresh=False, locations=[]):
+        super(ConfigureInstallCodeSources, self).update(
+            install='install' in self.request.form,
+            refresh='refresh' in self.request.form,
+            locations=self.request.form.get('locations', []))
+        if self.status:
+            service = getUtility(IMessageService)
+            service.send(self.status, self.request, namespace='feedback')
+
 
 class ManageSourcesErrors(silvaviews.ZMIView):
     grok.name('manage_sources_errors')
diff -r cac70275e114 -r 771cd7f2f9d4 Products/SilvaExternalSources/CodeSourceService_templates/configureinstallcodesources.cpt
--- a/Products/SilvaExternalSources/CodeSourceService_templates/configureinstallcodesources.cpt	Mon Oct 28 15:46:54 2013 +0100
+++ b/Products/SilvaExternalSources/CodeSourceService_templates/configureinstallcodesources.cpt	Tue Oct 29 15:05:31 2013 +0100
@@ -1,3 +1,80 @@
-<tal:configure i18n:domain="plone">
-   Install
+<tal:configure i18n:domain="silva">
+
+  <div class="form-head">
+    <h3 i18n:translate="">
+      Install new code sources
+    </h3>
+    <p tal:condition="rest.sources"
+       i18n:translate="">
+      You can here install <span i18n:name="count" tal:content="rest.sources" />
+      new code sources in your Silva
+      site:
+    </p>
+    <p tal:condition="not rest.sources"
+       i18n:translate="">
+      There is no installable code sources.
+    </p>
+  </div>
+
+  <form class="form-fields-container" tal:condition="rest.sources">
+    <tal:extension tal:repeat="extension rest.extensions">
+      <div class="form-head">
+        <h4 title="Click to hide or display"
+            tal:content="extension.title" />
+        <p tal:condition="extension.description"
+           tal:content="extension.description" />
+      </div>
+      <div class="form-body">
+        <div class="form-section"
+             tal:repeat="source extension.sources">
+          <div class="form-checkbox"
+               tal:define="id source.identifier;
+                           working source.validate">
+            <input type="checkbox" name="locations" value="#" id="#" class="#"
+                   tal:attributes="disabled not working and 'disabled' or None;
+                                   value source.location;
+                                   class string:check-${extension.id} field field-bool field-required;
+                                   id id" />
+            <label for="#"
+                   tal:attributes="for id">
+              <span tal:replace="source.title" />
+              (<span tal:replace="id" />)
+            </label>
+            <i tal:condition="not: working"
+               style="font-weight: bold; color: red;"
+               i18n:translate="">
+              This source is incomplete and cannot be installed.
+            </i>
+            <p tal:content="source.description" />
+          </div>
+        </div>
+      </div>
+    </tal:extension>
+
+    <div class="form-footer">
+      <div class="form-controls">
+        <a class="form-button open-screen" rel="admin" href="."
+           data-form-shortcut="ctrl+z" title="Go back to the site preferences"
+           i18n:attributes="title">
+          <ins class="ui-icon ui-icon-arrowreturnthick-1-w"></ins>
+          Cancel
+        </a>
+
+        <a class="form-control" name="install"
+           data-form-shortcut="ctrl+i" title="Install selected code sources"
+           i18n:attributes="title">
+          <ins class="icon form_check"></ins>
+          Install
+        </a>
+
+        <a class="form-control" name="refresh"
+           data-form-shortcut="ctrl+r" title="Refresh the list of installable sources"
+           i18n:attributes="title">
+          <ins class="icon form_check"></ins>
+          Refresh
+        </a>
+      </div>
+    </div>
+  </form>
+
 </tal:configure>