Skip to content

Commit

Permalink
remove uuid from form initial data for names
Browse files Browse the repository at this point in the history
  • Loading branch information
erikvw committed Aug 12, 2023
1 parent 8fe565b commit d5eb175
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions edc_consent/modeladmin_mixins/pii_names_model_admin_mixin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import re
from typing import Tuple

from django.core.handlers.wsgi import WSGIRequest
from edc_constants.constants import UUID_PATTERN

from ..utils import get_remove_patient_names_from_countries

Expand Down Expand Up @@ -46,3 +48,10 @@ def fields_without_names(self, fields: tuple, request: WSGIRequest) -> Tuple[str
if site and site.id in [s.site_id for s in self.all_sites.get(country)]:
fields = tuple([f for f in fields if f not in self.name_fields])
return fields

def get_changeform_initial_data(self, request) -> dict:
dct = super().get_changeform_initial_data(request)
for field in self.name_fields:
if re.match(UUID_PATTERN, dct.get(field, "")):
dct.update({field: None})
return dct

0 comments on commit d5eb175

Please sign in to comment.