Skip to content

proposal to avoid used unpublished templates - #3143

Merged
briri merged 6 commits into
DMPRoadmap:developmentfrom
nicolasfranck:fix_unpublish_template
Apr 7, 2022
Merged

proposal to avoid used unpublished templates#3143
briri merged 6 commits into
DMPRoadmap:developmentfrom
nicolasfranck:fix_unpublish_template

Conversation

@nicolasfranck

Copy link
Copy Markdown
Contributor

Fixes #2860

Changes proposed in this PR:

  • when button "unpublish" is clicked, and that template is published and that template is used by one or more plans, a new version should be created, instead of risking to alter the structure of existing plans
  • select and update should happen within the same transaction

@briri briri 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.

This looks reasonable to me. Thanks @nicolasfranck

@briri briri 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.

Thanks for patching this @nicolasfranck. Rubocop has one complaint. If you can switch that if statement to a one-liner it should make Rubocop happy

flash[:alert] = _("Unable to unpublish your #{template_type(template)}.")
Template.transaction do
# expected: template is latest
if template.published? && template.plans.any?

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.

Change this to a one-liner template.generate_version! if template.published? && template.plans.any? to make Rubocop happy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants