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):
suggestions = [sug.pk for sug in unit.suggestions()]
# Delete one of suggestions
self.client.get(
self.client.post(
self.translate_url,
{'delete': suggestions[0]},
)
......@@ -368,7 +368,7 @@ class EditTest(ViewTestCase):
self.assertFalse(unit.fuzzy)
# Accept one of suggestions
self.client.get(
self.client.post(
self.translate_url,
{'accept': suggestions[1]},
)
......
......@@ -387,14 +387,14 @@ def handle_suggestions(obj, request, this_unit_url):
return HttpResponseRedirect(this_unit_url)
# Parse suggestion ID
if 'accept' in request.GET:
if 'accept' in request.POST:
if not request.user.has_perm('trans.accept_suggestion'):
messages.error(
request,
_('You do not have privilege to accept suggestions!')
)
return HttpResponseRedirect(this_unit_url)
sugid = request.GET['accept']
sugid = request.POST['accept']
else:
if not request.user.has_perm('trans.delete_suggestion'):
messages.error(
......@@ -402,7 +402,7 @@ def handle_suggestions(obj, request, this_unit_url):
_('You do not have privilege to delete suggestions!')
)
return HttpResponseRedirect(this_unit_url)
sugid = request.GET['delete']
sugid = request.POST['delete']
try:
sugid = int(sugid)
suggestion = Suggestion.objects.get(pk=sugid)
......@@ -410,7 +410,7 @@ def handle_suggestions(obj, request, this_unit_url):
suggestion = None
if suggestion is not None:
if 'accept' in request.GET:
if 'accept' in request.POST:
# Accept suggesion
suggestion.accept(obj, request)
else:
......@@ -469,6 +469,12 @@ def translate(request, project, subproject, lang):
# Any form submitted?
if request.method == 'POST' and not project_locked:
# 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
)
......@@ -481,10 +487,6 @@ def translate(request, project, subproject, lang):
elif 'revert' in request.GET and not locked:
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
if response is not None:
return response
......
......@@ -121,10 +121,10 @@
{% if perms.trans.accept_suggestion or perms.trans.delete_suggestion %}
<div class="menu-float action-buttons">
{% 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 %}
{% 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 %}
</div>
{% endif %}
......
......@@ -75,7 +75,7 @@ nav li {
width: 4em;
text-align: center;
}
.action-buttons a {
.action-buttons button {
width: 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