Commit 206695a2 authored by Kevin Deldycke's avatar Kevin Deldycke

Move RPM patches from ERP5 product to dedicated repository

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@7852 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 5cbc4951
--- CMF-1.3.0.org/CMFCore/CatalogTool.py 2003-01-07 22:54:33.000000000 +0100
+++ CMF-1.3.0/CMFCore/CatalogTool.py 2003-02-18 09:41:46.000000000 +0100
@@ -67,6 +67,8 @@
for role in roles:
if allowed.has_key(role):
allowed['user:' + user] = 1
+ # Added for ERP5 project by JP Smets
+ if role != 'Owner': allowed['user:' + user + ':' + role] = 1
if allowed.has_key('Owner'):
del allowed['Owner']
return list(allowed.keys())
@@ -205,6 +207,20 @@
user = _getAuthenticatedUser(self)
kw[ 'allowedRolesAndUsers' ] = self._listAllowedRolesAndUsers( user )
+ # Patch for ERP5 by JP Smets in order
+ # to implement worklists and search of local roles
+ if kw.has_key('local_roles'):
+ # Only consider local_roles if it is not empty
+ if kw['local_roles'] != '' and kw['local_roles'] != [] and kw['local_roles'] is not None:
+ local_roles = kw['local_roles']
+ # Turn it into a list if necessary according to ';' separator
+ if type(local_roles) == type('a'):
+ local_roles = local_roles.split(';')
+ # Local roles now has precedence (since it comes from a WorkList)
+ kw[ 'allowedRolesAndUsers' ] = []
+ for role in local_roles:
+ kw[ 'allowedRolesAndUsers' ].append('user:%s:%s' % (user, role))
+
if not _checkPermission( AccessInactivePortalContent, self ):
base = aq_base( self )
now = DateTime()
--- CMF-1.3.0.org/DCWorkflow/DCWorkflow.py 2002-11-04 20:25:58.000000000 +0100
+++ CMF-1.3.0/DCWorkflow/DCWorkflow.py 2003-02-18 09:41:31.000000000 +0100
@@ -211,30 +211,41 @@
for id, qdef in self.worklists.items():
if qdef.actbox_name:
guard = qdef.guard
- if guard is None or guard.check(sm, self, portal):
- searchres = None
- var_match_keys = qdef.getVarMatchKeys()
- if var_match_keys:
- # Check the catalog for items in the worklist.
- catalog = getToolByName(self, 'portal_catalog')
- dict = {}
- for k in var_match_keys:
- v = qdef.getVarMatch(k)
- v_fmt = map(lambda x, info=info: x%info, v)
- dict[k] = v_fmt
- searchres = apply(catalog.searchResults, (), dict)
- if not searchres:
- continue
- if fmt_data is None:
- fmt_data = TemplateDict()
- fmt_data._push(info)
- searchres_len = lambda searchres=searchres: len(searchres)
- fmt_data._push({'count': searchres_len})
- res.append((id, {'name': qdef.actbox_name % fmt_data,
- 'url': qdef.actbox_url % fmt_data,
- 'permissions': (), # Predetermined.
- 'category': qdef.actbox_category}))
- fmt_data._pop()
+ # Patch for ERP5 by JP Smets in order
+ # to implement worklists and search of local roles
+ searchres = None
+ var_match_keys = qdef.getVarMatchKeys()
+ if var_match_keys:
+ # Check the catalog for items in the worklist.
+ catalog = getToolByName(self, 'portal_catalog')
+ dict = {}
+ for k in var_match_keys:
+ v = qdef.getVarMatch(k)
+ v_fmt = map(lambda x, info=info: x%info, v)
+ dict[k] = v_fmt
+ # Patch for ERP5 by JP Smets in order
+ # to implement worklists and search of local roles
+ if not (guard is None or guard.check(sm, self, portal)):
+ dict['local_roles'] = guard.roles
+ searchres = apply(catalog.searchResults, (), dict)
+ if not searchres:
+ continue
+ if fmt_data is None:
+ fmt_data = TemplateDict()
+ fmt_data._push(info)
+ searchres_len = lambda searchres=searchres: len(searchres)
+ fmt_data._push({'count': searchres_len})
+ # Patch for ERP5 by JP Smets in order
+ # to implement worklists and search of local roles
+ if dict.has_key('local_roles'):
+ fmt_data._push({'local_roles': join(guard.roles,';')})
+ else:
+ fmt_data._push({'local_roles': ''})
+ res.append((id, {'name': qdef.actbox_name % fmt_data,
+ 'url': qdef.actbox_url % fmt_data,
+ 'permissions': (), # Predetermined.
+ 'category': qdef.actbox_category}))
+ fmt_data._pop()
res.sort()
return map((lambda (id, val): val), res)
#!/bin/bash
diff -ur CMF-1.3.0.org/CMFCore/CatalogTool.py CMF-1.3.0/CMFCore/CatalogTool.py > CMF_local_context_worklist.patch
diff -ur CMF-1.3.0.org/DCWorkflow/DCWorkflow.py CMF-1.3.0/DCWorkflow/DCWorkflow.py >> CMF_local_context_worklist.patch
This diff is collapsed.
This diff is collapsed.
Common subdirectories: Formulator/dtml and Formulator.jp/dtml
diff -u Formulator/Field.py Formulator.jp/Field.py
--- Formulator/Field.py 2002-03-05 19:17:13.000000000 +0100
+++ Formulator.jp/Field.py 2003-02-23 10:55:12.000000000 +0100
@@ -123,7 +123,7 @@
def get_tales(self, id):
"""Get tales expression method for id."""
return self.tales.get(id, "")
-
+
security.declareProtected('Access contents information', 'is_required')
def is_required(self):
"""Check whether this field is required (utility function)
@@ -145,7 +145,7 @@
return getattr(self.validator, name)
else:
return "Unknown error: %s" % name
-
+
security.declarePrivate('_render_helper')
def _render_helper(self, key, value, REQUEST):
value = self._get_default(key, value, REQUEST)
@@ -164,7 +164,7 @@
return self.get_value('default')
security.declareProtected('View', 'render')
- def render(self, value=None, REQUEST=None):
+ def render(self, value=None, REQUEST=None, key=None):
"""Render the field widget.
value -- the value the field should have (for instance
from validation).
@@ -174,7 +174,10 @@
if value and REQUEST are both None, the 'default' property of
the field will be used for the value.
"""
- return self._render_helper('field_%s' % self.id, value, REQUEST)
+ # Patched by JPS for ERP5 in order to
+ # dynamically change the name
+ if key is None: key = self.id
+ return self._render_helper('field_%s' % key, value, REQUEST)
security.declareProtected('View', 'render_from_request')
def render_from_request(self, REQUEST):
@@ -182,7 +185,7 @@
(unvalidated data), or default if no raw data is found.
"""
return self._render_helper('field_%s' % self.id, None, REQUEST)
-
+
security.declareProtected('View', 'render_sub_field')
def render_sub_field(self, id, value=None, REQUEST=None):
"""Render a sub field, as part of complete rendering of widget in
Common subdirectories: Formulator/help and Formulator.jp/help
Common subdirectories: Formulator/tests and Formulator.jp/tests
diff -u Formulator/Validator.py Formulator.jp/Validator.py
--- Formulator/Validator.py 2002-11-26 13:50:09.000000000 +0100
+++ Formulator.jp/Validator.py 2003-03-24 14:47:10.000000000 +0100
@@ -31,10 +31,10 @@
def raise_error(self, error_key, field):
raise ValidationError(error_key, field)
-
- def validate(self, field, key, REQUEST):
+
+ def validate(self, field, key, REQUEST):
pass # override in subclass
-
+
class StringBaseValidator(Validator):
"""Simple string validator.
"""
@@ -48,15 +48,18 @@
default=1)
message_names = Validator.message_names + ['required_not_found']
-
+
required_not_found = 'Input is required but no input given.'
-
+
def validate(self, field, key, REQUEST):
- value = string.strip(REQUEST.get(key, ""))
+ # We had to add this patch for hidden fields of type "list"
+ value = REQUEST.get(key, "")
+ if type(value) is type('a'):
+ value = string.strip(value)
if field.get_value('required') and value == "":
self.raise_error('required_not_found', field)
return value
-
+
class StringValidator(StringBaseValidator):
property_names = StringBaseValidator.property_names +\
['max_length', 'truncate']
@@ -259,16 +262,19 @@
"If set to 0 or is left empty, there is no maximum."),
default="",
required=0)
-
+
message_names = StringBaseValidator.message_names +\
['too_many_lines', 'line_too_long', 'too_long']
too_many_lines = 'You entered too many lines.'
line_too_long = 'A line was too long.'
too_long = 'You entered too many characters.'
-
+
def validate(self, field, key, REQUEST):
value = StringBaseValidator.validate(self, field, key, REQUEST)
+ # Added as a patch for hidden values
+ if type(value) is type([]) or type(value) is type(()):
+ value = string.join(value, "\n")
# we need to add this check again
if value == "" and not field.get_value('required'):
return []
@@ -337,10 +343,10 @@
# will remain integers.
if str(item_value) == value:
return item_value
-
+
# if we didn't find the value, return error
self.raise_error('unknown_selection', field)
-
+
SelectionValidatorInstance = SelectionValidator()
class MultiSelectionValidator(Validator):
@@ -355,10 +361,10 @@
message_names = Validator.message_names + ['required_not_found',
'unknown_selection']
-
+
required_not_found = 'Input is required but no input given.'
unknown_selection = 'You selected an item that was not in the list.'
-
+
def validate(self, field, key, REQUEST):
values = REQUEST.get(key, [])
# NOTE: a hack to deal with single item selections
@@ -372,7 +378,7 @@
self.raise_error('required_not_found', field)
else:
return values
-
+
# create a dictionary of possible values
value_dict = {}
for item in field.get_value('items'):
diff -u Formulator/Widget.py Formulator.jp/Widget.py
--- Formulator/Widget.py 2002-10-24 12:35:07.000000000 +0200
+++ Formulator.jp/Widget.py 2003-03-24 14:33:42.000000000 +0100
@@ -67,7 +67,7 @@
"to add an onClick attribute to use with JavaScript, for instance."),
default="",
required=0)
-
+
def render(self, field, key, value, REQUEST):
"""Renders this widget as HTML using property values in field.
"""
@@ -79,14 +79,26 @@
try:
extra = field.get_value('extra')
except KeyError:
- # In case extra is not defined as in DateTimeWidget
+ # In case extra is not defined as in DateTimeWidget
extra = ''
- return render_element("input",
+ result = ''
+ # We must adapt the rendering to the type of the value
+ # in order to get the correct type back
+ if type(value) is type([]) or type(value) is type(()):
+ for v in value:
+ result += render_element("input",
+ type="hidden",
+ name="%s:list" % key,
+ value=v,
+ extra=extra)
+ else:
+ result = render_element("input",
type="hidden",
name=key,
value=value,
extra=extra)
-
+ return result
+
class TextWidget(Widget):
"""Text widget
"""
@@ -202,7 +214,7 @@
"""
property_names = Widget.property_names +\
['width', 'height', 'extra']
-
+
default = fields.TextAreaField('default',
title='Default',
description=(
@@ -210,7 +222,7 @@
default="",
width=20, height=3,
required=0)
-
+
width = fields.IntegerField('width',
title='Width',
description=(
@@ -228,7 +240,7 @@
def render(self, field, key, value, REQUEST):
width = field.get_value('width')
height = field.get_value('height')
-
+
return render_element("textarea",
name=key,
css_class=field.get_value('css_class'),
@@ -236,7 +248,7 @@
rows=height,
contents=html_quote(value),
extra=field.get_value('extra'))
-
+
TextAreaWidgetInstance = TextAreaWidget()
class LinesTextAreaWidget(TextAreaWidget):
Common subdirectories: Formulator/www and Formulator.jp/www
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment