Skip to content
This repository
  • 4 commits
  • 4 files changed
  • 0 comments
  • 3 contributors
2  apps/wiki/kumascript.py
@@ -121,6 +121,8 @@ def get(document, cache_control, base_url, timeout=None):
121 121 # http://developer.mindtouch.com/en/docs/DekiScript/Reference/
122 122 # Wiki_Functions_and_Variables
123 123 path = document.get_absolute_url()
  124 + # TODO: Someday merge with _get_document_for_json in views.py
  125 + # where most of this is duplicated code.
124 126 env_vars = dict(
125 127 path=path,
126 128 url=urljoin(base_url, path),
19 apps/wiki/tests/test_views.py
@@ -149,6 +149,13 @@ class ViewTests(TestCaseBase):
149 149 fixtures = ['test_users.json', 'wiki/documents.json']
150 150
151 151 def test_json_view(self):
  152 + expected_tags = sorted(['foo', 'bar', 'baz'])
  153 + expected_review_tags = sorted(['tech', 'editorial'])
  154 +
  155 + doc = Document.objects.get(pk=1)
  156 + doc.tags.set(*expected_tags)
  157 + doc.current_revision.review_tags.set(*expected_review_tags)
  158 +
152 159 url = reverse('wiki.json', locale=settings.WIKI_DEFAULT_LANGUAGE)
153 160
154 161 resp = self.client.get(url, {'title': 'an article title'})
@@ -156,6 +163,12 @@ def test_json_view(self):
156 163 data = json.loads(resp.content)
157 164 eq_('article-title', data['slug'])
158 165
  166 + result_tags = sorted([str(x) for x in data['tags']])
  167 + eq_(expected_tags, result_tags)
  168 +
  169 + result_review_tags = sorted([str(x) for x in data['review_tags']])
  170 + eq_(expected_review_tags, result_review_tags)
  171 +
159 172 url = reverse('wiki.json_slug', args=('article-title',),
160 173 locale=settings.WIKI_DEFAULT_LANGUAGE)
161 174 resp = self.client.get(url)
@@ -166,6 +179,12 @@ def test_json_view(self):
166 179 eq_('an article title', data['title'])
167 180 ok_('translations' in data)
168 181
  182 + result_tags = sorted([str(x) for x in data['tags']])
  183 + eq_(expected_tags, result_tags)
  184 +
  185 + result_review_tags = sorted([str(x) for x in data['review_tags']])
  186 + eq_(expected_review_tags, result_review_tags)
  187 +
169 188 def test_history_view(self):
170 189 slug = 'history-view-test-doc'
171 190 html = 'history view test doc'
9 apps/wiki/views.py
@@ -280,6 +280,7 @@ def _join_slug(parent_split, slug):
280 280 return '/'.join(parent_split)
281 281
282 282
  283 +# TODO: Maybe refactor this into a .to_json() method on the Document model?
283 284 def _get_document_for_json(doc, addLocaleToTitle=False):
284 285 """Returns a document in object format for output as JSON"""
285 286 content = (wiki.content.parse(doc.html)
@@ -305,12 +306,20 @@ def _get_document_for_json(doc, addLocaleToTitle=False):
305 306 locale=translation.locale)
306 307 })
307 308
  309 + if not doc.current_revision:
  310 + review_tags = []
  311 + else:
  312 + review_tags = [x.name for x in
  313 + doc.current_revision.review_tags.all()]
  314 +
308 315 return {
309 316 'title': title,
310 317 'label': doc.title,
311 318 'url': doc.get_absolute_url(),
312 319 'id': doc.id,
313 320 'slug': doc.slug,
  321 + 'tags': [x.name for x in doc.tags.all()],
  322 + 'review_tags': review_tags,
314 323 'sections': wiki.content.get_content_sections(content),
315 324 'locale': doc.locale,
316 325 'summary': summary,
2  media/css/wiki-screen.css
@@ -553,7 +553,7 @@ td.diff_header {
553 553
554 554 /* Prism syntax highlighting */
555 555 pre[class*="language-"] { line-height: 1.5em; margin-bottom: 20px !important; }
556   -pre[class*="language-"] span.comment { display: inline-block; }
  556 +pre[class*="language-"] span.comment { display: inherit; }
557 557 .error pre[class*="language-"] { margin: 10px 0 0 0 !important; background: none; }
558 558 pre[class*="language-"].twopartsyntaxbox { margin-bottom: 0 !important; }
559 559 pre[class*="language-"].twopartsyntaxbox, pre[class*="language-"].syntaxbox {

No commit comments for this range

Something went wrong with that request. Please try again.