Changeset - 9b623dcddb02
[Not reviewed]
beta
0 2 0
Marcin Kuzminski - 13 years ago 2012-06-11 23:23:32
marcin@python-works.com
Format datetime in notifications according to unified function
2 files changed with 6 insertions and 6 deletions:
0 comments (0 inline, 0 general)
rhodecode/lib/helpers.py
Show inline comments
 
@@ -44,6 +44,7 @@ from rhodecode.lib.utils2 import str2boo
 
from rhodecode.lib.markup_renderer import MarkupRenderer
 
from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
 
from rhodecode.lib.vcs.backends.base import BaseChangeset
 
from rhodecode.config.conf import DATE_FORMAT, DATETIME_FORMAT
 
from rhodecode.model.db import URL_SEP
 

	
 
log = logging.getLogger(__name__)
 
@@ -350,8 +351,8 @@ hide_credentials = lambda x: ''.join(cre
 

	
 
def fmt_date(date):
 
    if date:
 
        return (date.strftime(_(u"%a, %d %b %Y %H:%M:%S").encode('utf8'))
 
            .decode('utf8'))
 
        _fmt = _(u"%a, %d %b %Y %H:%M:%S").encode('utf8')
 
        return date.strftime(_fmt).decode('utf8')
 

	
 
    return ""
 

	
rhodecode/model/notification.py
Show inline comments
 
@@ -32,7 +32,6 @@ import datetime
 
from pylons.i18n.translation import _
 

	
 
import rhodecode
 
from rhodecode.config.conf import DATETIME_FORMAT
 
from rhodecode.lib import helpers as h
 
from rhodecode.model import BaseModel
 
from rhodecode.model.db import Notification, User, UserNotification
 
@@ -181,12 +180,12 @@ class NotificationModel(BaseModel):
 
            notification.TYPE_REGISTRATION: _('registered in RhodeCode')
 
        }
 

	
 
        tmpl = "%(user)s %(action)s %(when)s"
 
        # action == _map string
 
        tmpl = "%(user)s %(action)s at %(when)s"
 
        if show_age:
 
            when = h.age(notification.created_on)
 
        else:
 
            DTF = lambda d: datetime.datetime.strftime(d, DATETIME_FORMAT)
 
            when = DTF(notification.created_on)
 
            when = h.fmt_date(notification.created_on)
 

	
 
        data = dict(
 
            user=notification.created_by_user.username,
0 comments (0 inline, 0 general)