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

Merge remote-tracking branch 'origin/master'

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