Ignore:
Timestamp:
21 Feb 2014, 11:07:54 (11 years ago)
Author:
uli
Message:

Merge current trunk into 0.2 maintenance branch. Now really

Location:
main/waeup.kofa/branches/0.2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/branches/0.2

  • main/waeup.kofa/branches/0.2/src/waeup/kofa/objecthistory.py

    r9126 r11161  
    5353        return self._getMessages()
    5454
    55     def addMessage(self, msg):
     55    def addMessage(self, msg, user=None):
    5656        """Add the message (history entry) in msg.
    5757
    5858        Any message will be stored with a timestamp and the current
    59         user (principal).
     59        user (principal) if user parameter is None.
    6060        """
    6161        msgs = self._getMessages()
    6262        tz = getUtility(IKofaUtils).tzinfo
    6363        timestamp = now(tz).strftime("%Y-%m-%d %H:%M:%S %Z")
    64         user = get_current_principal()
    65         if user is None:
    66             usertitle = 'system'
    67         elif user.id == 'zope.anybody':
    68             usertitle = 'Anonymous'
     64        portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
     65        msg = translate(msg,'waeup.kofa',target_language=portal_language)
     66        by = translate(_('by'),'waeup.kofa',target_language=portal_language)
     67        if user == None:
     68            user = get_current_principal()
     69            if user is None:
     70                usertitle = 'system'
     71            elif user.id == 'zope.anybody':
     72                usertitle = 'Anonymous'
     73            else:
     74                usertitle = getattr(user, 'public_name', None)
     75                if not usertitle:
     76                    usertitle = user.title
     77            msg = u'%s - %s %s %s' % (timestamp, msg, by, usertitle)
     78        elif user == 'undisclosed':
     79            msg = u'%s - %s' % (timestamp, msg)
    6980        else:
    70             usertitle = getattr(user, 'public_name', None)
    71             if not usertitle:
    72                 usertitle = user.title
    73         portal_language = getUtility(IKofaUtils).PORTAL_LANGUAGE
    74         by = translate(_('by'),'waeup.kofa',target_language=portal_language)
    75         msg = translate(msg,'waeup.kofa',target_language=portal_language)
    76         msg = u'%s - %s %s %s' % (timestamp, msg, by, usertitle)
     81            msg = u'%s - %s %s %s' % (timestamp, msg, by, user)
    7782        msgs.append(msg)
    7883        self._annotations[self.history_key] = msgs
Note: See TracChangeset for help on using the changeset viewer.