Replace django_date with datetime.datetime.strftime

The django_date transforms time to string with i18n, which will
cause error while using chinese, we can fix this either encode
the date_str using 'utf8' or use datetime.datetime.strftime to
do the transform job.

Closes-Bug: #1671315

Change-Id: Ice599334b29125cfac69ab30e04b956024f34517
This commit is contained in:
jiangpch 2017-03-07 11:04:03 +08:00
parent 8add59f426
commit d78e627783
1 changed files with 2 additions and 4 deletions

View File

@ -13,7 +13,6 @@
import datetime
import pprint
from django.template.defaultfilters import date as django_date
from django.utils.translation import ugettext_lazy as _
from django.views import generic
@ -62,9 +61,8 @@ class RestoreView(workflows.WorkflowView):
@shield('Unable to get backup.', redirect='backups:index')
def get_workflow_name(self):
backup = freezer_api.Backup(self.request).get(self.kwargs['backup_id'])
backup_date = datetime.datetime.fromtimestamp(int(backup.time_stamp))
backup_date_str = django_date(backup_date,
'SHORT_DATETIME_FORMAT')
backup_date_str = datetime.datetime.fromtimestamp(int(backup.time_stamp))\
.strftime("%Y/%m/%d %H:%M")
return "Restore '{}' from {}".format(backup.backup_name,
backup_date_str)