##// END OF EJS Templates
Format datetime in notifications according to unified function
marcink -
r2445:9b623dcd beta
parent child Browse files
Show More
@@ -44,6 +44,7 b' from rhodecode.lib.utils2 import str2boo'
44 from rhodecode.lib.markup_renderer import MarkupRenderer
44 from rhodecode.lib.markup_renderer import MarkupRenderer
45 from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
45 from rhodecode.lib.vcs.exceptions import ChangesetDoesNotExistError
46 from rhodecode.lib.vcs.backends.base import BaseChangeset
46 from rhodecode.lib.vcs.backends.base import BaseChangeset
47 from rhodecode.config.conf import DATE_FORMAT, DATETIME_FORMAT
47 from rhodecode.model.db import URL_SEP
48 from rhodecode.model.db import URL_SEP
48
49
49 log = logging.getLogger(__name__)
50 log = logging.getLogger(__name__)
@@ -350,8 +351,8 b" hide_credentials = lambda x: ''.join(cre"
350
351
351 def fmt_date(date):
352 def fmt_date(date):
352 if date:
353 if date:
353 return (date.strftime(_(u"%a, %d %b %Y %H:%M:%S").encode('utf8'))
354 _fmt = _(u"%a, %d %b %Y %H:%M:%S").encode('utf8')
354 .decode('utf8'))
355 return date.strftime(_fmt).decode('utf8')
355
356
356 return ""
357 return ""
357
358
@@ -32,7 +32,6 b' import datetime'
32 from pylons.i18n.translation import _
32 from pylons.i18n.translation import _
33
33
34 import rhodecode
34 import rhodecode
35 from rhodecode.config.conf import DATETIME_FORMAT
36 from rhodecode.lib import helpers as h
35 from rhodecode.lib import helpers as h
37 from rhodecode.model import BaseModel
36 from rhodecode.model import BaseModel
38 from rhodecode.model.db import Notification, User, UserNotification
37 from rhodecode.model.db import Notification, User, UserNotification
@@ -181,12 +180,12 b' class NotificationModel(BaseModel):'
181 notification.TYPE_REGISTRATION: _('registered in RhodeCode')
180 notification.TYPE_REGISTRATION: _('registered in RhodeCode')
182 }
181 }
183
182
184 tmpl = "%(user)s %(action)s %(when)s"
183 # action == _map string
184 tmpl = "%(user)s %(action)s at %(when)s"
185 if show_age:
185 if show_age:
186 when = h.age(notification.created_on)
186 when = h.age(notification.created_on)
187 else:
187 else:
188 DTF = lambda d: datetime.datetime.strftime(d, DATETIME_FORMAT)
188 when = h.fmt_date(notification.created_on)
189 when = DTF(notification.created_on)
190
189
191 data = dict(
190 data = dict(
192 user=notification.created_by_user.username,
191 user=notification.created_by_user.username,
General Comments 0
You need to be logged in to leave comments. Login now