Commit 172cd60b authored by Michal Čihař's avatar Michal Čihař

Replace accordion with tabs and load Git info using AJAX

parent 9c3b7d85
{% 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 %}
......@@ -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 %}
......
......@@ -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 %}
......
......@@ -216,4 +216,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>");
}
},
});
});
......@@ -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
......@@ -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