-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
18 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |