Merge lp:~davidc3/developer-ubuntu-com/translations-dashboard-1528618 into lp:developer-ubuntu-com

Proposed by David Callé on 2015-12-22
Status: Merged
Approved by: David Callé on 2015-12-22
Approved revision: 184
Merged at revision: 183
Proposed branch: lp:~davidc3/developer-ubuntu-com/translations-dashboard-1528618
Merge into: lp:developer-ubuntu-com
Diff against target: 31 lines (+7/-1)
1 file modified
translations_dashboard/views.py (+7/-1)
To merge this branch: bzr merge lp:~davidc3/developer-ubuntu-com/translations-dashboard-1528618
Reviewer Review Type Date Requested Status
Daniel Holbach (community) 2015-12-22 Approve on 2015-12-22
Review via email: mp+281225@code.launchpad.net

Commit Message

Fix for #1528618 : translations-dashboard not handling pages without a language

Description of the Change

When an english page is missing from the pages list, we still need a time to sort it.

To post a comment you must log in.
Daniel Holbach (dholbach) wrote :

LGTM.

review: Approve
184. By David Callé on 2015-12-22

List only published changes

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'translations_dashboard/views.py'
2--- translations_dashboard/views.py 2015-10-02 16:59:20 +0000
3+++ translations_dashboard/views.py 2015-12-22 16:03:19 +0000
4@@ -2,6 +2,8 @@
5 from django.template import RequestContext
6 from django.views.decorators.cache import never_cache
7 from cms.models import CMSPlugin
8+import datetime
9+import pytz
10
11
12 def get_pages():
13@@ -13,6 +15,8 @@
14 date = plugin_change.changed_date
15 lang = plugin_change.language.replace('-', '_')
16 page = plugin_change.placeholder.page
17+ if not page or page.publisher_is_draft:
18+ continue
19 path = page.get_path()
20 if path not in known_paths:
21 known_paths.append(path)
22@@ -25,8 +29,10 @@
23 p[lang] = date
24 else:
25 p[lang] = date
26+ # When an english page is missing, we still need a time to sort pages
27+ notime = datetime.datetime(1, 1, 1, tzinfo=pytz.timezone('UTC'))
28 dashboard_data = list(reversed(sorted(
29- dashboard_data, key=lambda k: k.get('en', None))))
30+ dashboard_data, key=lambda k: k.get('en', notime))))
31 return dashboard_data
32
33

Subscribers

People subscribed via source and target branches