[Products.SilvaExternalSources][Sylvain Viollon] Add an availabl...
[email protected] Tue, 29 Oct 2013 17:16:40 +0100
| Newsgroups | gmane.comp.web.zope.silva.cvs |
|---|---|
| Message-ID | <[email protected]> |
author: Sylvain Viollon
date: Tue Oct 29 17:16:37 2013 +0100
revision: 1129:b67a3f81ae8a in Products.SilvaExternalSources
branch: 2.4
details: https://hg.infrae.com/Products.SilvaExternalSources?cmd=changeset;node=b67a3f81ae8a
modified: Products/SilvaExternalSources/CodeSourceService.py Products/SilvaExternalSources/CodeSourceService_templates/configureexisting.cpt Products/SilvaExternalSources/CodeSourceService_templates/configureinstall.cpt Products/SilvaExternalSources/CodeSourceService_templates/configureinstallcodesources.cpt Products/SilvaExternalSources/CodeSourceService_templates/manageexistingcodesources.pt
added: Products/SilvaExternalSources/CodeSourceService_templates/configureexisting.cpt Products/SilvaExternalSources/CodeSourceService_templates/configureinstall.cpt
removed: Products/SilvaExternalSources/CodeSourceService_templates/configureinstallcodesources.cpt
log: Add an available and improve install configuration screens.
diffstat:
Products/SilvaExternalSources/CodeSourceService.py | 72 +++++++-
Products/SilvaExternalSources/CodeSourceService_templates/configureexisting.cpt | 83 ++++++++++
Products/SilvaExternalSources/CodeSourceService_templates/configureinstall.cpt | 80 +++++++++
Products/SilvaExternalSources/CodeSourceService_templates/configureinstallcodesources.cpt | 80 ---------
Products/SilvaExternalSources/CodeSourceService_templates/manageexistingcodesources.pt | 2 +-
5 files changed, 225 insertions(+), 92 deletions(-)
diffs (422 lines):
diff -r 771cd7f2f9d4 -r b67a3f81ae8a Products/SilvaExternalSources/CodeSourceService.py
--- a/Products/SilvaExternalSources/CodeSourceService.py Tue Oct 29 15:05:31 2013 +0100
+++ b/Products/SilvaExternalSources/CodeSourceService.py Tue Oct 29 17:16:37 2013 +0100
@@ -41,7 +41,7 @@
from silva.core.views import views as silvaviews
from silva.fanstatic import need
from silva.translations import translate as _
-from silva.ui import rest
+from silva.ui import rest, menu
from zeam.form import silva as silvaforms
from .interfaces import ICodeSource, ICodeSourceService, ICodeSourceInstaller
@@ -375,7 +375,9 @@
return self._location
def is_installed(self, folder):
- return self.identifier in folder.objectIds()
+ source = getattr(folder, self.identifier, None)
+ return (ICodeSource.providedBy(source) and
+ source.get_fs_location() == self._location)
def install(self, folder):
if self.is_installed(folder):
@@ -532,7 +534,7 @@
security = ClassSecurityInfo()
manage_options = (
- {'label': 'Existing Code Sources',
+ {'label': 'Available Code Sources',
'action': 'manage_existing_codesources'},
{'label': 'Install Code Sources',
'action': 'manage_install_codesources'},
@@ -701,12 +703,10 @@
self.__errors = collections.deque([], 25)
-class ManageExistingCodeSources(silvaviews.ZMIView):
- grok.name('manage_existing_codesources')
- grok.context(CodeSourceService)
+class ExistingCodeSourcesMixin(object):
def update(self, find=False, below=None, child=False,
- update=False, bind=False):
+ update=False, bind=False, sources=None):
self.status = None
if find:
self.context.find_installed_sources()
@@ -733,7 +733,7 @@
continue
message = None
if ICodeSource.providedBy(source):
- if update:
+ if update and (sources is None or source.getId() in sources):
installable = source._get_installable()
if (installable is not None and
os.path.isdir(installable._directory)):
@@ -766,7 +766,41 @@
self.filter = '/'.join(aq_parent(self.context).getPhysicalPath())
+class ManageExistingCodeSources(ExistingCodeSourcesMixin, silvaviews.ZMIView):
+ grok.name('manage_existing_codesources')
+ grok.context(CodeSourceService)
+
+
+class ConfigureExisting(ExistingCodeSourcesMixin, rest.PageWithTemplateREST):
+ grok.adapts(rest.Screen, CodeSourceService)
+ grok.name('admin-existing')
+ grok.require('zope2.ViewManagementScreens')
+
+ def get_menu_title(self):
+ return _('Available code sources')
+
+ def update(self):
+ sources = self.request.form.get('sources')
+ if sources is not None and not isinstance(sources, list):
+ sources = [sources]
+ super(ConfigureExisting, self).update(
+ find='find' in self.request.form,
+ update='update' in self.request.form,
+ sources=sources)
+ if self.status:
+ service = getUtility(IMessageService)
+ service.send(self.status, self.request, namespace='feedback')
+
+
+class ConfigureExistingMenu(menu.MenuItem):
+ grok.adapts(menu.ContentMenu, CodeSourceService)
+ grok.order(10)
+ name = _('Available')
+ screen = ConfigureExisting
+
+
class InstallCodeSourcesMixin(object):
+ only_uninstalled = False
def update(self, install=False, refresh=False, locations=[]):
self.status = None
@@ -807,6 +841,8 @@
self.sources = 0
extensions = {}
for source in self.context.get_installable_sources(refresh=refresh):
+ if self.only_uninstalled and source.is_installed(self.context):
+ continue
sources = extensions.setdefault(source.extension, [])
sources.append(source)
self.sources += 1
@@ -836,23 +872,30 @@
'sources': sources,
})
self.extensions.sort(key=operator.itemgetter('title'))
- need(jquery)
+
class ManageInstallCodeSources(InstallCodeSourcesMixin, silvaviews.ZMIView):
grok.name('manage_install_codesources')
grok.context(CodeSourceService)
+ def update(self, install=False, refresh=False, locations=[]):
+ super(ManageInstallCodeSources, self).update(
+ install=install, refresh=refresh, locations=locations)
+ need(jquery)
-class ConfigureInstallCodeSources(InstallCodeSourcesMixin, rest.PageWithTemplateREST):
+
+class ConfigureInstall(InstallCodeSourcesMixin, rest.PageWithTemplateREST):
grok.adapts(rest.Screen, CodeSourceService)
grok.name('admin')
grok.require('zope2.ViewManagementScreens')
+ only_uninstalled = True
+
def get_menu_title(self):
return _('Install code sources')
def update(self, install=False, refresh=False, locations=[]):
- super(ConfigureInstallCodeSources, self).update(
+ super(ConfigureInstall, self).update(
install='install' in self.request.form,
refresh='refresh' in self.request.form,
locations=self.request.form.get('locations', []))
@@ -861,6 +904,13 @@
service.send(self.status, self.request, namespace='feedback')
+class ConfigureInstallMenu(menu.MenuItem):
+ grok.adapts(menu.ContentMenu, CodeSourceService)
+ grok.order(15)
+ name = _('Install')
+ screen = ConfigureInstall
+
+
class ManageSourcesErrors(silvaviews.ZMIView):
grok.name('manage_sources_errors')
grok.context(CodeSourceService)
diff -r 771cd7f2f9d4 -r b67a3f81ae8a Products/SilvaExternalSources/CodeSourceService_templates/configureexisting.cpt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Products/SilvaExternalSources/CodeSourceService_templates/configureexisting.cpt Tue Oct 29 17:16:37 2013 +0100
@@ -0,0 +1,83 @@
+<tal:installed i18n:domain="silva">
+
+ <div class="form-head">
+ <h3 i18n:translate="">
+ Code sources installed in this site
+ </h3>
+
+ <p tal:condition="rest.sources"
+ i18n:translate="">
+ There are currently
+ <span tal:replace="len(rest.sources)" i18n:name="count" />
+ known code sources possibly in use under
+ <span tal:replace="rest.filter" i18n:name="path" /> in this Silva
+ site.
+ </p>
+ <p tal:condition="not rest.sources"
+ i18n:translate="">
+ There are no known code sources is this site.
+ Try to find them with the actions below.
+ </p>
+ </div>
+
+ <form class="form-fields-container">
+ <div class="form-body" tal:condition="rest.sources">
+ <div class="form-section ${source.problems and 'broken' or None}"
+ tal:repeat="source rest.sources">
+ <div class="form-checkbox">
+ <input type="checkbox" name="sources" value="#" id="#"
+ class="field field-bool field-required"
+ tal:attributes="value source.id;
+ id source.id" />
+ <label for="#"
+ tal:attributes="for source.id">
+ <span tal:replace="source.title" />
+ (<span tal:replace="source.id" />)
+ </label>
+ <tal:message tal:condition="source.message">
+ : <span class="message" tal:content="source.message" />
+ </tal:message>
+ <p tal:content="source.title" />
+ <tal:error tal:condition="source.problems">
+ <p>Error(s) are:</p>
+ <ol tal:condition="source.problems">
+ <li tal:repeat="problem source.problems">
+ <p tal:content="problem" />
+ </li>
+ </ol>
+ </tal:error>
+ </div>
+ </div>
+
+ <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="update"
+ title="Update selected code sources"
+ data-form-shortcut="ctrl+u"
+ data-confirmation="Are you sure ?"
+ tal:condition="rest.sources"
+ i18n:attributes="title data-confirmation">
+ <ins class="icon form_check"></ins>
+ Update
+ </a>
+ <a class="form-control" name="find"
+ data-form-shortcut="ctrl+r"
+ data-confirmation="Are you sure ?"
+ title="Find code sources used in the site"
+ i18n:attributes="title data-confirmation">
+ <ins class="icon form_check"></ins>
+ Find
+ </a>
+
+ </div>
+ </div>
+ </div>
+ </form>
+
+</tal:installed>
diff -r 771cd7f2f9d4 -r b67a3f81ae8a Products/SilvaExternalSources/CodeSourceService_templates/configureinstall.cpt
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Products/SilvaExternalSources/CodeSourceService_templates/configureinstall.cpt Tue Oct 29 17:16:37 2013 +0100
@@ -0,0 +1,80 @@
+<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>
+
+ <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>
+
+ </tal:extension>
+
+ </form>
+
+</tal:configure>
diff -r 771cd7f2f9d4 -r b67a3f81ae8a Products/SilvaExternalSources/CodeSourceService_templates/configureinstallcodesources.cpt
--- a/Products/SilvaExternalSources/CodeSourceService_templates/configureinstallcodesources.cpt Tue Oct 29 15:05:31 2013 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-<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>
diff -r 771cd7f2f9d4 -r b67a3f81ae8a Products/SilvaExternalSources/CodeSourceService_templates/manageexistingcodesources.pt
--- a/Products/SilvaExternalSources/CodeSourceService_templates/manageexistingcodesources.pt Tue Oct 29 15:05:31 2013 +0100
+++ b/Products/SilvaExternalSources/CodeSourceService_templates/manageexistingcodesources.pt Tue Oct 29 17:16:37 2013 +0100
@@ -20,7 +20,7 @@
</div>
<h2 i18n:translate="">
- Code sources used in this site
+ Code sources installed in this site
</h2>
<h3 i18n:translate="">