[gen] Field.indexed, instead of being a Boolean, can be a str, to represent the name of a Zope Index. This way, it is possible to bypass the standard Appy choice for index types, ie for Computed fields whose content may produce any type of value; added missing translation labels in the macro displaying object's history; added default fields Tool.dateFormat and Tool.hourFormat that give application-wide default formats for dates with/without hour; added a table in Config->Users that shows the connected users and the date/time of their last access to the app; added the missing search macro for a Computed field.

This commit is contained in:
Gaetan Delannay 2012-07-18 21:58:11 +02:00
parent 21ffa7b46d
commit 699cc8346b
8 changed files with 95 additions and 21 deletions

View file

@ -1020,6 +1020,30 @@ class ToolMixin(BaseMixin):
url = appyUser.o.getUrl(mode='edit', page='main', nav='')
return (' | '.join(info), url)
def getUserName(self, login):
'''Gets the user name corresponding to p_login, or the p_login itself
if the user does not exist anymore.'''
user = self.appy().search1('User', noSecurity=True, login=login)
if not user: return login
firstName = user.firstName
name = user.name
res = ''
if firstName: res += firstName
if name:
if res: res += ' ' + name
else: res = name
if not res: res = login
return res
def formatDate(self, aDate, withHour=True):
'''Returns aDate formatted as specified by tool.dateFormat.
If p_withHour is True, hour is appended, with a format specified
in tool.hourFormat.'''
tool = self.appy()
res = aDate.strftime(tool.dateFormat)
if withHour: res += ' (%s)' % aDate.strftime(tool.hourFormat)
return res
def generateUid(self, className):
'''Generates a UID for an instance of p_className.'''
name = className.split('_')[-1]