Skip to content

Add steward copy-context and per-type duplicate URL exemption#597

Merged
JoaquinBN merged 2 commits intodevfrom
JoaquinBN/copy-submission
May 4, 2026
Merged

Add steward copy-context and per-type duplicate URL exemption#597
JoaquinBN merged 2 commits intodevfrom
JoaquinBN/copy-submission

Conversation

@JoaquinBN
Copy link
Copy Markdown
Collaborator

Summary

  • Adds a copy-icon button on each submission card in the steward review queue (steward view only) that copies a compact AI-ready bundle — user, contribution type, mission, state, submitter notes, evidence URLs, staff reply, proposal, and internal CRM notes — to the clipboard. Notes are re-fetched on click and the copy aborts on fetch failure to prevent silently-incomplete payloads.
  • Adds an admin-editable `allow_duplicate` flag on `EvidenceURLType` that exempts URLs of a given type (e.g. shared GitHub repositories) from duplicate detection in both the synchronous submission serializer and the auto-review command. Lookup excludes permissive evidence; the auto-review path falls back to URL pattern detection when stored `url_type` is null; accepted-contribution evidence copying preserves `url_type` so the exemption survives.
  • Includes new tests for the duplicate-allow exemption (lookup exclusion, per-URL short-circuit, null `url_type` fallback, accepted-evidence preservation, and that non-permissive types still reject duplicates).

Test plan

  • Apply migration `0055_evidenceurltype_allow_duplicate` and confirm the flag appears as editable in `/admin/contributions/evidenceurltype/`.
  • In steward review, click the copy icon on a pending submission with internal CRM notes; verify the clipboard contains all sections including notes.
  • Toggle `allow_duplicate` on for one type and submit two submissions with the same URL of that type — both should pass duplicate checks. Toggle off and confirm strict behavior returns.
  • Run backend tests: `python manage.py test contributions.tests.test_url_utils contributions.tests.test_review_submissions`.

JoaquinBN added 2 commits May 4, 2026 18:27
The steward submissions queue gains a copy-icon button on each card
(steward review view only) that copies a compact AI-ready bundle of the
submission: user, contribution type, mission, state, submitter notes,
evidence, staff reply, proposal, and steward CRM notes. Notes are
re-fetched on click; copy aborts on fetch failure rather than producing
a clipboard payload with silently-missing context.

Evidence URL types gain an admin-editable allow_duplicate flag. When
set, URLs of that type are exempt from duplicate detection in both the
synchronous submission serializer and the auto-review deterministic
rule. Accepted-contribution evidence copying preserves the url_type FK
so the exemption applies on the converted side; the auto-review path
falls back to URL pattern detection when a row's url_type is null.

## Claude Implementation Notes
- backend/contributions/models.py: Adds allow_duplicate BooleanField (default False) on EvidenceURLType.
- backend/contributions/migrations/0055_evidenceurltype_allow_duplicate.py: Schema migration for the new field.
- backend/contributions/admin.py: Surfaces the flag in EvidenceURLType admin list (display, filter, list_editable).
- backend/contributions/url_utils.py: check_duplicate_url short-circuits when the incoming URL maps to a permissive type, and excludes stored evidence whose url_type is permissive from both submission and accepted-contribution lookups.
- backend/contributions/management/commands/review_submissions.py: _build_url_lookup excludes permissive evidence from url_to_sub_ids and accepted_urls. _check_single_url_duplicate short-circuits when the new evidence's url_type is permissive, with a detect_url_type fallback when url_type is null.
- backend/contributions/views.py: Steward-accept evidence copy via bulk_create now preserves url_type so the FK isn't dropped (bulk_create bypasses Evidence.save()).
- backend/contributions/tests/test_url_utils.py: Adds CheckDuplicateUrlAllowDuplicateTests and CheckDuplicateUrlNullUrlTypeTests.
- backend/contributions/tests/test_review_submissions.py: Adds RuleDuplicateUrlAllowDuplicateTest covering lookup exclusion, per-URL short-circuit, null-fallback, accepted-evidence preservation, and that non-permissive types still reject duplicates.
- frontend/src/components/SubmissionCard.svelte: Adds copy-context button gated on showReviewForm && !isOwnSubmission, copyContext() builder that assembles a compact text payload, and onRequestNotes prop so the card awaits a fresh notes fetch before copying.
- frontend/src/routes/StewardSubmissions.svelte: Adds throwing fetchNotesForCopy wired as onRequestNotes so fetch failures abort the copy instead of silently degrading.
@JoaquinBN JoaquinBN force-pushed the JoaquinBN/copy-submission branch from e5196f7 to b3c3a6a Compare May 4, 2026 16:28
@JoaquinBN JoaquinBN merged commit 6fdb0bf into dev May 4, 2026
@JoaquinBN JoaquinBN deleted the JoaquinBN/copy-submission branch May 4, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant