diff --git a/weblate/templates/snippets/suggestions.html b/weblate/templates/snippets/suggestions.html index 15995aed813c..2b9fd772daf5 100644 --- a/weblate/templates/snippets/suggestions.html +++ b/weblate/templates/snippets/suggestions.html @@ -25,7 +25,7 @@ {% else %} {% perm 'suggestion.delete' suggestion as user_can_delete_suggestion %} {% if user_can_vote_suggestion or user_can_accept_suggestion or user_can_delete_suggestion %} -
+
{% if user_can_vote_suggestion %} diff --git a/weblate/templates/zen-units.html b/weblate/templates/zen-units.html index 880230d144eb..76b205164b22 100644 --- a/weblate/templates/zen-units.html +++ b/weblate/templates/zen-units.html @@ -89,6 +89,17 @@ {% endif %} {% crispy item.form %} + +{% perm 'suggestion.add' item.unit as user_can_suggest %} +{% perm 'suggestion.accept' item.unit as user_can_accept_suggestion %} +{% perm 'suggestion.vote' item.unit.translation as user_can_vote_suggestion %} + +
+ {% csrf_token %} + + + {% include "snippets/suggestions.html" with suggestions=item.unit.suggestions %} +
diff --git a/weblate/trans/views/edit.py b/weblate/trans/views/edit.py index 6f90efd284dc..f68946bc2229 100644 --- a/weblate/trans/views/edit.py +++ b/weblate/trans/views/edit.py @@ -893,6 +893,32 @@ def zen(request, path): search_result, unitdata = get_zen_unitdata(obj, project, unit_set, request) sort = get_sort_name(request, obj) + if ( + request.method == "POST" + and "merge" not in request.POST + and ( + "accept" in request.POST + or "accept_edit" in request.POST + or "accept_approve" in request.POST + or "delete" in request.POST + or "spam" in request.POST + or "upvote" in request.POST + or "downvote" in request.POST + ) + ): + # Handle accepting/deleting suggestions + _obj, unit_set, _context = parse_path_units( + request, path, (Translation, ProjectLanguage, CategoryLanguage) + ) + + checksum_form = ChecksumForm(unit_set, request.POST) + if not checksum_form.is_valid(): + show_form_errors(request, checksum_form) + return HttpResponseBadRequest("Invalid checksum") + + unit = checksum_form.cleaned_data["unit"] + # We are ignoring any redirects and responses here + _response = handle_suggestions(request, unit, "", "") # Handle redirects if isinstance(search_result, HttpResponse):