Commit b71d7cf4 authored by Michal Čihař's avatar Michal Čihař

Initial read only zen mode

Preparing support for zen mode, right now it's simple read only listing
of strings.

Issue #375
parent 16a5dd48
......@@ -670,3 +670,37 @@ def comment(request, pk):
messages.error(request, _('Failed to add comment!'))
return redirect(request.POST.get('next', translation))
def zen(request, project, subproject, lang):
'''
Generic entry point for translating, suggesting and searching.
'''
translation = get_translation(request, project, subproject, lang)
# Check locks
project_locked, user_locked, own_lock = translation.is_locked(
request, True
)
locked = project_locked or user_locked
# Search results
search_result = search(translation, request)
# Handle redirects
if isinstance(search_result, HttpResponse):
return search_result
return render_to_response(
'zen.html',
RequestContext(
request,
{
'translation': translation,
'units': translation.unit_set.filter(pk__in=search_result['ids']),
'search_query': search_result['query'],
'filter_name': search_result['name'],
'filter_count': len(search_result['ids']),
}
)
)
{% extends "base.html" %}
{% load url from future %}
{% load i18n %}
{% load static %}
{% load translations %}
{% block extra_meta %}
<link rel="canonical" href="{{ unit.get_absolute_url }}" />
{% endblock %}
{% block breadcrumbs %}
<li><a href="{{ translation.subproject.project.get_absolute_url }}">{{ translation.subproject.project }}</a></li>
<li><a href="{{ translation.subproject.get_absolute_url }}">{{ translation.subproject.name }}</a></li>
<li><a href="{{ translation.get_absolute_url }}">{{ translation.language }}</a></li>
<li><a href="{{ translation.get_translate_url }}">{% trans "zen" %}</a></li>
{% endblock %}
{% block content %}
{% with translation as object %}
{% include "show-lock.html" %}
{% endwith %}
<h2>{% trans "Translate" %}</h2>
{% if filter_name %}
<span class="navi-toolbar ui-widget-header ui-corner-all">
{% blocktrans %}Current filter: {{ filter_name }} ({{ filter_count }}){% endblocktrans %}
</span>
{% endif %}
<table class="zen">
{% for unit in units %}
<tr>
<td class="translatetext">{{ unit.source|fmtsearchmatch:search_query }}</td>
</tr>
{% endfor %}
</table>
{% endblock %}
......@@ -144,6 +144,11 @@ urlpatterns = patterns(
'trans.views.edit.translate',
name='translate',
),
url(
r'^projects/' + TRANSLATION + 'zen/$',
'trans.views.edit.zen',
name='zen',
),
url(
r'^projects/' + TRANSLATION + 'download/$',
'trans.views.files.download_translation',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment