diff --git a/django_project/minisass_authentication/admin.py b/django_project/minisass_authentication/admin.py index daf5b3fec..dfafe3b48 100644 --- a/django_project/minisass_authentication/admin.py +++ b/django_project/minisass_authentication/admin.py @@ -32,12 +32,22 @@ class UserProfileInline(admin.StackedInline): verbose_name_plural = 'UserProfile' +def correct_country(modeladmin, request, queryset): + for user in queryset: + if user.userprofile: + if user.userprofile.country in ['ZA', 'SA', 'South Africa', '9']: + user.userprofile.country = 'ZA' + user.userprofile.save() +correct_country.short_description = "Correct Country" + + class UserAdmin(BaseUserAdmin): inlines = (UserProfileInline, ) list_filter = ( 'userprofile__expert_approval_status', 'userprofile__is_expert', 'is_staff', 'is_superuser', 'is_active' ) + actions = [correct_country] class PasswordHistoryAdmin(admin.ModelAdmin): diff --git a/django_project/monitor/admin.py b/django_project/monitor/admin.py index cdf003521..17d165804 100644 --- a/django_project/monitor/admin.py +++ b/django_project/monitor/admin.py @@ -1,5 +1,5 @@ -from django.contrib import admin import csv +from django.contrib import admin from django.utils.encoding import smart_str from django.http import HttpResponse from minisass_authentication.models import UserProfile