Skip to content
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

Improve soft-deletion faculty #102

Merged
merged 8 commits into from
Jan 25, 2024
Merged

Improve soft-deletion faculty #102

merged 8 commits into from
Jan 25, 2024

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Jan 25, 2024

Prior to this PR, soft deletion was implemented for the SolidusFriendlyPromotion::PromotionAction. However, there was no UI making soft-deleted records visible, and it appears this was only done so that Spree::Adjustment records never lose their source.

This PR moves the soft-deletion faculty to the SolidusFriendlyPromotion::Promotion model, adds a little bit of UI to make them visible if necessary, and tells the Spree::PromotionAction model how to deal with adjustments: If there's adjustments where the order is complete, refuse to be deleted, if there's adjustments where the order is incomplete, delete those adjustments.

Fixes #30

Let's use the `discard` gem for soft-deleting promotions.
@mamhoff mamhoff force-pushed the discard-promotions branch from 5bc903c to 602eb0b Compare January 25, 2024 10:38
There are still a few bugs with the new admin, so let's disable that
for the time being.
We don't want to allow people to edit or re-create deleted promotions,
so we just indicate they're there for now. Let's see if we find a need
to show them in some kind of uneditable mode.
When a promotion has been applied to an order, we need to make sure no
adjustments remain that have that promotion's actions as their source.
For incomplete orders, we can simply delete the adjustments, but for
complete orders, we must stop the promotion action from being deleted.
We now protect against destroying promotion actions that have been
applied to a complete order, so we can stop the dependent: :nullify
thing.
There's no need for soft-delete on promotion actions, now that we have
soft-delete on promotions.
We don't need soft-delete on promotion actions when we have soft-delete
on promotions.
@mamhoff mamhoff force-pushed the discard-promotions branch from 602eb0b to 61b6ec3 Compare January 25, 2024 10:46
@mamhoff mamhoff merged commit 43d8a32 into main Jan 25, 2024
4 checks passed
@mamhoff mamhoff deleted the discard-promotions branch January 25, 2024 11:12
mamhoff added a commit that referenced this pull request Jul 1, 2024
mamhoff added a commit that referenced this pull request Oct 25, 2024
mamhoff added a commit that referenced this pull request Oct 25, 2024
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.

Implement better soft-delete
2 participants