Fix duplicate community library submission#5773
Conversation
rtibblesbot
left a comment
There was a problem hiding this comment.
Clean fix for the duplicate submission bug.
CI pending (frontend tests, Python unit tests, linting still running). No UI files changed.
- praise: Root cause is well-identified — the hardcoded
-date_updatedordering caused recently-updated older submissions to shadow newer ones, allowing duplicate creation. The fix correctly separates the default ordering from the queryset and enables client-specified ordering viaValuesViewsetOrderingFilter, which is the established pattern in this codebase.
@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly
How was this generated?
Reviewed the pull request diff checking for:
- Correctness: bugs, edge cases, undocumented behavior, resource leaks, hardcoded values
- Design: unnecessary complexity, naming, readability, comment accuracy, redundant state
- Architecture: duplicated concerns, minimal interfaces, composition over inheritance
- Testing: behavior-based assertions, mocks only at hard boundaries, accurate coverage
- Completeness: missing dependencies, unupdated usages, i18n, accessibility, security
- Principles: DRY (same reason to change), SRP, Rule of Three (no premature abstraction)
- Checked CI status and linked issue acceptance criteria
- For UI changes: inspected screenshots for layout, visual completeness, and consistency
| pagination_class = CommunityLibrarySubmissionPagination | ||
|
|
||
| ordering_fields = ["date_updated", "date_created"] | ||
| ordering = "-date_updated" |
There was a problem hiding this comment.
praise: Good design — setting ordering = "-date_updated" as the viewset default preserves backward compatibility for all other callers while enabling the frontend to override with -date_created when needed.
marcellamaki
left a comment
There was a problem hiding this comment.
thank you @AlexVelezLl ! @pcenov, although I am approving and merging, I am tagging this as "needs QA" for testing on unstable (using the reviewer guidance above)
Summary
Fixes community library submission ordering when requesting the latest submission. The error occurred because on the submission side panel, we query the latest submission to know if a submission already exists, but the ordering was set to "-updated_date" by default. Therefore, if a previous submission was recently updated, we will get this previous submission, instead of the "newer created submission". Therefore, allowing the user to make the request to create a submission that already exists.
References
Closes #5766.
Reviewer guidance