[gen] When param Ref.select is a Search instance, Search.name can be ommitted; added code that shows a warning: Appy is not compatible with MSIE below 9.

This commit is contained in:
Gaetan Delannay 2014-07-28 17:35:49 +02:00
parent a45dfa8dd0
commit dda894089a
14 changed files with 54 additions and 4 deletions

View file

@ -24,10 +24,12 @@ from group import Group
# ------------------------------------------------------------------------------
class Search:
'''Used for specifying a search for a given class.'''
def __init__(self, name, group=None, sortBy='', sortOrder='asc',
def __init__(self, name=None, group=None, sortBy='', sortOrder='asc',
maxPerPage=30, default=False, colspan=1, translated=None,
show=True, translatedDescr=None, checkboxes=False,
checkboxesDefault=True, **fields):
# "name" is mandatory, excepted in some special cases (ie, when used as
# "select" param for a Ref field).
self.name = name
# Searches may be visually grouped in the portlet.
self.group = Group.get(group)

View file

@ -730,6 +730,9 @@ class ZopeGenerator(Generator):
def generateSearches(self, classDescr):
'''Generates i18n labels for searches defined on p_classDescr.'''
for search in classDescr.getSearches(classDescr.klass):
if not search.name:
className = classDescr.klass.__name__
raise Exception('Search defined on %s has no name.' % className)
label = '%s_search_%s' % (classDescr.name, search.name)
self.i18n(label, search.name)
self.i18n('%s_descr' % label, ' ', nice=False)

View file

@ -1410,4 +1410,16 @@ class ToolMixin(BaseMixin):
'''Returns the PX allowing to close the iframe popup and refresh the
base page.'''
return self.appy().pxBack({'ztool': self})
ieRex = re.compile('MSIE\s+(\d\.\d)')
ieMin = '9' # We do not support IE below this version.
def getBrowserIncompatibility(self):
'''Produces an error message if the browser in use is not compatible
with Appy.'''
res = self.ieRex.search(self.REQUEST.get('HTTP_USER_AGENT'))
if not res: return
version = res.group(1)
if version < self.ieMin:
mapping = {'version': version, 'min': self.ieMin}
return self.translate('wrong_browser', mapping=mapping)
# ------------------------------------------------------------------------------

View file

@ -715,6 +715,6 @@ msgstr ""
msgid "unauthorized"
msgstr ""
#. Default: "Close"
msgid "window_close"
#. Default: "Microsoft Internet Explorer ${version} is not supported. Please upgrade your browser to version ${min} or above."
msgid "wrong_browser"
msgstr ""

View file

@ -714,3 +714,7 @@ msgstr ""
#. Default: "You are not allowed to consult this."
msgid "unauthorized"
msgstr ""
#. Default: "Microsoft Internet Explorer ${version} is not supported. Please upgrade your browser to version ${min} or above."
msgid "wrong_browser"
msgstr ""

View file

@ -714,3 +714,7 @@ msgstr ""
#. Default: "You are not allowed to consult this."
msgid "unauthorized"
msgstr ""
#. Default: "Microsoft Internet Explorer ${version} is not supported. Please upgrade your browser to version ${min} or above."
msgid "wrong_browser"
msgstr ""

View file

@ -715,3 +715,7 @@ msgstr "In some situations, by leaving this page this way, you may lose encoded
#. Default: "You are not allowed to consult this."
msgid "unauthorized"
msgstr "You are not allowed to consult this."
#. Default: "Microsoft Internet Explorer ${version} is not supported. Please upgrade your browser to version ${min} or above."
msgid "wrong_browser"
msgstr "Microsoft Internet Explorer ${version} is not supported. Please upgrade your browser to version ${min} or above."

View file

@ -714,3 +714,7 @@ msgstr ""
#. Default: "You are not allowed to consult this."
msgid "unauthorized"
msgstr ""
#. Default: "Microsoft Internet Explorer ${version} is not supported. Please upgrade your browser to version ${min} or above."
msgid "wrong_browser"
msgstr ""

View file

@ -715,3 +715,7 @@ msgstr "Dans certaines situations, en quittant cette page de cette manière, vou
#. Default: "You are not allowed to consult this."
msgid "unauthorized"
msgstr "Vous n'êtes pas autorisé à consulter ceci."
#. Default: "Microsoft Internet Explorer ${version} is not supported. Please upgrade your browser to version ${min} or above."
msgid "wrong_browser"
msgstr "Microsoft Internet Explorer ${version} n'est pas supporté. Veuillez mettre à jour votre navigateur à la version ${min} ou supérieure."

View file

@ -714,3 +714,7 @@ msgstr ""
#. Default: "You are not allowed to consult this."
msgid "unauthorized"
msgstr ""
#. Default: "Microsoft Internet Explorer ${version} is not supported. Please upgrade your browser to version ${min} or above."
msgid "wrong_browser"
msgstr ""

View file

@ -714,3 +714,7 @@ msgstr ""
#. Default: "You are not allowed to consult this."
msgid "unauthorized"
msgstr ""
#. Default: "Microsoft Internet Explorer ${version} is not supported. Please upgrade your browser to version ${min} or above."
msgid "wrong_browser"
msgstr ""

View file

@ -47,6 +47,7 @@ img { border: 0; vertical-align: middle }
.main { width: 900px; height: 95%; box-shadow: 3px 3px 3px #A9A9A9 }
.mainWide { width: 100%; height: 100% }
.wrongBrowser { height: 15px; color: red; text-align: center }
.top { height: 89px; margin-left: 3em; vertical-align: top;
background-color: white }
.lang { margin-right: 6px }

View file

@ -236,7 +236,7 @@ function askQueryResult(hookId, objectUrl, className, searchName, popup,
var filterWidget = document.getElementById(hookId + '_' + filterKey);
if (filterWidget && filterWidget.value) {
params['filterKey'] = filterKey;
params['filterValue'] = filterWidget.value;
params['filterValue'] = encodeURIComponent(filterWidget.value);
}
}
askAjaxChunk(hookId, 'GET', objectUrl, 'pxQueryResult', params, null,

View file

@ -181,6 +181,10 @@ class AbstractWrapper(object):
<table class=":(cfg.skin == 'wide') and 'mainWide main' or 'main'"
align="center" cellpadding="0">
<!-- The browser incompatibility message when relevant -->
<tr var="bi=ztool.getBrowserIncompatibility()" if="bi"
class="wrongBrowser"><td>:bi</td></tr>
<tr class="top" if="not inPopup">
<!-- Top banner -->
<td var="bannerName=(dir == 'ltr') and 'banner' or 'bannerrtl'"