Skip to content

Commit

Permalink
Add a success message for successful imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonkagwi committed Feb 6, 2025
1 parent 81ab67e commit 408befd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions apps/odk_publish/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.shortcuts import get_object_or_404, redirect, render
from django.views.decorators.http import require_http_methods
from django.utils.timezone import localdate
from import_export.results import RowResult

from .etl.load import generate_and_save_app_user_collect_qrcodes, sync_central_project
from .forms import ProjectSyncForm, AppUserExportForm, AppUserImportForm
Expand Down Expand Up @@ -198,6 +199,11 @@ def app_user_import(request, odk_project_pk):
form.dataset, use_transactions=True, rollback_on_validation_errors=True
)
if not (result.has_validation_errors() or result.has_errors()):
messages.success(
request,
f"Import finished successfully, with {result.totals[RowResult.IMPORT_TYPE_NEW]} "
f"new and {result.totals[RowResult.IMPORT_TYPE_UPDATE]} updated app users.",
)
return redirect("odk_publish:app-user-list", odk_project_pk=odk_project_pk)
for row in result.invalid_rows:
for field, errors in row.error_dict.items():
Expand Down

0 comments on commit 408befd

Please sign in to comment.