Commit d4406bd1 authored by Weblate's avatar Weblate

Merge remote-tracking branch 'origin/master'

parents d3edc531 9a8e583d
......@@ -185,7 +185,7 @@
{% if not unit.only_vote_suggestions or perms.trans.override_suggestion %}
{% if perms.trans.accept_suggestion %}
<button type="submit" class="btn btn-success btn-xs" name="accept" value="{{ suggestion.id }}"><i class="fa fa-check"></i> {% trans "Accept" %}</button>
<button type="submit" class="btn btn-warning btn-xs" name="accept-edit" value="{{ suggestion.id }}"><i class="fa fa-pencil"></i> {% trans "Accept and edit" %}</button>
<button type="submit" class="btn btn-warning btn-xs" name="accept_edit" value="{{ suggestion.id }}"><i class="fa fa-pencil"></i> {% trans "Accept and edit" %}</button>
{% endif %}
{% if perms.trans.delete_suggestion %}
<button type="submit" class="btn btn-danger btn-xs" name="delete" value="{{ suggestion.id }}"><i class="fa fa-trash"></i> {% trans "Delete" %}</button>
......@@ -292,7 +292,7 @@
{% if perms.trans.add_comment %}
<form method="post" action="{% url 'comment' pk=unit.id %}">
{% csrf_token %}
<input type="hidden" name="next" value="{{ this_unit_url }}" />
<input type="hidden" name="next" value="{{ this_unit_url }}#comments" />
<div class="panel panel-primary">
<div class="panel-heading"><h4 class="panel-title">{% trans "New comment" %}</h4></div>
<div class="panel-body">
......
......@@ -110,6 +110,22 @@ class SuggestionsTest(ViewTestCase):
self.assertFalse(unit.fuzzy)
self.assertEqual(len(self.get_unit().suggestions()), 1)
def test_accept_edit(self):
translate_url = self.get_translation().get_translate_url()
# Create suggestion
self.add_suggestion_1()
# Get ids of created suggestions
suggestion = self.get_unit().suggestions()[0].pk
# Accept one of suggestions
response = self.edit_unit(
'Hello, world!\n',
'',
accept_edit=suggestion,
)
self.assertRedirectsOffset(response, translate_url, 0)
def test_accept(self):
translate_url = self.get_translation().get_translate_url()
# Create two suggestions
......@@ -164,7 +180,7 @@ class SuggestionsTest(ViewTestCase):
'',
accept=suggestions[0].pk,
)
self.assertRedirectsOffset(response, translate_url, 0)
self.assertRedirectsOffset(response, translate_url, 1)
# Reload from database
unit = self.get_unit()
......
......@@ -407,7 +407,7 @@ def handle_suggestions(translation, request, this_unit_url, next_unit_url):
Handles suggestion deleting/accepting.
'''
sugid = ''
params = ('accept', 'accept-edit', 'delete', 'upvote', 'downvote')
params = ('accept', 'accept_edit', 'delete', 'upvote', 'downvote')
redirect_url = this_unit_url
# Parse suggestion ID
......@@ -420,7 +420,7 @@ def handle_suggestions(translation, request, this_unit_url, next_unit_url):
sugid = int(sugid)
suggestion = Suggestion.objects.get(pk=sugid)
if 'accept' in request.POST or 'accept-edit' in request.POST:
if 'accept' in request.POST or 'accept_edit' in request.POST:
# Accept suggesion
if not request.user.has_perm('trans.accept_suggestion'):
messages.error(
......@@ -514,7 +514,7 @@ def translate(request, project, subproject, lang):
# Handle accepting/deleting suggestions
if ('accept' not in request.POST and
'accept-edit' not in request.POST and
'accept_edit' not in request.POST and
'delete' not in request.POST and
'upvote' not in request.POST and
'downvote' not in request.POST):
......
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