Mercurial > public > sg101
diff accounts/admin.py @ 581:ee87ea74d46b
For Django 1.4, rearranged project structure for new manage.py.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sat, 05 May 2012 17:10:48 -0500 |
parents | gpp/accounts/admin.py@d1b11096595b |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/accounts/admin.py Sat May 05 17:10:48 2012 -0500 @@ -0,0 +1,29 @@ +"""This file contains the automatic admin site definitions for the accounts Models""" + +from django.contrib import admin +from accounts.models import IllegalUsername +from accounts.models import IllegalEmail +from accounts.models import PendingUser +from accounts import create_new_user + + +class PendingUserAdmin(admin.ModelAdmin): + list_display = ('username', 'email', 'date_joined') + actions = ('activate_account', ) + + def activate_account(self, request, qs): + """ + Activate the accounts of the selected pending users. + + """ + for pending_user in qs: + create_new_user(pending_user, admin_activation=True) + + self.message_user(request, "%s accounts activated" % qs.count()) + + activate_account.short_description = "Activate accounts for selected users" + + +admin.site.register(IllegalUsername) +admin.site.register(IllegalEmail) +admin.site.register(PendingUser, PendingUserAdmin)