mirror of
https://github.com/Hopiu/django-rosetta.git
synced 2026-05-01 10:24:43 +00:00
Actually move to the next block when submitting a lot of translations (Issue #13) - Thanks @fetzig for the patch
This commit is contained in:
parent
11439587a3
commit
49b4c3e964
3 changed files with 21 additions and 11 deletions
1
CHANGES
1
CHANGES
|
|
@ -1,3 +1,4 @@
|
|||
* Actually move to the next block when submitting a lot of translations (Issue #13)
|
||||
* Add msgctxt to the entry hash to differentiate entries with context. Thanks @metalpriest (Issue #39)
|
||||
|
||||
Version 0.6.8
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ class RosettaTestCase(TestCase):
|
|||
self.assertTrue('String 1' in r.content)
|
||||
self.assertTrue('String 1' in r2.content)
|
||||
self.assertTrue('m_08e4e11e2243d764fc45a5a4fba5d0f2' in r.content)
|
||||
r = self.client.post(reverse('rosetta-home'), dict(m_08e4e11e2243d764fc45a5a4fba5d0f2='Hello, world', _next='_next'))
|
||||
r = self.client.post(reverse('rosetta-home'), dict(m_08e4e11e2243d764fc45a5a4fba5d0f2='Hello, world', _next='_next'), follow=True)
|
||||
r2 = self.client2.get(reverse('rosetta-home'))
|
||||
|
||||
# Client 2 reloads the home, forces a reload of the catalog,
|
||||
|
|
@ -220,14 +220,19 @@ class RosettaTestCase(TestCase):
|
|||
self.assertTrue('String 2' in r.content and 'm_e48f149a8b2e8baa81b816c0edf93890' in r.content)
|
||||
|
||||
# client 2 posts!
|
||||
r2 = self.client2.post(reverse('rosetta-home'), dict(m_e48f149a8b2e8baa81b816c0edf93890='Hello, world, from client two!', _next='_next'))
|
||||
r2 = self.client2.post(reverse('rosetta-home'), dict(m_e48f149a8b2e8baa81b816c0edf93890='Hello, world, from client two!', _next='_next'), follow=True)
|
||||
|
||||
self.assertTrue('save-conflict' not in r2.content)
|
||||
|
||||
# uh-oh here comes client 1
|
||||
r = self.client.post(reverse('rosetta-home'), dict(m_e48f149a8b2e8baa81b816c0edf93890='Hello, world, from client one!', _next='_next'))
|
||||
r = self.client.post(reverse('rosetta-home'), dict(m_e48f149a8b2e8baa81b816c0edf93890='Hello, world, from client one!', _next='_next'), follow=True)
|
||||
# An error message is displayed
|
||||
self.assertTrue('save-conflict' in r.content)
|
||||
|
||||
# client 2 won
|
||||
pofile_content = open(self.dest_file, 'r').read()
|
||||
self.assertTrue('Hello, world, from client two!' in pofile_content)
|
||||
|
||||
# Both clients show all strings, error messages are gone
|
||||
r = self.client.get(reverse('rosetta-home') + '?filter=translated')
|
||||
self.assertTrue('save-conflict' not in r.content)
|
||||
|
|
|
|||
|
|
@ -172,15 +172,11 @@ def home(request):
|
|||
storage.set('rosetta_i18n_pofile', rosetta_i18n_pofile)
|
||||
|
||||
# Retain query arguments
|
||||
query_arg = ''
|
||||
if 'query' in request.REQUEST:
|
||||
query_arg = '?query=%s' % request.REQUEST.get('query')
|
||||
query_arg = '?_next=1'
|
||||
if 'query' in request.GET or 'query' in request.POST:
|
||||
query_arg += '&query=%s' % request.REQUEST.get('query')
|
||||
if 'page' in request.GET:
|
||||
if query_arg:
|
||||
query_arg = query_arg + '&'
|
||||
else:
|
||||
query_arg = '?'
|
||||
query_arg = query_arg + 'page=%d' % int(request.GET.get('page'))
|
||||
query_arg += '&page=%d&_next=1' % int(request.GET.get('page'))
|
||||
return HttpResponseRedirect(reverse('rosetta-home') + iri_to_uri(query_arg))
|
||||
rosetta_i18n_lang_name = _(storage.get('rosetta_i18n_lang_name'))
|
||||
rosetta_i18n_lang_code = storage.get('rosetta_i18n_lang_code')
|
||||
|
|
@ -203,6 +199,14 @@ def home(request):
|
|||
page = int(request.GET.get('page'))
|
||||
else:
|
||||
page = 1
|
||||
|
||||
if '_next' in request.GET or '_next' in request.POST:
|
||||
page += 1
|
||||
if page > paginator.num_pages:
|
||||
page = 1
|
||||
query_arg = '?page=%d' % page
|
||||
return HttpResponseRedirect(reverse('rosetta-home') + iri_to_uri(query_arg))
|
||||
|
||||
rosetta_messages = paginator.page(page).object_list
|
||||
if rosetta_settings.MAIN_LANGUAGE and rosetta_settings.MAIN_LANGUAGE != rosetta_i18n_lang_code:
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue