Commit 27379a2b authored by Michal Čihař's avatar Michal Čihař

Merge remote-tracking branch 'origin/master'

parents c7958129 ae79fede
{% load i18n %}
{% if perms.trans.commit_translation or perms.trans.update_translation %}
<h3><a href="#">{% trans "Git maintenance" %}</a></h3>
<div>
{% with object.git_needs_commit as needs_commit %}
{% if needs_commit %}
<p>{% trans "There are some not commited changes!" %}</p>
......@@ -21,5 +19,4 @@
{% if perms.trans.update_translation %}
<li><a href="{{ object.get_update_url }}">{% trans "Pull changes from remote repository" %}</a></li>
{% endif %}
</div>
{% endif %}
......@@ -16,22 +16,24 @@
<form method="post" action="{% url 'accounts.views.profile' %}">
{% csrf_token %}
<div class="accordion">
<h2><a href="#">{% trans "Preferences" %}</a></h2>
<div>
<div class="tabs" id="tabs-preferences">
<ul>
<li><a href="#preferences">{% trans "Preferences" %}</a></li>
<li><a href="#account">{% trans "Account" %}</a></li>
<li><a href="#password">{% trans "Password" %}</a></li>
</ul>
<div id="preferences">
<table>
{{ form.as_table }}
</table>
</div>
<h2><a href="#">{% trans "Account" %}</a></h2>
<div>
<div id="account">
<table>
{{ userform.as_table }}
</table>
<span class="helptext">{% trans "Your name and email will appear as author on Git commits." %}</span>
</div>
<h2><a href="#">{% trans "Password" %}</a></h2>
<div>
<div id="password">
{% url 'django.contrib.auth.views.password_change' as pw_url %}
{% blocktrans %}You can change password on <a href="{{ pw_url }}">separate page</a>.{% endblocktrans %}
</div>
......
......@@ -35,9 +35,15 @@
<h2>{% trans "Tools" %}</h2>
<div class="accordion">
<h3><a href="#">{% trans "Dictionaries" %}</a></h3>
<div>
<div class="tabs" id="project-tabs">
<ul>
<li><a href="#dicts">{% trans "Dictionaries" %}</a></li>
{% if perms.trans.commit_translation or perms.trans.update_translation %}
<li><a href="{% url 'trans.views.git_status_project' project=object.slug %}">{% trans "Git maintenance" %}</a></li>
{% endif %}
</ul>
<div id="dicts">
<ul>
{% for dict in dicts %}
<li><a href="{% url 'trans.views.show_dictionary' project=object.slug lang=dict.code %}">{{ dict }}</a></li>
......@@ -45,7 +51,6 @@
<li><a href="{% url 'trans.views.show_dictionaries' project=object.slug %}">{% trans "Manage all dictionaries" %}</a></li>
</ul>
</div>
{% include "git-tools.html" %}
</div>
{% endblock %}
......@@ -23,13 +23,18 @@
<h2>{% trans "Tools" %}</h2>
<div class="accordion">
<h3><a href="#">{% trans "New language" %}</a></h3>
<div>
<div class="tabs" id="subproject-tabs">
<ul>
<li><a href="#new-lang">{% trans "New language" %}</a></li>
{% if perms.trans.commit_translation or perms.trans.update_translation %}
<li><a href="{% url 'trans.views.git_status_subproject' project=object.project.slug subproject=object.slug %}">{% trans "Git maintenance" %}</a></li>
{% endif %}
</ul>
<div id="new-lang">
<p>{% blocktrans %}Should your language be missing, please <a href="{{ contact_url }}?subject=New+language+request+for+{{ object }}">contact us</a>.{% endblocktrans %}</li>
</div>
{% include "git-tools.html" %}
</div>
{% endblock %}
......
......@@ -150,7 +150,7 @@
<h2>{% trans "Translation context" %}</h2>
<div class="tabs">
<div class="translate-tabs">
<ul>
<li><a href="#tab-nearby" title="{% trans "Messages placed around this one" %}">{% trans "Nearby messages" %}</a></li>
<li><a href="/js/similar/{{ unit.id }}/" title="{% trans "Similar messages" %}">{% trans "Similar messages" %}</a></li>
......
......@@ -27,28 +27,36 @@
<h2>{% trans "Tools" %}</h2>
<div class="accordion">
<h2><a href="#">{% trans "Search" %}</a></h2>
<div class="tabs" id="translation-tabs">
<ul>
<li><a href="#search">{% trans "Search" %}</a></li>
<li><a href="#download">{% trans "Download" %}</a></li>
{% if perms.trans.upload_translation %}
<li><a href="#upload">{% trans "Upload" %}</a></li>
{% endif %}
{% if autoform %}
<li><a href="#auto">{% trans "Automatic translation" %}</a></li>
{% endif %}
{% if perms.trans.commit_translation or perms.trans.update_translation %}
<li><a href="{% url 'trans.views.git_status_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}">{% trans "Git maintenance" %}</a></li>
{% endif %}
</ul>
<div>
<div id="search">
<form action="{{ object.get_translate_url }}" method="GET">
{{ search_form.as_p }}
<input type="submit" value="{% trans "Search" %}" class="button" />
</form>
</div>
<h3><a href="#">{% trans "Download" %}</a></h3>
<div>
<div id="download">
{% with object.get_download_url as download_url %}
<p>{% blocktrans %}You can <a href="{{ download_url }}">download</a> file for offline translation.{% endblocktrans %}</p>
{% endwith %}
</div>
{% if perms.trans.upload_translation %}
<h3><a href="#">{% trans "Upload" %}</a></h3>
<div>
<div id="upload">
{% if perms.trans.overwrite_translation %}
<p>{% trans "Uploaded file will be merged with current translation. In case you want to overwrite already translated strings, don't forget to enable it." %}</p>
{% else %}
......@@ -66,8 +74,7 @@
{% endif %}
{% if autoform %}
<h3><a href="#">{% trans "Automatic translation" %}</a></h3>
<div>
<div id="auto">
<p>{% trans "Automatic translation takes existing translations in this project and applies it to current subproject. It can be used to push translations to different branch or to fix inconsistent translations." %}</p>
<form action="{% url 'trans.views.auto_translation' project=object.subproject.project.slug subproject=object.subproject.slug lang=object.language.code %}" method="post" enctype="multipart/form-data">
{% csrf_token %}
......@@ -78,8 +85,6 @@
</form>
</div>
{% endif %}
{% include "git-tools.html" %}
</div>
{% endblock %}
......
......@@ -120,7 +120,6 @@ $(function() {
$('ul.menu li a').button();
$('ul.breadcums').buttonset();
$('div.progress').each(function f(i, e) {e = $(e); e.progressbar({ value: parseInt(e.attr('id')) })});
$('.accordion').accordion();
$('.errorlist').addClass('ui-state-error ui-corner-all');
$('.sug-accept').button({text: false, icons: { primary: "ui-icon-check" }});
$('.sug-delete').button({text: false, icons: { primary: "ui-icon-close" }});
......@@ -190,7 +189,7 @@ $(function() {
});
});
$("div.tabs").tabs({
$("div.translate-tabs").tabs({
ajaxOptions: {
error: function(xhr, status, index, anchor) {
$(anchor.hash).html(gettext("AJAX request to load this content has failed!"));
......@@ -216,4 +215,27 @@ $(function() {
$('a.mergebutton').button({text: true, icons: { primary: "ui-icon-check" }});
}
});
$("div.tabs").tabs({
ajaxOptions: {
error: function(xhr, status, index, anchor) {
$(anchor.hash).html(gettext("AJAX request to load this content has failed!"));
}
},
cookie: {
expires: 31,
name: $(this).id,
path: '/'
},
cache: true,
load: function (e, ui) {
$(ui.panel).find(".tab-loading").remove();
},
show: function (e, ui) {
var $panel = $(ui.panel);
if ($panel.is(":empty")) {
$panel.append("<div class='tab-loading'>" + gettext("Loading...") + "</div>");
}
},
});
});
......@@ -679,7 +679,7 @@ class Translation(models.Model):
checks = Check.objects.all()
else:
checks = Check.objects.filter(check = check)
checks = checks.filter(project = self.subproject.project, language = self.language, ignore = False).values_list('checksum', flat = True).distinct()
checks = checks.filter(project = self.subproject.project, language = self.language, ignore = False).values_list('checksum', flat = True)
return self.unit_set.filter(checksum__in = checks, translated = True).count()
class Unit(models.Model):
......
......@@ -6,7 +6,7 @@ from django.utils.translation import ugettext_lazy, ugettext as _
from django.template import RequestContext, loader
from django.http import HttpResponse, HttpResponseRedirect, HttpResponseNotAllowed, HttpResponseNotFound, Http404
from django.contrib import messages
from django.contrib.auth.decorators import login_required, permission_required
from django.contrib.auth.decorators import login_required, permission_required, user_passes_test
from django.contrib.auth.models import AnonymousUser
from django.db.models import Q, Count
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
......@@ -82,7 +82,7 @@ def show_check_project(request, name, project):
langs = Check.objects.filter(check = name, project = prj, ignore = False).values_list('language', flat = True).distinct()
units = Unit.objects.none()
for lang in langs:
checks = Check.objects.filter(check = name, project = prj, language = lang, ignore = False).values_list('checksum', flat = True).distinct()
checks = Check.objects.filter(check = name, project = prj, language = lang, ignore = False).values_list('checksum', flat = True)
res = Unit.objects.filter(checksum__in = checks, translation__language = lang, translation__subproject__project = prj, translated = True).values('translation__subproject__slug', 'translation__subproject__project__slug').annotate(count = Count('id'))
units |= res
return render_to_response('check_project.html', RequestContext(request, {
......@@ -101,7 +101,7 @@ def show_check_subproject(request, name, project, subproject):
langs = Check.objects.filter(check = name, project = subprj.project, ignore = False).values_list('language', flat = True).distinct()
units = Unit.objects.none()
for lang in langs:
checks = Check.objects.filter(check = name, project = subprj.project, language = lang, ignore = False).values_list('checksum', flat = True).distinct()
checks = Check.objects.filter(check = name, project = subprj.project, language = lang, ignore = False).values_list('checksum', flat = True)
res = Unit.objects.filter(translation__subproject = subprj, checksum__in = checks, translation__language = lang, translated = True).values('translation__language__code').annotate(count = Count('id'))
units |= res
return render_to_response('check_subproject.html', RequestContext(request, {
......@@ -889,3 +889,27 @@ def about(request):
'django_version': django.get_version(),
'git_version': git.__version__,
}))
@user_passes_test(lambda u: u.has_perm('trans.commit_translation') or u.has_perm('trans.update_translation'))
def git_status_project(request, project):
obj = get_object_or_404(Project, slug = project)
return render_to_response('js/git-status.html', RequestContext(request, {
'object': obj,
}))
@user_passes_test(lambda u: u.has_perm('trans.commit_translation') or u.has_perm('trans.update_translation'))
def git_status_subproject(request, project, subproject):
obj = get_object_or_404(SubProject, slug = subproject, project__slug = project)
return render_to_response('js/git-status.html', RequestContext(request, {
'object': obj,
}))
@user_passes_test(lambda u: u.has_perm('trans.commit_translation') or u.has_perm('trans.update_translation'))
def git_status_translation(request, project, subproject, lang):
obj = get_object_or_404(Translation, language__code = lang, subproject__slug = subproject, subproject__project__slug = project)
return render_to_response('js/git-status.html', RequestContext(request, {
'object': obj,
}))
......@@ -64,6 +64,9 @@ urlpatterns = patterns('',
url(r'^js/similar/(?P<unit_id>[0-9]*)/$', 'trans.views.get_similar'),
url(r'^js/other/(?P<unit_id>[0-9]*)/$', 'trans.views.get_other'),
url(r'^js/dictionary/(?P<unit_id>[0-9]*)/$', 'trans.views.get_dictionary'),
url(r'^js/git/(?P<project>[^/]*)/$', 'trans.views.git_status_project'),
url(r'^js/git/(?P<project>[^/]*)/(?P<subproject>[^/]*)/$', 'trans.views.git_status_subproject'),
url(r'^js/git/(?P<project>[^/]*)/(?P<subproject>[^/]*)/(?P<lang>[^/]*)/$', 'trans.views.git_status_translation'),
# Admin interface
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
......
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