Skip to content

Commit

Permalink
Merge pull request #10 from wildfish/fix/handle_custom_delete_queryset
Browse files Browse the repository at this point in the history
Allow custom delete managers to have additional params.
  • Loading branch information
jamesoutterside committed Mar 20, 2020
2 parents 4c5d04a + bc47d11 commit f6e0535
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 27 deletions.
4 changes: 0 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@ script:
- tox
env:
matrix:
- TOXENV=py27-django1.8
- TOXENV=py34-django1.8
- TOXENV=py27-django1.11
- TOXENV=py34-django1.11
- TOXENV=py35-django1.11
- TOXENV=py36-django1.11 DEPLOY=true
- TOXENV=py27-django1.11 DATABASE_ENGINE=mysql DATABASE_USER=travis
- TOXENV=py27-django1.11 DATABASE_ENGINE=pgsql DATABASE_USER=postgres
- TOXENV=py36-django1.11 DATABASE_ENGINE=mysql DATABASE_USER=travis
- TOXENV=py36-django1.11 DATABASE_ENGINE=pgsql DATABASE_USER=postgres
- TOXENV=py34-django2.0
Expand Down
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Features
backups
* Anonymise all models to sanitise working copies of a production database

Supports Django 1.8 to 2.1, on Python 2.7 and 3.4+.
Supports Django 1.8 to 2.1, on 3.4+.

See the `full documentation <https://django-gdpr-assist.readthedocs.io>`_ for details
of how GDPR-assist works; in particular:
Expand Down
5 changes: 1 addition & 4 deletions gdpr_assist/admin/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,7 @@ def handle_export(self, request, querysets):
with zipfile.ZipFile(zipfile_buffer, 'w') as zipped_file:
for model, queryset in querysets.items():
# Generate CSV data in memory
if six.PY2:
csv_buffer = BytesIO()
else:
csv_buffer = StringIO()
csv_buffer = StringIO()
csv_writer = None
for obj in queryset:
privacy_meta = getattr(
Expand Down
4 changes: 2 additions & 2 deletions gdpr_assist/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ def anonymise(self):
for obj in self:
obj.anonymise()

def delete(self):
def delete(self, *args, **kwargs):
"""
Anonymise privacy-registered objects related to this queryset
"""
for obj in self:
anonymise_related_objects(obj)

super(PrivacyQuerySet, self).delete()
super(PrivacyQuerySet, self).delete(*args, **kwargs)

@classmethod
def _cast_class(cls, queryset):
Expand Down
2 changes: 0 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,6 @@ def runtests(args):
'Intended Audience :: Developers',
'License :: OSI Approved :: BSD License',
'Operating System :: OS Independent',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.7',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: 3.5',
Expand Down
6 changes: 1 addition & 5 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
from io import BytesIO, TextIOWrapper
import csv
import six
import zipfile

import django
Expand Down Expand Up @@ -282,10 +281,7 @@ def test_export_matches__records_export(self):
],
)

if six.PY2:
mode = 'rU'
else:
mode = 'r'
mode = 'r'

with zip_file.open(
'gdpr_assist_tests_app-FirstSearchModel.csv',
Expand Down
5 changes: 1 addition & 4 deletions tests/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""
import six
import sys
from io import StringIO

from django.core.management import call_command
from django.test import TestCase
Expand All @@ -20,10 +21,6 @@ class Capturing(list):
def __enter__(self):
self._stdout = sys.stdout
self._stderr = sys.stderr
if six.PY2:
from StringIO import StringIO
else:
from io import StringIO
sys.stdout = sys.stderr = self._stringio = StringIO()
return self

Expand Down
9 changes: 4 additions & 5 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[tox]
envlist =
clean
py{27,34}-django1.8
py{27,34,35,36}-django1.11
py{34}-django1.8
py{34,35,36}-django1.11
py{34,35,36}-django2.0
py{35,36}-django2.1
report
Expand All @@ -17,7 +17,6 @@ setenv =
TOXENV={envname}

basepython =
py27: python2.7
py34: python3.4
py35: python3.5
py36: python3.6
Expand All @@ -27,12 +26,12 @@ deps =
django1.11: django>=1.11, <2.0
django2.0: django>=2.0, <2.1
django2.1: django>=2.1, <2.2
py27: mock
ipdb
six
django-yaa-settings
# Make mysql/pgsql available in case env specifies one
model_mommy
django1.8: model_mommy==1.5.1
django1.11,django2.0,django2.1: model_mommy==2.0.0
freezegun
pillow
psycopg2>2.4.1
Expand Down

0 comments on commit f6e0535

Please sign in to comment.