Skip to content

Commit

Permalink
Merge branch 'release/0.3.7' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Jul 20, 2023
2 parents bb2c344 + abfbe54 commit 5b8fb45
Show file tree
Hide file tree
Showing 26 changed files with 25 additions and 31 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ repos:
- "-x *test*.py"

- repo: https://github.com/psf/black
rev: 23.1.0
rev: 23.3.0
hooks:
- id: black
language_version: python3.9
language_version: python3.10

- repo: https://github.com/pycqa/flake8
rev: 6.0.0
Expand Down Expand Up @@ -42,7 +42,7 @@ repos:
- id: detect-private-key

- repo: https://github.com/adrienverge/yamllint
rev: v1.30.0
rev: v1.31.0
hooks:
- id: yamllint
args:
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

@admin.register(Crypt, site=encryption_admin)
class CryptModelAdmin(admin.ModelAdmin):

date_hierarchy = "modified"

fields = sorted(tuple(field.name for field in Crypt._meta.fields))
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/fields/base_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@


class BaseField(models.Field):

description = "Field class that stores values as encrypted"

def __init__(self, algorithm, mode, *args, **kwargs):
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/fields/encrypted_char_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@


class EncryptedCharField(BaseRsaField):

description = "rsa encrypted field for 'CharField'"
2 changes: 0 additions & 2 deletions django_crypto_fields/fields/encrypted_decimal_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@


class EncryptedDecimalField(BaseRsaField):

description = "local-rsa encrypted field for 'IntegerField'"

def __init__(self, *args, **kwargs):

if "max_digits" not in kwargs:
raise AttributeError(
"EncryptedDecimalField requires attribute 'max_digits. " "Got none"
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/fields/encrypted_integer_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


class EncryptedIntegerField(BaseRsaField):

description = "local-rsa encrypted field for 'IntegerField'"

def to_python(self, value):
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/fields/encrypted_text_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class EncryptedTextField(BaseAesField):

description = "Custom field for 'Text' form field, uses local AES"

def formfield(self, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

class Command(BaseCommand):
def add_arguments(self, parser):

parser.add_argument(
"--dry-run",
action="store_true",
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@


class Migration(migrations.Migration):

initial = True

dependencies = []
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@


class Migration(migrations.Migration):

replaces = [
("django_crypto_fields", "0001_initial"),
("django_crypto_fields", "0002_crypt_cipher_mode"),
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/migrations/0002_auto_20190303_2341.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Migration(migrations.Migration):

dependencies = [("django_crypto_fields", "0001_squashed_0011_delete_keyreference")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/migrations/0002_crypt_cipher_mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [("django_crypto_fields", "0001_initial")]

operations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [
("django_crypto_fields", "0002_auto_20190303_2341"),
]
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/migrations/0003_auto_20161124_1835.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Migration(migrations.Migration):

dependencies = [("django_crypto_fields", "0002_crypt_cipher_mode")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/migrations/0004_auto_20161221_0018.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Migration(migrations.Migration):

dependencies = [("django_crypto_fields", "0003_auto_20161124_1835")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/migrations/0005_auto_20170106_1849.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


class Migration(migrations.Migration):

dependencies = [("django_crypto_fields", "0004_auto_20161221_0018")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/migrations/0006_auto_20170328_0728.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [("django_crypto_fields", "0005_auto_20170106_1849")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/migrations/0007_auto_20170518_1233.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Migration(migrations.Migration):

dependencies = [("django_crypto_fields", "0006_auto_20170328_0728")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/migrations/0008_auto_20170624_1905.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@


class Migration(migrations.Migration):

dependencies = [("django_crypto_fields", "0007_auto_20170518_1233")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/migrations/0009_auto_20170903_1532.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class Migration(migrations.Migration):

dependencies = [("django_crypto_fields", "0008_auto_20170624_1905")]

operations = [
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/migrations/0010_keyreference.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@


class Migration(migrations.Migration):

dependencies = [("django_crypto_fields", "0009_auto_20170903_1532")]

operations = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@


class Migration(migrations.Migration):

dependencies = [("django_crypto_fields", "0010_keyreference")]

operations = [migrations.DeleteModel(name="KeyReference")]
2 changes: 0 additions & 2 deletions django_crypto_fields/persist_key_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ def get_etc_dir(no_warn=None):


def get_last_key_path(filename=None):

last_key_path = None
if "test" not in sys.argv:
if not filename:
Expand All @@ -50,7 +49,6 @@ def get_last_key_path(filename=None):


def persist_key_path(key_path=None, filename=None):

last_key_path = get_last_key_path(filename)

if not last_key_path:
Expand Down
1 change: 0 additions & 1 deletion django_crypto_fields/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class TestModel(CryptoMixin, BaseModel):

firstname = FirstnameField(verbose_name="First Name", null=True)

lastname = LastnameField(verbose_name="Last Name", null=True)
Expand Down
18 changes: 17 additions & 1 deletion django_crypto_fields/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
def has_encrypted_fields(model):
from __future__ import annotations

from typing import TYPE_CHECKING

if TYPE_CHECKING:
from .fields import BaseField


def has_encrypted_fields(model) -> bool:
for field in model._meta.get_fields():
if hasattr(field, "field_cryptor"):
return True
return False


def get_encrypted_fields(model) -> list[BaseField]:
encrypted_fields = []
for field in model._meta.get_fields():
if hasattr(field, "field_cryptor"):
encrypted_fields.append(field)
return encrypted_fields
7 changes: 5 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ exclude_lines = [
legacy_tox_ini = """
[tox]
envlist =
py{310,311}-dj{41,dev},
py{310}-dj{41,42},
py{311}-dj{41,42,dev},
lint
isolated_build = true
Expand All @@ -48,7 +49,8 @@ python =
[gh-actions:env]
DJANGO =
4.1: dj41, lint
4.1: dj41
4.2: dj42, lint
dev: djdev
[testenv]
Expand All @@ -58,6 +60,7 @@ deps =
-r https://raw.githubusercontent.com/clinicedc/edc/develop/requirements.tests/edc.txt
-r https://raw.githubusercontent.com/clinicedc/edc/develop/requirements.tests/third_party_dev.txt
dj41: Django>=4.1,<4.2
dj42: Django>=4.2,<5.0
djdev: https://github.com/django/django/tarball/main
commands =
Expand Down

0 comments on commit 5b8fb45

Please sign in to comment.