-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft: Suggestions in Zen mode #11187
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -893,6 +893,32 @@ | |
|
||
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 | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is essentially a copy of code from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can I just put such a function in the same file, or it should go to some utils.py file? |
||
): | ||
# Handle accepting/deleting suggestions | ||
_obj, unit_set, _context = parse_path_units( | ||
request, path, (Translation, ProjectLanguage, CategoryLanguage) | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is already done at top of this function. |
||
|
||
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, "", "") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the return value is not needed, there is no need to store it in a variable.
Comment on lines
+896
to
+921
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Refactor the code and add tests. The code segment introduces new functionality to handle accepting or deleting suggestions within the
Do you want me to refactor the code to address these issues or open a GitHub issue to track these improvements? ToolsRuff
GitHub Check: codecov/patch
|
||
|
||
# Handle redirects | ||
if isinstance(search_result, HttpResponse): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please avoid inline styles.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, I don't like it too, I wonder what should I do instead? Changing the original class doesn't sound like a good idea either, I guess I could create new one?