Skip to content

Commit

Permalink
Finished release 0.1.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed May 19, 2015
2 parents 7a6090b + 737756c commit a3331d0
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 3 deletions.
2 changes: 1 addition & 1 deletion django_crypto_fields/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
try:
KEY_PATH = settings.KEY_PATH
except (ImproperlyConfigured, AttributeError) as e:
KEY_PATH = os.path.join(settings.BASE_DIR, 'django_crypto_fields/tests')
KEY_PATH = settings.BASE_DIR
KEY_PREFIX = 'test'
print('Warning! Not ready for production. {}. Setting KEY_PATH to {} for testing purposes.'.format(e, KEY_PATH))

Expand Down
1 change: 1 addition & 0 deletions django_crypto_fields/fields/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .base_field import BaseField
from .encrypted_char_field import EncryptedCharField
from .encrypted_date_field import EncryptedDateField
from .encrypted_decimal_field import EncryptedDecimalField
Expand Down
1 change: 1 addition & 0 deletions django_crypto_fields/mixins/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .crypto_mixin import CryptoMixin
8 changes: 8 additions & 0 deletions django_crypto_fields/mixins/crypto_mixin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from ..fields import BaseField


class CryptoMixin(object):

@classmethod
def encrypted_fields(cls):
return [fld.name for fld in cls._meta.fields if isinstance(fld, BaseField)]
8 changes: 7 additions & 1 deletion django_crypto_fields/tests/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
from datetime import datetime

from django.db import models

from ..edc.base.models import BaseModel

from ..fields import EncryptedTextField, FirstnameField, IdentityField
from ..mixins import CryptoMixin


class TestModel (BaseModel):
class TestModel (CryptoMixin, BaseModel):

first_name = FirstnameField(
verbose_name="First Name")
Expand All @@ -18,6 +21,9 @@ class TestModel (BaseModel):
verbose_name="AES",
max_length=500)

report_date = models.DateField(
default=datetime.today())

objects = models.Manager()

class Meta:
Expand Down
3 changes: 3 additions & 0 deletions django_crypto_fields/tests/test_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ def test_encrypt_rsa(self):
name, path, args, kwargs = fld_instance.deconstruct()
new_instance = BaseField(*args, **kwargs)
# self.assertEqual(fld_instance.max_length, new_instance.max_length)

def test_list_encrypted_fields(self):
self.assertEquals(len(TestModel.encrypted_fields()), 3)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

setup(
name='django-crypto-fields',
version='0.1.1a',
version='0.1.2',
author=u'Erik van Widenfelt',
author_email='ew2789@gmail.com',
packages=find_packages(),
Expand Down

0 comments on commit a3331d0

Please sign in to comment.