Skip to content

Commit d1e7e7d

Browse files
committed
Refactor the registration number cleanup
1 parent d6e7a09 commit d1e7e7d

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

backend/donations/management/commands/registration_numbers_cleanup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,12 @@ class Command(BaseCommand):
1818
def handle(self, *args, **options):
1919
errors: List[str] = []
2020
target_ngos = Ngo.objects.filter(registration_number_valid=None)
21+
2122
if target_ngos.count() == 0:
2223
target_ngos = Ngo.objects.filter(registration_number_valid=False)
24+
2325
if target_ngos.count() == 0:
2426
self.stdout.write(self.style.SUCCESS("No NGOs to clean registration numbers for."))
25-
2627
return
2728

2829
for ngo_id in target_ngos.values_list("pk", flat=True):
@@ -54,7 +55,7 @@ def clean_ngo(self, ngo_id: int) -> Dict[str, str]:
5455

5556
def clean_ngo_registration_number(self, ngo: Ngo) -> Dict[str, str]:
5657
initial_registration_number = ngo.registration_number
57-
cleaned_registration_number = self._clean_registration_number(initial_registration_number)
58+
cleaned_registration_number = self._clean_up_registration_number(initial_registration_number)
5859

5960
if not re.match(REGISTRATION_NUMBER_REGEX, cleaned_registration_number):
6061
self.stdout.write(
@@ -107,7 +108,7 @@ def clean_ngo_registration_number(self, ngo: Ngo) -> Dict[str, str]:
107108
}
108109

109110
@staticmethod
110-
def _clean_registration_number(reg_num: str) -> Optional[str]:
111+
def _clean_up_registration_number(reg_num: str) -> Optional[str]:
111112
if re.match(REGISTRATION_NUMBER_REGEX, reg_num):
112113
return reg_num
113114

0 commit comments

Comments
 (0)