Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
1bd2ec25
Commit
1bd2ec25
authored
8 years ago
by
Peter Fogg
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12474 from edx/peter-fogg/date-summary-fixes
Fixes for courseware date formatting/translation.
parents
73806bee
80bfa36d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
10 deletions
+14
-10
lms/djangoapps/courseware/date_summary.py
+14
-10
No files found.
lms/djangoapps/courseware/date_summary.py
View file @
1bd2ec25
...
@@ -8,6 +8,7 @@ from datetime import datetime
...
@@ -8,6 +8,7 @@ from datetime import datetime
from
babel.dates
import
format_timedelta
from
babel.dates
import
format_timedelta
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext
as
_
from
django.utils.translation
import
ugettext_lazy
from
django.utils.translation
import
to_locale
,
get_language
from
django.utils.translation
import
to_locale
,
get_language
from
edxmako.shortcuts
import
render_to_string
from
edxmako.shortcuts
import
render_to_string
from
lazy
import
lazy
from
lazy
import
lazy
...
@@ -51,7 +52,7 @@ class DateSummary(object):
...
@@ -51,7 +52,7 @@ class DateSummary(object):
The format to display this date in. By default, displays like Jan
The format to display this date in. By default, displays like Jan
01, 2015.
01, 2015.
"""
"""
return
'
%
b
%
d,
%
Y'
return
u
'
%
b
%
d,
%
Y'
@property
@property
def
link
(
self
):
def
link
(
self
):
...
@@ -107,7 +108,7 @@ class DateSummary(object):
...
@@ -107,7 +108,7 @@ class DateSummary(object):
# 'absolute'. For example, 'absolute' might be "Jan 01, 2020",
# 'absolute'. For example, 'absolute' might be "Jan 01, 2020",
# and if today were December 5th, 2020, 'relative' would be "1
# and if today were December 5th, 2020, 'relative' would be "1
# month".
# month".
date_format
=
_
(
"{relative} ago - {absolute}"
)
if
date_has_passed
else
_
(
"in {relative} - {absolute}"
)
date_format
=
_
(
u"{relative} ago - {absolute}"
)
if
date_has_passed
else
_
(
u
"in {relative} - {absolute}"
)
return
date_format
.
format
(
return
date_format
.
format
(
relative
=
relative_date
,
relative
=
relative_date
,
absolute
=
self
.
date
.
strftime
(
self
.
date_format
),
absolute
=
self
.
date
.
strftime
(
self
.
date_format
),
...
@@ -126,7 +127,7 @@ class DateSummary(object):
...
@@ -126,7 +127,7 @@ class DateSummary(object):
return
False
return
False
def
__repr__
(
self
):
def
__repr__
(
self
):
return
'DateSummary: "{title}" {date} is_enabled={is_enabled}'
.
format
(
return
u
'DateSummary: "{title}" {date} is_enabled={is_enabled}'
.
format
(
title
=
self
.
title
,
title
=
self
.
title
,
date
=
self
.
date
,
date
=
self
.
date
,
is_enabled
=
self
.
is_enabled
is_enabled
=
self
.
is_enabled
...
@@ -139,7 +140,10 @@ class TodaysDate(DateSummary):
...
@@ -139,7 +140,10 @@ class TodaysDate(DateSummary):
"""
"""
css_class
=
'todays-date'
css_class
=
'todays-date'
is_enabled
=
True
is_enabled
=
True
date_format
=
'
%
b
%
d,
%
Y (
%
H:
%
M {utc})'
.
format
(
utc
=
_
(
'UTC'
))
@property
def
date_format
(
self
):
return
u'
%
b
%
d,
%
Y (
%
H:
%
M {utc})'
.
format
(
utc
=
_
(
'UTC'
))
# The date is shown in the title, no need to display it again.
# The date is shown in the title, no need to display it again.
def
get_context
(
self
):
def
get_context
(
self
):
...
@@ -153,7 +157,7 @@ class TodaysDate(DateSummary):
...
@@ -153,7 +157,7 @@ class TodaysDate(DateSummary):
@property
@property
def
title
(
self
):
def
title
(
self
):
return
_
(
'Today is {date}'
)
.
format
(
date
=
datetime
.
now
(
pytz
.
UTC
)
.
strftime
(
self
.
date_format
))
return
_
(
u
'Today is {date}'
)
.
format
(
date
=
datetime
.
now
(
pytz
.
UTC
)
.
strftime
(
self
.
date_format
))
class
CourseStartDate
(
DateSummary
):
class
CourseStartDate
(
DateSummary
):
...
@@ -161,7 +165,7 @@ class CourseStartDate(DateSummary):
...
@@ -161,7 +165,7 @@ class CourseStartDate(DateSummary):
Displays the start date of the course.
Displays the start date of the course.
"""
"""
css_class
=
'start-date'
css_class
=
'start-date'
title
=
_
(
'Course Starts'
)
title
=
ugettext_lazy
(
'Course Starts'
)
@property
@property
def
date
(
self
):
def
date
(
self
):
...
@@ -173,7 +177,7 @@ class CourseEndDate(DateSummary):
...
@@ -173,7 +177,7 @@ class CourseEndDate(DateSummary):
Displays the end date of the course.
Displays the end date of the course.
"""
"""
css_class
=
'end-date'
css_class
=
'end-date'
title
=
_
(
'Course End'
)
title
=
ugettext_lazy
(
'Course End'
)
@property
@property
def
is_enabled
(
self
):
def
is_enabled
(
self
):
...
@@ -200,12 +204,12 @@ class VerifiedUpgradeDeadlineDate(DateSummary):
...
@@ -200,12 +204,12 @@ class VerifiedUpgradeDeadlineDate(DateSummary):
Verified track.
Verified track.
"""
"""
css_class
=
'verified-upgrade-deadline'
css_class
=
'verified-upgrade-deadline'
title
=
_
(
'Verification Upgrade Deadline'
)
title
=
ugettext_lazy
(
'Verification Upgrade Deadline'
)
description
=
_
(
description
=
ugettext_lazy
(
'You are still eligible to upgrade to a Verified Certificate! '
'You are still eligible to upgrade to a Verified Certificate! '
'Pursue it to highlight the knowledge and skills you gain in this course.'
'Pursue it to highlight the knowledge and skills you gain in this course.'
)
)
link_text
=
_
(
'Upgrade to Verified Certificate'
)
link_text
=
ugettext_lazy
(
'Upgrade to Verified Certificate'
)
@property
@property
def
link
(
self
):
def
link
(
self
):
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment