Skip to content

Commit

Permalink
Add page counts to doc.json. Fixes #1936. Commit ready for merge.
Browse files Browse the repository at this point in the history
 - Legacy-Id: 11122
  • Loading branch information
rjsparks committed Apr 15, 2016
1 parent eda3f8f commit f8a2807
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions ietf/doc/tests.py
Expand Up @@ -696,6 +696,9 @@ def test_document_json(self):

r = self.client.get(urlreverse("ietf.doc.views_doc.document_json", kwargs=dict(name=doc.name)))
self.assertEqual(r.status_code, 200)
data = json.loads(r.content)
self.assertEqual(doc.name, data['name'])
self.assertEqual(doc.pages,data['pages'])

def test_writeup(self):
doc = make_test_data()
Expand Down
4 changes: 4 additions & 0 deletions ietf/doc/utils.py
Expand Up @@ -582,6 +582,8 @@ def get_ancestors(doc):
'published': e.time.isoformat(),
'url': url,
}
if d.history_set.filter(rev=e.newrevisiondocevent.rev).exists():
history[url]['pages'] = d.history_set.filter(rev=e.newrevisiondocevent.rev).first().pages

if doc.type_id == "draft":
e = doc.latest_event(type='published_rfc')
Expand All @@ -595,5 +597,7 @@ def get_ancestors(doc):
'published': e.time.isoformat(),
'url': url
}
if doc.history_set.filter(rev=e.newrevisiondocevent.rev).exists():
history[url]['pages'] = doc.history_set.filter(rev=e.newrevisiondocevent.rev).first().pages
history = history.values()
return sorted(history, key=lambda x: x['published'])
1 change: 1 addition & 0 deletions ietf/doc/views_doc.py
Expand Up @@ -908,6 +908,7 @@ def extract_name(s):

data["name"] = doc.name
data["rev"] = doc.rev
data["pages"] = doc.pages
data["time"] = doc.time.strftime("%Y-%m-%d %H:%M:%S")
data["group"] = None
if doc.group:
Expand Down

0 comments on commit f8a2807

Please sign in to comment.