0001-csv_import-do-not-send-creation-email-when-simulatin.patch
src/authentic2/csv_import.py | ||
---|---|---|
369 | 369 |
self._missing_roles = set() |
370 | 370 |
self.csv_importer = CsvImporter() |
371 | 371 |
self.max_user_id = User.objects.aggregate(max=models.Max('id'))['max'] or -1 |
372 |
self.simulate = simulate |
|
372 | 373 | |
373 | 374 |
def parse_csv(): |
374 | 375 |
if not self.csv_importer.run(fd_or_str, encoding): |
... | ... | |
777 | 778 |
return True |
778 | 779 | |
779 | 780 |
def registration_option(self, cell, user): |
780 |
if cell.value == REGISTRATION_RESET_EMAIL: |
|
781 |
if cell.value == REGISTRATION_RESET_EMAIL and not self.simulate:
|
|
781 | 782 |
send_password_reset_mail( |
782 | 783 |
user, |
783 | 784 |
template_names=[ |
tests/test_csv_import.py | ||
---|---|---|
533 | 533 |
content = '''email key,first_name,last_name,@registration |
534 | 534 |
tnoel@entrouvert.com,Thomas,Noël,''' |
535 | 535 | |
536 |
importer = user_csv_importer_factory(content + 'send-email') |
|
537 |
assert importer.run(simulate=True) |
|
536 | 538 |
assert not mail.outbox |
539 | ||
537 | 540 |
importer = user_csv_importer_factory(content + 'send-email') |
538 | 541 |
assert importer.run() |
539 | 542 |
thomas = User.objects.get(email='tnoel@entrouvert.com') |
540 |
- |