Mercurial > kallithea
comparison rhodecode/model/notification.py @ 2445:9b623dcddb02 beta
Format datetime in notifications according to unified function
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Mon, 11 Jun 2012 23:23:32 +0200 |
parents | 7d517a35b6c9 |
children | 4753a3445ff7 |
comparison
equal
deleted
inserted
replaced
2437:81c29d269aed | 2445:9b623dcddb02 |
---|---|
30 import datetime | 30 import datetime |
31 | 31 |
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 |
39 | 38 |
40 log = logging.getLogger(__name__) | 39 log = logging.getLogger(__name__) |
179 notification.TYPE_MESSAGE: _('sent message'), | 178 notification.TYPE_MESSAGE: _('sent message'), |
180 notification.TYPE_MENTION: _('mentioned you'), | 179 notification.TYPE_MENTION: _('mentioned you'), |
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, |
193 action=_map[notification.type_], when=when, | 192 action=_map[notification.type_], when=when, |
194 ) | 193 ) |