[gen] Bugfixes; for Ref field, replaced render mode 'titles' with 'minimal', allowing to display all fields defined in shownInfo.

This commit is contained in:
Gaetan Delannay 2014-05-19 12:12:33 +02:00
parent 57bab29447
commit b3a72ade24
4 changed files with 17 additions and 18 deletions

View file

@ -151,7 +151,7 @@ class Ref(Field):
'askConfirm(%s,%s,%s)' % (q('script'), q(formCall), \ 'askConfirm(%s,%s,%s)' % (q('script'), q(formCall), \
q(addConfirmMsg)); q(addConfirmMsg));
noFormCall=navBaseCall.replace('**v**', \ noFormCall=navBaseCall.replace('**v**', \
'%d,%s' % (startNumber, q('CreateWithoutForm'))); '%d,%s' % (startNumber, q('doCreateWithoutForm')));
noFormCall=not field.addConfirm and noFormCall or \ noFormCall=not field.addConfirm and noFormCall or \
'askConfirm(%s, %s, %s)' % (q('script'), q(noFormCall), \ 'askConfirm(%s, %s, %s)' % (q('script'), q(noFormCall), \
q(addConfirmMsg)); q(addConfirmMsg));
@ -341,10 +341,10 @@ class Ref(Field):
</td> </td>
</tr></table>''') </tr></table>''')
# Simplified widget showing comma-separated not-clickable object titles. # Simplified widget showing minimal info about tied objects.
pxViewTitles = Px('''<span class="smaller" pxViewMinimal = Px('''
var2="titles=[o.title for o in objects]">:', '.join(titles) or \ <x var2="infos=[field.getReferenceLabel(o, True) \
_('no_ref')</span>''') for o in objects]">:', '.join(infos) or _('no_ref')</x>''')
# PX that displays referred objects through this field. In mode link="list", # PX that displays referred objects through this field. In mode link="list",
# if, in the request, key "scope" is present and holds value "objs", the # if, in the request, key "scope" is present and holds value "objs", the
@ -383,7 +383,7 @@ class Ref(Field):
checkboxes=checkboxesEnabled and (totalNumber &gt; 1); checkboxes=checkboxesEnabled and (totalNumber &gt; 1);
showSubTitles=req.get('showSubTitles', 'true') == 'true'"> showSubTitles=req.get('showSubTitles', 'true') == 'true'">
<!-- JS tables storing checkbox statuses if checkboxes are enabled --> <!-- JS tables storing checkbox statuses if checkboxes are enabled -->
<script if="checkboxesEnabled and renderAll" <script if="checkboxesEnabled and renderAll and (render == 'list')"
type="text/javascript">:field.getCbJsInit(zobj)</script> type="text/javascript">:field.getCbJsInit(zobj)</script>
<div if="linkList and renderAll and mayEdit" <div if="linkList and renderAll and mayEdit"
var2="ajaxHookId='%s_%s_poss' % (zobj.id, field.name)" var2="ajaxHookId='%s_%s_poss' % (zobj.id, field.name)"
@ -393,7 +393,7 @@ class Ref(Field):
<div if="renderAll" id=":ajaxHookId">:field.pxViewList</div> <div if="renderAll" id=":ajaxHookId">:field.pxViewList</div>
<x if="not renderAll">:field.pxViewList</x> <x if="not renderAll">:field.pxViewList</x>
</x> </x>
<x if="render in ('menus','titles')">:getattr(field, 'pxView%s' % \ <x if="render in ('menus','minimal')">:getattr(field, 'pxView%s' % \
render.capitalize())</x> render.capitalize())</x>
</x>''') </x>''')
@ -562,8 +562,8 @@ class Ref(Field):
# Indeed, we need to keep the "list" rendering in the "view" layout # Indeed, we need to keep the "list" rendering in the "view" layout
# because the "menus" rendering is minimalist and does not allow to # because the "menus" rendering is minimalist and does not allow to
# perform all operations on linked objects (add, move, delete, edit...); # perform all operations on linked objects (add, move, delete, edit...);
# - "titles" renders a list of comma-separated, not-even-clickable, # - "minimal" renders a list of comma-separated, not-even-clickable,
# titles. # data about the tied objects (according to shownInfo).
self.render = render self.render = render
# If render is 'menus', 2 methods must be provided. # If render is 'menus', 2 methods must be provided.
# "menuIdMethod" will be called, with every linked object as single arg, # "menuIdMethod" will be called, with every linked object as single arg,
@ -1004,6 +1004,11 @@ class Ref(Field):
uids.remove(uid) uids.remove(uid)
uids.insert(newIndex, uid) uids.insert(newIndex, uid)
def doCreateWithoutForm(self, obj):
'''This method is called when a user wants to create a object from a
reference field, automatically (without displaying a form).'''
obj.appy().create(self.name)
xhtmlToText = re.compile('<.*?>', re.S) xhtmlToText = re.compile('<.*?>', re.S)
def getReferenceLabel(self, refObject, unlimited=False): def getReferenceLabel(self, refObject, unlimited=False):
'''p_self must have link=True. I need to display, on an edit view, the '''p_self must have link=True. I need to display, on an edit view, the

View file

@ -419,7 +419,7 @@ class ToolMixin(BaseMixin):
def quote(self, s): def quote(self, s):
'''Returns the quoted version of p_s.''' '''Returns the quoted version of p_s.'''
if not isinstance(s, basestring): s = str(s) if not isinstance(s, basestring): s = str(s)
s = s.replace('\r\n', '').replace('\n', '').replace("'", "\\'") s = s.replace('\r\n', '').replace('\n', '').replace("'", "&apos;")
return "'%s'" % s return "'%s'" % s
def getLayoutType(self): def getLayoutType(self):
@ -962,7 +962,7 @@ class ToolMixin(BaseMixin):
# c. Identify the user from the authentication form. # c. Identify the user from the authentication form.
if not login: if not login:
login = req.get('__ac_name', None) login = req.get('__ac_name', None)
password = req.get('__ac_password', None) password = req.get('__ac_password', '')
# Stop identification here if we don't need to return a special user # Stop identification here if we don't need to return a special user
if not alsoSpecial: return login, password if not alsoSpecial: return login, password
# d. All the identification methods failed. So identify the user as # d. All the identification methods failed. So identify the user as

View file

@ -324,12 +324,6 @@ class BaseMixin:
self.say(self.translate('action_done')) self.say(self.translate('action_done'))
self.goto(urlBack) self.goto(urlBack)
def onCreateWithoutForm(self):
'''This method is called when a user wants to create a object from a
reference field, automatically (without displaying a form).'''
rq = self.REQUEST
self.appy().create(rq['fieldName'])
def intraFieldValidation(self, errors, values): def intraFieldValidation(self, errors, values):
'''This method performs field-specific validation for every field from '''This method performs field-specific validation for every field from
the page that is being created or edited. For every field whose the page that is being created or edited. For every field whose

View file

@ -74,7 +74,7 @@ class UserWrapper(AbstractWrapper):
'''Sets a p_newPassword for self. If p_newPassword is not given, we '''Sets a p_newPassword for self. If p_newPassword is not given, we
generate one. This method returns the generated password (or simply generate one. This method returns the generated password (or simply
p_newPassword if no generation occurred).''' p_newPassword if no generation occurred).'''
if newPassword: if newPassword != None:
msgPart = 'changed' msgPart = 'changed'
else: else:
newPassword = self.getField('password1').generatePassword() newPassword = self.getField('password1').generatePassword()