Stub for upload processing

This commit is contained in:
Michal Čihař 2012-03-04 09:37:22 +01:00
parent 2190de58bd
commit e13b6929b4
3 changed files with 24 additions and 1 deletions

View File

@ -26,6 +26,15 @@
<a href="{{ object.get_download_url }}">{% trans "Download" %}</a>
{% if user.is_authenticated %}
<form action="{% url 'trans.views.upload_translation' %}" method="post">
<table>
{{ form.as_table }}
<tr><td></td><td><input type="submit" value="{% trans "Upload" %}" /></td></tr>
</table>
</form>
{% endif %}
{% endblock %}

View File

@ -7,7 +7,7 @@ from django.http import HttpResponse, HttpResponseRedirect
from django.contrib import messages
from trans.models import Project, SubProject, Translation, Unit, Suggestion
from trans.forms import TranslationForm
from trans.forms import TranslationForm, UploadForm
from util import is_plural, split_plural, join_plural
import logging
import os.path
@ -40,10 +40,12 @@ def show_subproject(request, project, subproject):
def show_translation(request, project, subproject, lang):
obj = get_object_or_404(Translation, language__code = lang, subproject__slug = subproject, subproject__project__slug = project)
form = UploadForm()
return render_to_response('translation.html', RequestContext(request, {
'object': obj,
'title': '%s @ %s' % (obj.__unicode__(), settings.SITE_TITLE),
'form': form,
}))
def download_translation(request, project, subproject, lang):
@ -171,3 +173,14 @@ def get_string(request, checksum):
return HttpResponse('')
return HttpResponse(units[0].get_source_plurals()[0])
def upload_translation(request, project, subproject, lang):
obj = get_object_or_404(Translation, language__code = lang, subproject__slug = subproject, subproject__project__slug = project)
if request.method == 'POST':
form = UploadForm(request.POST)
if form.is_valid():
# FIXME: process upload
messages.add_message(request, messages.INFO, _('File content successfully merged into translation.'))
return HttpResponseRedirect(obj.get_absolute_url())

View File

@ -9,6 +9,7 @@ urlpatterns = patterns('',
url(r'^projects/(?P<project>[^/]*)/(?P<subproject>[^/]*)/(?P<lang>[^/]*)/$', 'trans.views.show_translation'),
url(r'^projects/(?P<project>[^/]*)/(?P<subproject>[^/]*)/(?P<lang>[^/]*)/translate/$', 'trans.views.translate'),
url(r'^projects/(?P<project>[^/]*)/(?P<subproject>[^/]*)/(?P<lang>[^/]*)/download/$', 'trans.views.download_translation'),
url(r'^projects/(?P<project>[^/]*)/(?P<subproject>[^/]*)/(?P<lang>[^/]*)/upload/$', 'trans.views.upload_translation'),
url(r'^js/get/(?P<checksum>[^/]*)/$', 'trans.views.get_string'),