Skip to content

Commit

Permalink
[bug 790802] Add comments of recent updates to translate page.
Browse files Browse the repository at this point in the history
  • Loading branch information
rlr committed Oct 10, 2012
1 parent 74fb8e7 commit 17cabe5
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
4 changes: 4 additions & 0 deletions apps/wiki/templates/wiki/revision.html
Expand Up @@ -29,6 +29,10 @@ <h1 class="title">{{ document.title }}</h1>
<strong>{{ _('Creator:') }}</strong>
<span>{{ revision.creator }}</span>
</li>
<li>
<strong>{{ _('Comment:') }}</strong>
<span>{{ revision.comment }}</span>
</li>
<li>
<strong>{{ _('Reviewed:') }}</strong>
<span>{{ revision.reviewed|yesno }}</span>
Expand Down
19 changes: 16 additions & 3 deletions apps/wiki/templates/wiki/translate.html
Expand Up @@ -85,10 +85,24 @@ <h3><label for="{{ document_form.slug.auto_id }}" title="{{ document_form.slug.h
{{ csrf() }}
<input type="hidden" name="form" value="rev" />
{% endif %}
{% if recent_approved_revs %}
<h3>{{ _('Recently approved updates') }}:</h3>
<ul class="recent-revisions">
{% for rev in recent_approved_revs %}
<li>
<a href="{{ url('wiki.revision', parent.slug, rev.id, locale=parent.locale) }}" rel="nofollow, noindex">{{ datetimeformat(rev.created, format='date') }}</a>:
[<a href="{{ profile_url(rev.creator) }}">{{ rev.creator }}</a>]
{{ rev.comment }}
</li>
{% endfor %}
</ul>
{% endif %}

<h3>{{ _('Differences') }}:</h3>
<ul class="description">
<li>
<div class="approved">
<h3>{{ _('Keywords:') }}</h3>
<h3><label>{{ _('Keywords:') }}</label></h3>
<div class="val">{{ based_on.keywords }}</div>
</div>
<div class="localized">
Expand All @@ -98,7 +112,7 @@ <h3><label for="{{ revision_form.keywords.auto_id }}" title="{{ revision_form.ke
</li>
<li>
<div class="approved">
<h3>{{ _('Search result summary:') }}</h3>
<h3><label>{{ _('Search result summary:') }}</label></h3>
<div class="val">{{ based_on.summary }}</div>
</div>
<div class="localized">
Expand All @@ -117,7 +131,6 @@ <h3><label for="{{ revision_form.summary.auto_id }}" title="{{ revision_form.sum
<p>{{ _('Note: There are no approved translations for this article.') }}</p>
{% endif %}
<div id="content-fields">
<ul>
<div class="approved">
<h3>{{ _('Approved {default_locale} version:')|f(default_locale=settings.LANGUAGES[settings.WIKI_DEFAULT_LANGUAGE.lower()]) }}</h3>
<textarea readonly="readonly">{{ based_on.content }}</textarea>
Expand Down
7 changes: 4 additions & 3 deletions apps/wiki/tests/test_templates.py
Expand Up @@ -354,11 +354,11 @@ def test_revision_view(self):
eq_('Created:\n Jan 1, 2011 12:00:00 AM',
doc('.revision-info li')[1].text_content().strip())
eq_('Reviewed:\n Jan 2, 2011 12:00:00 AM',
doc('.revision-info li')[5].text_content().strip())
doc('.revision-info li')[6].text_content().strip())
# is reviewed?
eq_('Yes', doc('.revision-info li').eq(3).find('span').text())
eq_('Yes', doc('.revision-info li').eq(4).find('span').text())
# is current revision?
eq_('Yes', doc('.revision-info li').eq(7).find('span').text())
eq_('Yes', doc('.revision-info li').eq(8).find('span').text())

@mock.patch.object(ReadyRevisionEvent, 'fire')
def test_mark_as_ready_POST(self, fire):
Expand Down Expand Up @@ -1595,6 +1595,7 @@ def test_another_translation_to_locale(self, get_current, edited_fire,
doc = pq(response.content)
eq_(rev_es.content, doc('#id_content').text())
eq_(rev_enUS.content, doc('#content-fields textarea[readonly]').text())
eq_(2, len(doc('.recent-revisions li')))

# Post the translation and verify
data = _translation_data()
Expand Down
11 changes: 10 additions & 1 deletion apps/wiki/views.py
Expand Up @@ -602,12 +602,21 @@ def translate(request, document_slug, revision_id=None):

show_revision_warning = _show_revision_warning(doc, base_rev)

# A list of the revisions that have been approved since the last
# translation.
recent_approved_revs = parent_doc.revisions.filter(
is_approved=True, id__lte=based_on_rev.id)
if doc and doc.current_revision and doc.current_revision.based_on_id:
recent_approved_revs = recent_approved_revs.filter(
id__gt=doc.current_revision.based_on_id)

return jingo.render(request, 'wiki/translate.html',
{'parent': parent_doc, 'document': doc,
'document_form': doc_form, 'revision_form': rev_form,
'locale': request.locale, 'based_on': based_on_rev,
'disclose_description': disclose_description,
'show_revision_warning': show_revision_warning})
'show_revision_warning': show_revision_warning,
'recent_approved_revs': recent_approved_revs})


@require_POST
Expand Down
9 changes: 9 additions & 0 deletions media/less/wiki.less
Expand Up @@ -807,6 +807,15 @@ textarea[name="content"] {
}

/* Translate specific */

.translate {
.recent-revisions {
li {
margin: 10px 0;
padding: 0;
}
}
}
ul.description {
li {
list-style: none;
Expand Down

0 comments on commit 17cabe5

Please sign in to comment.