Skip to content

Commit 643c87f

Browse files
authored
Added support for Django 2.x+ (#50)
* Added support for Django 2.x+ * Updated requirements for testing * Updated travis config with Python 3.6 and additional environments * Updated CHANGELOG and README
1 parent 6281aaa commit 643c87f

File tree

11 files changed

+37
-15
lines changed

11 files changed

+37
-15
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: python
22
python:
3-
- 3.4
3+
- 3.6
44
script: make test
55
notifications:
66
email: false
@@ -13,6 +13,8 @@ env:
1313
- DJANGO='django>=1.8,<1.9'
1414
- DJANGO='django>=1.9,<1.10'
1515
- DJANGO='django>=1.10,<1.11'
16+
- DJANGO='django>=2.0,<2.1'
17+
- DJANGO='django>=2.1,<2.2'
1618
- DJANGO='--upgrade --pre django'
1719
matrix:
1820
fast_finish: true

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 2.1.1
2+
3+
* Added support for Django 2.x+
4+
* Updated requirements for testing
5+
* Updated travis config with Python 3.6 and additional environments
6+
17
## 2.1.0
28

39
Thanks to @peterfarrell:

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ PGP symmetric fields are:
2828
## Requirements
2929

3030
- postgres with `pgcrypto`
31+
- Supports Django 1.8 to 2.1
32+
- Compatible with Python 3 only
33+
3134

3235
## Installation
3336

pgcrypto/forms.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class DateField(forms.DateField):
1111
def __init__(self, input_formats=None, *args, **kwargs):
1212
"""Init that pops off the max_length attribute."""
1313
kwargs.pop('max_length', None)
14-
super().__init__(input_formats, *args, **kwargs)
14+
super().__init__(input_formats=input_formats, **kwargs)
1515

1616

1717
class DateTimeField(forms.DateTimeField):
@@ -24,4 +24,4 @@ class DateTimeField(forms.DateTimeField):
2424
def __init__(self, input_formats=None, *args, **kwargs):
2525
"""Init that pops off the max_length attribute."""
2626
kwargs.pop('max_length', None)
27-
super().__init__(input_formats, *args, **kwargs)
27+
super().__init__(input_formats=input_formats, **kwargs)

pgcrypto/lookups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class DateLookupBase(Lookup):
5252
operator = None # Set in subclasses
5353

5454
def __init__(self, lhs, rhs):
55-
"""Implementing an abstract class."""
55+
"""Implement an abstract class."""
5656
super(DateLookupBase, self).__init__(lhs, rhs) # pragma: no cover
5757

5858
def as_sql(self, qn, connection):

pgcrypto/mixins.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ class HashMixin:
2121
`HashMixin` uses 'pgcrypto' to encrypt data in a postgres database.
2222
"""
2323
def __init__(self, original=None, *args, **kwargs):
24+
"""Tells the init the original attr."""
2425
self.original = original
2526

2627
super(HashMixin, self).__init__(*args, **kwargs)
2728

2829
def pre_save(self, model_instance, add):
30+
"""Save the original_value."""
2931
if self.original:
3032
original_value = getattr(model_instance, self.original)
3133
setattr(model_instance, self.attname, original_value)

requirements.txt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
colour-runner==0.0.5
33
coverage==4.3.1
44
dj-database-url==0.4.2
5-
django>=1.10,<1.11
5+
django>=1.10,<2.2
66
factory-boy==2.8.1
7-
flake8-docstrings==1.0.2
7+
flake8-docstrings==1.3.0
88
flake8-import-order==0.11
9-
flake8==3.2.1
9+
flake8==3.5.0
1010
incuna-test-utils==6.6.0
11-
psycopg2==2.6.2
12-
pyflakes==1.4.0
11+
psycopg2-binary==2.7.5
12+
pyflakes==1.6.0
13+
pycodestyle==2.3.1

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from setuptools import find_packages, setup
22

33

4-
version = '2.1.0'
4+
version = '2.1.1'
55

66

77
setup(

tests/factories.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
class EncryptedModelFactory(factory.DjangoModelFactory):
99
"""Factory to generate hashed and encrypted data."""
10-
class Meta:
11-
model = EncryptedModel
1210

1311
digest_field = factory.Sequence('Text digest {}'.format)
1412
hmac_field = factory.Sequence('Text hmac {}'.format)
@@ -22,3 +20,7 @@ class Meta:
2220
pgp_sym_field = factory.Sequence('Text with symmetric key {}'.format)
2321

2422
date_pgp_sym_field = date.today()
23+
24+
class Meta:
25+
"""Sets up meta for test factory."""
26+
model = EncryptedModel

tests/models.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ class EncryptedModelManager(managers.PGPManager):
1010
class EncryptedModel(models.Model):
1111
"""Dummy model used for tests to check the fields."""
1212
digest_field = fields.TextDigestField(blank=True, null=True)
13-
digest_with_original_field = fields.TextDigestField(blank=True, null=True, original='pgp_sym_field')
13+
digest_with_original_field = fields.TextDigestField(blank=True, null=True,
14+
original='pgp_sym_field')
1415
hmac_field = fields.TextHMACField(blank=True, null=True)
15-
hmac_with_original_field = fields.TextHMACField(blank=True, null=True, original='pgp_sym_field')
16+
hmac_with_original_field = fields.TextHMACField(blank=True, null=True,
17+
original='pgp_sym_field')
1618

1719
email_pgp_pub_field = fields.EmailPGPPublicKeyField(blank=True, null=True)
1820
integer_pgp_pub_field = fields.IntegerPGPPublicKeyField(blank=True, null=True)
@@ -25,6 +27,7 @@ class EncryptedModel(models.Model):
2527
datetime_pgp_sym_field = fields.DateTimePGPSymmetricKeyField(blank=True, null=True)
2628

2729
class Meta:
30+
"""Sets up the meta for the test model."""
2831
app_label = 'tests'
2932

3033

@@ -33,4 +36,5 @@ class EncryptedModelWithManager(EncryptedModel):
3336
objects = EncryptedModelManager()
3437

3538
class Meta:
39+
"""Sets up the meta for the test manager."""
3640
proxy = True

0 commit comments

Comments
 (0)