Commit 539d1f3e authored by Michal Čihař's avatar Michal Čihař

Suggestions are now manipulated using POST

Fixes #291
parent 86926d9c
...@@ -348,7 +348,7 @@ class EditTest(ViewTestCase): ...@@ -348,7 +348,7 @@ class EditTest(ViewTestCase):
suggestions = [sug.pk for sug in unit.suggestions()] suggestions = [sug.pk for sug in unit.suggestions()]
# Delete one of suggestions # Delete one of suggestions
self.client.get( self.client.post(
self.translate_url, self.translate_url,
{'delete': suggestions[0]}, {'delete': suggestions[0]},
) )
...@@ -368,7 +368,7 @@ class EditTest(ViewTestCase): ...@@ -368,7 +368,7 @@ class EditTest(ViewTestCase):
self.assertFalse(unit.fuzzy) self.assertFalse(unit.fuzzy)
# Accept one of suggestions # Accept one of suggestions
self.client.get( self.client.post(
self.translate_url, self.translate_url,
{'accept': suggestions[1]}, {'accept': suggestions[1]},
) )
......
...@@ -387,14 +387,14 @@ def handle_suggestions(obj, request, this_unit_url): ...@@ -387,14 +387,14 @@ def handle_suggestions(obj, request, this_unit_url):
return HttpResponseRedirect(this_unit_url) return HttpResponseRedirect(this_unit_url)
# Parse suggestion ID # Parse suggestion ID
if 'accept' in request.GET: if 'accept' in request.POST:
if not request.user.has_perm('trans.accept_suggestion'): if not request.user.has_perm('trans.accept_suggestion'):
messages.error( messages.error(
request, request,
_('You do not have privilege to accept suggestions!') _('You do not have privilege to accept suggestions!')
) )
return HttpResponseRedirect(this_unit_url) return HttpResponseRedirect(this_unit_url)
sugid = request.GET['accept'] sugid = request.POST['accept']
else: else:
if not request.user.has_perm('trans.delete_suggestion'): if not request.user.has_perm('trans.delete_suggestion'):
messages.error( messages.error(
...@@ -402,7 +402,7 @@ def handle_suggestions(obj, request, this_unit_url): ...@@ -402,7 +402,7 @@ def handle_suggestions(obj, request, this_unit_url):
_('You do not have privilege to delete suggestions!') _('You do not have privilege to delete suggestions!')
) )
return HttpResponseRedirect(this_unit_url) return HttpResponseRedirect(this_unit_url)
sugid = request.GET['delete'] sugid = request.POST['delete']
try: try:
sugid = int(sugid) sugid = int(sugid)
suggestion = Suggestion.objects.get(pk=sugid) suggestion = Suggestion.objects.get(pk=sugid)
...@@ -410,7 +410,7 @@ def handle_suggestions(obj, request, this_unit_url): ...@@ -410,7 +410,7 @@ def handle_suggestions(obj, request, this_unit_url):
suggestion = None suggestion = None
if suggestion is not None: if suggestion is not None:
if 'accept' in request.GET: if 'accept' in request.POST:
# Accept suggesion # Accept suggesion
suggestion.accept(obj, request) suggestion.accept(obj, request)
else: else:
...@@ -469,9 +469,15 @@ def translate(request, project, subproject, lang): ...@@ -469,9 +469,15 @@ def translate(request, project, subproject, lang):
# Any form submitted? # Any form submitted?
if request.method == 'POST' and not project_locked: if request.method == 'POST' and not project_locked:
response = handle_translate(
obj, request, user_locked, this_unit_url, next_unit_url # Handle accepting/deleting suggestions
) if 'accept' in request.POST or 'delete' in request.POST:
if not locked:
response = handle_suggestions(obj, request, this_unit_url)
else:
response = handle_translate(
obj, request, user_locked, this_unit_url, next_unit_url
)
# Handle translation merging # Handle translation merging
elif 'merge' in request.GET and not locked: elif 'merge' in request.GET and not locked:
...@@ -481,10 +487,6 @@ def translate(request, project, subproject, lang): ...@@ -481,10 +487,6 @@ def translate(request, project, subproject, lang):
elif 'revert' in request.GET and not locked: elif 'revert' in request.GET and not locked:
response = handle_revert(obj, request, this_unit_url) response = handle_revert(obj, request, this_unit_url)
# Handle accepting/deleting suggestions
elif not locked and ('accept' in request.GET or 'delete' in request.GET):
response = handle_suggestions(obj, request, this_unit_url)
# Pass possible redirect further # Pass possible redirect further
if response is not None: if response is not None:
return response return response
......
...@@ -121,10 +121,10 @@ ...@@ -121,10 +121,10 @@
{% if perms.trans.accept_suggestion or perms.trans.delete_suggestion %} {% if perms.trans.accept_suggestion or perms.trans.delete_suggestion %}
<div class="menu-float action-buttons"> <div class="menu-float action-buttons">
{% if perms.trans.accept_suggestion %} {% if perms.trans.accept_suggestion %}
<a href="{{ this_unit_url }}&amp;accept={{ suggestion.id }}" class="sug-accept">{% trans "Accept" %}</a> <button type="submit" class="sug-accept" name="accept" value="{{ suggestion.id }}">{% trans "Accept" %}</button>
{% endif %} {% endif %}
{% if perms.trans.delete_suggestion %} {% if perms.trans.delete_suggestion %}
<a href="{{ this_unit_url }}&amp;delete={{ suggestion.id }}" class="sug-delete">{% trans "Delete" %}</a> <button type="submit" class="sug-delete" name="delete" value="{{ suggestion.id }}">{% trans "Delete" %}</button>
{% endif %} {% endif %}
</div> </div>
{% endif %} {% endif %}
......
...@@ -75,7 +75,7 @@ nav li { ...@@ -75,7 +75,7 @@ nav li {
width: 4em; width: 4em;
text-align: center; text-align: center;
} }
.action-buttons a { .action-buttons button {
width: 20px; width: 20px;
height: 20px; height: 20px;
} }
......
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