зеркало из https://github.com/mozilla/kitsune.git
Implemented locale selection page [bug 606533]
This commit is contained in:
Родитель
2168a9aed8
Коммит
a7a25f8e04
|
@ -37,7 +37,7 @@
|
|||
<span>{{ _('Localize Article') }}</span>
|
||||
{% else %}
|
||||
{# TODO: Create page to select localization? Show link to all authenticated? #}
|
||||
<a href="#">{{ _('Localize Article') }}</a>
|
||||
<a href="{{ url('wiki.select_locale', document.slug) }}">{{ _('Localize Article') }}</a>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endif %}
|
||||
|
|
|
@ -0,0 +1,28 @@
|
|||
{# vim: set ts=2 et sts=2 sw=2: #}
|
||||
{% extends "wiki/base.html" %}
|
||||
{% from "wiki/includes/sidebar_modules.html" import document_tabs %}
|
||||
{% set title = _('Select Locale | {document}')|f(document=document.title) %}
|
||||
{% set crumbs = [(url('wiki.category', document.category), document.get_category_display()),
|
||||
(document.get_absolute_url(), document.title),
|
||||
(None, _('Select Locale'))] %}
|
||||
|
||||
{% block content %}
|
||||
<article id="select-locale" class="main">
|
||||
<div id="breadcrumbs">
|
||||
{{ _('You are here:') }}
|
||||
{{ breadcrumbs(crumbs) }}
|
||||
</div>
|
||||
<h1>{{ _('Select a locale to translate to:') }}</h1>
|
||||
<ul class="locales">
|
||||
{% for locale in settings.LANGUAGE_CHOICES %}
|
||||
{% if locale[0] != settings.WIKI_DEFAULT_LANGUAGE %}
|
||||
<li><a href="{{ url('wiki.translate', locale=locale[0], document_slug=document.slug) }}">{{ locale[1] }} ({{ locale[0] }})</a></li>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</article>
|
||||
{% endblock %}
|
||||
|
||||
{% block side %}
|
||||
{{ document_tabs(document, document.parent, user, 'localize', settings) }}
|
||||
{% endblock %}
|
|
@ -966,6 +966,24 @@ class HelpfulVoteTests(TestCaseBase):
|
|||
assert votes[0].helpful
|
||||
|
||||
|
||||
class SelectLocaleTests(TestCaseBase):
|
||||
"""Test the locale selection page"""
|
||||
fixtures = ['users.json']
|
||||
|
||||
def setUp(self):
|
||||
super(SelectLocaleTests, self).setUp()
|
||||
self.d = _create_document()
|
||||
self.client.login(username='admin', password='testpass')
|
||||
|
||||
def test_page_renders_locales(self):
|
||||
"""Load the page and verify it contains all the locales for l10n."""
|
||||
response = get(self.client, 'wiki.select_locale', args=[self.d.slug])
|
||||
eq_(200, response.status_code)
|
||||
doc = pq(response.content)
|
||||
eq_(len(settings.LANGUAGE_CHOICES) - 1, # All except for 1 (en-US)
|
||||
len(doc('#select-locale ul.locales li')))
|
||||
|
||||
|
||||
# TODO: Merge with wiki.tests.doc_rev()?
|
||||
def _create_document(title='Test Document', parent=None,
|
||||
locale=settings.WIKI_DEFAULT_LANGUAGE):
|
||||
|
|
|
@ -43,6 +43,7 @@ document_patterns = patterns('wiki.views',
|
|||
name='wiki.review_revision'),
|
||||
url(r'^/compare$', 'compare_revisions', name='wiki.compare_revisions'),
|
||||
url(r'^/translate$', 'translate', name='wiki.translate'),
|
||||
url(r'^/locales$', 'select_locale', name='wiki.select_locale'),
|
||||
|
||||
# Un/Subscribe to document edit notifications.
|
||||
url(r'^/watch$', 'watch_document', name='wiki.document_watch'),
|
||||
|
|
|
@ -316,6 +316,14 @@ def compare_revisions(request, document_slug):
|
|||
'revision_to': revision_to})
|
||||
|
||||
|
||||
@login_required
|
||||
def select_locale(request, document_slug):
|
||||
"""Select a locale to translate the document to."""
|
||||
doc = get_object_or_404(
|
||||
Document, locale=settings.WIKI_DEFAULT_LANGUAGE, slug=document_slug)
|
||||
return jingo.render(request, 'wiki/select_locale.html', {'document': doc})
|
||||
|
||||
|
||||
@require_http_methods(['GET', 'POST'])
|
||||
@login_required
|
||||
def translate(request, document_slug):
|
||||
|
|
|
@ -1340,6 +1340,12 @@ td.diff_header {
|
|||
width: 300px;
|
||||
}
|
||||
|
||||
/* Select locale for l10n page */
|
||||
#select-locale ul.locales {
|
||||
font-size: 14px;
|
||||
margin: 15px;
|
||||
}
|
||||
|
||||
|
||||
/* Graceful fallback for <details> tags */
|
||||
/* from http://mathiasbynens.be/notes/html5-details-jquery */
|
||||
|
|
Загрузка…
Ссылка в новой задаче