Skip to content

Improve object selection and batch copying of covers and stories - #767

Merged
jochengcd merged 6 commits into
GrandComicsDatabase:betafrom
ProfNardi:feat/select-stories-bulk-copy
Sep 27, 2026
Merged

jochengcd merged 6 commits into
GrandComicsDatabase:betafrom
ProfNardi:feat/select-stories-bulk-copy

Conversation

@ProfNardi

@ProfNardi ProfNardi commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Description

Redesigned /select_object/ to make selecting, ordering, and copying covers and stories simpler—with a compact interface and atomic batch operations.

Features

  • Added a compact layout inspired by the keyword manager, with three collapsible search panels:

    • Search the catalog
    • Publication details
    • Select by ID
  • Added checkbox multi-selection with Select all / Clear selection controls per category.

  • Added drag-and-drop ordering with automatic persistence.

  • Kept selection counts, copy, bulk delete, and cancel within reach through a fixed action bar.

  • Removed per-row Delete buttons and moved category-wide and full cache clearing into a separate danger zone below the lists.

  • Added explicit primary-cover selection when copying multiple covers.

Fixes

  • Removed duplicate cache entries, including existing duplicates.
  • Unified single and batch copy handling: the primary cover occupies position 0, followed by cover reprints and selected stories in the appropriate order.
  • Made batch copying atomic with database transactions and row locks. Signed confirmation payloads and short-lived cache tokens prevent duplicate submissions—no new support tables or migrations.
  • Blocked cache operations while order changes are being saved and required a reload when the save outcome is uncertain.
  • Validated cache_size as a positive integer and preserved existing entries when changing its value.
  • Replaced the hard-coded 2025 search limit with the current year.
  • Preserved the existing Elasticsearch search backend.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a robust bulk-copying feature for cached sequences (covers and stories), including UI enhancements for managing and reordering remembered objects, dynamic validation for series years, and performance optimizations for homepage and series searches. The review feedback highlights several critical issues: a database integrity bug in apps/oi/views.py due to using a static hash for StoryCopyBatch keys, a failure to retrieve selected_covers during bulk cache removal in apps/select/views.py, a performance bottleneck in apps/gcd/views/search.py caused by evaluating querysets in memory, and a potential KeyError when sorting cache choices.

Comment thread apps/oi/views.py Outdated
Comment thread apps/select/views.py Outdated
Comment thread apps/gcd/views/search.py Outdated
Comment thread apps/select/views.py Outdated
Comment thread apps/oi/models.py Outdated
return "Changeset"


class StoryCopyBatch(models.Model):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add a model for temp data that can be put into the cache ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You’re right; a new model was unnecessary here. Removed StoryCopyBatch and its migration in d981f3a and switched to the existing cache.

@ProfNardi ProfNardi changed the title Improved handling of selection, ordering, and batch copying of covers and stories in /select_object/ Improve object selection and batch copying of covers and stories Sep 23, 2026
@ProfNardi
ProfNardi force-pushed the feat/select-stories-bulk-copy branch from 88bc43d to cdee1a9 Compare September 24, 2026 20:12
@jochengcd

Copy link
Copy Markdown
Contributor

I see you are editing css, we use tailwind as a css framework, so no written css.
I am behind in documenting its usage.

<p>This issue already has a cover. Copy as cover reprint (on interior page) at position {{ cover_position }}. The main cover stays in place.</p>
{% endif %}
{% endif %}
{% if bulk_copy %}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use two-space indentation for html files.

@jochengcd

Copy link
Copy Markdown
Contributor

Functionality looks good.

The colors and stylings need to use the tailwind colors.

@jochengcd

Copy link
Copy Markdown
Contributor

select_object is also used for adding reprints, which with this change doesn't work anymore.

@ProfNardi

Copy link
Copy Markdown
Contributor Author

Thanks, Jochen. Addressed in ea4d798 and 9a3feba:

  • Removed the custom stylesheets and inline CSS, replacing them with Tailwind utilities and existing shared button styles. HTML indentation now uses two spaces.
  • Restricted the redesigned selector to sequence copying. “Add Reprint” and other selection workflows now use the original page again.

@ProfNardi

Copy link
Copy Markdown
Contributor Author

The current fix keeps their templates separate, but both still use /select_object/, with the template chosen from the operation stored in the session.

I think a dedicated URL and view for sequence copying would make the separation clearer, while reusing the existing search and cache helpers. /select_object/ would retain its original behavior for reprints and other selections.

Would you prefer that approach for this PR?

@jochengcd

Copy link
Copy Markdown
Contributor

This is for sequences only, right ? We can make it under /select_multiple_sequences/ for the selection functionality, we might can use it for other purposes later.

The left/right border/margin on the page is larger then one other pages, should be consistent.

The text is smaller, I see a text-sm ? Should be consistent to other pages so that the user can consistently decide via zoom.

Do we need to show the order column, or can we hide it ? "Order" also line breaks before r on my window, which can be prevented.

The text on the buttons should all be capitalized, e.g. Copy Selected, again for consistency (not all buttons are made consistent, but all being edited should be made so)

Specific reason for covers above stories ? So far we had first stories, with the idea that the more often used object is on top. Should be consistent on the two select screens.

I am not sure about the red color for the clear-buttons. Don't think we have similar buttons so far ?

@ProfNardi

ProfNardi commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Removed the non-standard changes while keeping the style 100% consistent:

  • Added a dedicated /select_multiple_sequences/ URL and view, reusing the existing search and cache logic.
  • Preserved the original selector for reprints and other selections.
  • Removed the extra horizontal margins and smaller text overrides.
  • Hid the order column while keeping drag-and-drop ordering.
  • Put stories before covers and capitalized the button labels.
  • Replaced the red clear-cache buttons with muted Tailwind styling.

@jochengcd

jochengcd commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the update.

On the confirmation page we so far show the sequence data. For me this is key to make sure that I got the right sequence, also the "Copy credits with credited/signed qualifiers" and "Copy characters" depends on the data of the sequence, which is now not accessible. I think we need to show this as before ?

Since I know these question will come from the users:
Is there a way to remember the order in which one selects the sequences and thereby order them ?

Do we want "Copy credits with credited/signed qualifiers" and "Copy characters" per sequence ?

@ProfNardi

Copy link
Copy Markdown
Contributor Author

Ok. Updated in b96ac7fe:

  • Restored full sequence details on the confirmation page.
  • Added independent credit qualifier and character options for each sequence, with “select all” controls for multiple selections.
  • Added a sticky action bar using the existing Tailwind styles.
  • The behavior for a single sequence remains unchanged: once confirmed, it opens the copied sequence’s editor directly.
  • All 35 targeted tests pass.
  • Ordering still follows the cache’s order, which can be adjusted by dragging; selection click order is not tracked.

@jochengcd
jochengcd merged commit 3d9d4b5 into GrandComicsDatabase:beta Sep 27, 2026
2 checks passed
@ProfNardi
ProfNardi deleted the feat/select-stories-bulk-copy branch October 4, 2026 20:51
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.

2 participants