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

chore: remove deprecated pre_save #710

Merged
merged 13 commits into from
Dec 2, 2022
4 changes: 3 additions & 1 deletion .github/workflows/migration-fixer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.6.x'
python-version: '3.7.x'
cache: 'pip'
cache-dependency-path: '**/requirements.txt'

- name: Install dependencies
run: |
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ jobs:
strategy:
fail-fast: true
matrix:
platform: [ubuntu-latest, macos-latest, windows-latest]
platform: [ubuntu-20.04, ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9, '3.10', 3.11]
exclude:
- platform: ubuntu-latest
python-version: 3.6
- platform: macos-latest
python-version: 3.11
- platform: windows-latest
Expand Down
19 changes: 0 additions & 19 deletions model_clone/mixin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import itertools
import warnings
from itertools import repeat

from conditional import conditional
Expand Down Expand Up @@ -196,23 +195,6 @@ def bulk_clone_multi(cls, objs, attrs=None, batch_size=None):
# TODO: Support bulk clones split by the batch_size
pass

def pre_save_duplicate(self, instance): # pylint: disable=R0201
"""
This method has been deprecated and would be removed in the 5.0.0 release.
Please use `pre_clone_save` signal instead.

See: https://github.com/tj-django/django-clone#signals for guidance.
"""
# TODO: Remove prior to v5.0.0 release
warnings.warn(
"The usage of `pre_save_duplicate` has been deprecated "
"and would be removed in the 5.0.0 release "
"Please use `pre_clone_save` signal instead.",
DeprecationWarning,
stacklevel=2,
)
return instance

@transaction.atomic
def make_clone(self, attrs=None, sub_clone=False, using=None, parent=None):
"""Creates a clone of the django model instance.
Expand Down Expand Up @@ -245,7 +227,6 @@ def make_clone(self, attrs=None, sub_clone=False, using=None, parent=None):
for name, value in attrs.items():
setattr(duplicate, name, value)

duplicate = self.pre_save_duplicate(duplicate)
duplicate = self.__duplicate_m2o_fields(duplicate, using=using)

pre_clone_save.send(sender=self.__class__, instance=duplicate)
Expand Down
5 changes: 0 additions & 5 deletions sample/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,6 @@ class Book(CloneModel):
def __str__(self):
return _(self.name)

def pre_save_duplicate(self, instance):
instance.name = self.name

return instance


class BookTag(models.Model):
book = models.ForeignKey(Book, on_delete=models.CASCADE)
Expand Down