comments viewlet's format_time now returns localized time.
svn path=/plone.app.discussion/trunk/; revision=27471
This commit is contained in:
parent
de5499d996
commit
3d4343440c
@ -19,7 +19,7 @@ BASIC COMMENTING FUNCTIONALITY
|
|||||||
|
|
||||||
[ ] Fix temporary commenter's image css
|
[ ] Fix temporary commenter's image css
|
||||||
|
|
||||||
[ ] Make comments viewlet format_time return localized time
|
[X] Make comments viewlet format_time return localized time
|
||||||
|
|
||||||
[ ] Add i18n translations
|
[ ] Add i18n translations
|
||||||
|
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
from DateTime import DateTime
|
||||||
|
|
||||||
from urllib import quote as url_quote
|
from urllib import quote as url_quote
|
||||||
|
|
||||||
@ -125,10 +126,11 @@ class CommentsViewlet(ViewletBase):
|
|||||||
return '%s/login_form?came_from=%s' % (self.navigation_root_url, url_quote(self.request.get('URL', '')),)
|
return '%s/login_form?came_from=%s' % (self.navigation_root_url, url_quote(self.request.get('URL', '')),)
|
||||||
|
|
||||||
def format_time(self, time):
|
def format_time(self, time):
|
||||||
# Todo: return localized time
|
# We have to transform Python datetime into Zope DateTime
|
||||||
return time.strftime("%a, %d %b %Y %H:%M")
|
# before we can call toLocalizedTime
|
||||||
# XXX: Not working, returns None !!!
|
util = getToolByName(self.context, 'translation_service')
|
||||||
#return self.context.restrictedTraverse('@@plone').toLocalizedTime(time, long_format=True)
|
zope_time = DateTime(time.year, time.month, time.day, time.hour, time.minute, time.second)
|
||||||
|
return util.toLocalizedTime(zope_time, long_format=True)
|
||||||
|
|
||||||
class AddComment(BrowserView):
|
class AddComment(BrowserView):
|
||||||
"""Add a comment to a conversation
|
"""Add a comment to a conversation
|
||||||
|
@ -37,7 +37,9 @@ class CommentsViewletTest(PloneTestCase):
|
|||||||
self.viewlet = CommentsViewlet(context, request, None, None)
|
self.viewlet = CommentsViewlet(context, request, None, None)
|
||||||
|
|
||||||
def test_format_time(self):
|
def test_format_time(self):
|
||||||
pass
|
python_time = datetime(2009, 02, 01, 23, 32, 03, 57)
|
||||||
|
localized_time = self.viewlet.format_time(python_time)
|
||||||
|
self.assertEquals(localized_time, "Feb 01, 2009 11:32 PM")
|
||||||
|
|
||||||
def test_get_commenter_portrait(self):
|
def test_get_commenter_portrait(self):
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user