Skip to content

fix: deletion of version objects blocked by source fields #320

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

Merged
merged 15 commits into from
Feb 28, 2023

Conversation

fsbraun
Copy link
Member

@fsbraun fsbraun commented Feb 16, 2023

Description

source fields refer to Version objects a version was originally derived (copied) from. They are declared with on_delete = models.PROTECT. This blocks deletion of versioned objects (such as pages) which have sources.

If DJANGOCMS_VERSIONING_ALLOW_DELETING_VERSIONS is set to True, on_delete = models.SET_NULL removes the block and a user with permissions to delete Version objects can delete pages.

Remark: This does not affect the models.PROTECT setting for the Version.content.

Related resources

  • This change in model is reflected in the existing migrations but does not affect database constraints (see Django docs). Toggling the settings will therefore not create migrations.
  • A test for missing migrations has been added. It needs to run as the first test for otherwise versioning's proxy models might create an incorrect migration.
  • This test revealed that two verbose names of fields were not referred to in the migrations. This is fixed.

Checklist

  • I have opened this pull request against master
  • I have added or modified the tests when changing logic
  • I have followed the conventional commits guidelines to add meaningful information into the changelog
  • I have read the contribution guidelines and I have joined #workgroup-pr-review on
    Slack to find a “pr review buddy” who is going to review my pull request.

@codecov
Copy link

codecov bot commented Feb 16, 2023

Codecov Report

Merging #320 (2592545) into master (6d062b2) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #320      +/-   ##
==========================================
+ Coverage   89.96%   89.99%   +0.02%     
==========================================
  Files          68       68              
  Lines        2253     2259       +6     
  Branches      300      301       +1     
==========================================
+ Hits         2027     2033       +6     
  Misses        171      171              
  Partials       55       55              
Impacted Files Coverage Δ
djangocms_versioning/migrations/0003_version.py 100.00% <ø> (ø)
...cms_versioning/migrations/0015_version_modified.py 100.00% <ø> (ø)
djangocms_versioning/conf.py 100.00% <100.00%> (ø)
...gocms_versioning/migrations/0014_version_source.py 100.00% <100.00%> (ø)
djangocms_versioning/models.py 95.05% <100.00%> (+0.13%) ⬆️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@fsbraun fsbraun requested a review from Aiky30 February 16, 2023 13:27
Copy link
Contributor

@Aiky30 Aiky30 left a comment

Choose a reason for hiding this comment

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

Looks good, minor comments added.

fsbraun and others added 5 commits February 24, 2023 14:39
Co-authored-by: Andrew Aikman <Aiky30@users.noreply.github.com>
Co-authored-by: Andrew Aikman <Aiky30@users.noreply.github.com>
@fsbraun fsbraun merged commit 7e41d8a into django-cms:master Feb 28, 2023
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