annotate accounts/admin.py @ 943:cf9918328c64

Haystack tweaks for Django 1.7.7. I had to upgrade to Haystack 2.3.1 to get it to work with Django 1.7.7. I also had to update the Xapian backend. But I ran into problems. On my laptop anyway (Ubuntu 14.0.4), xapian gets mad when search terms are greater than 245 chars (or something) when indexing. So I created a custom field that would simply omit terms greater than 64 chars and used this field everywhere I previously used a CharField. Secondly, the custom search form was broken now. Something changed in the Xapian backend and exact searches stopped working. Fortunately the auto_query (which I was using originally and broke during an upgrade) started working again. So I cut the search form back over to doing an auto_query. I kept the form the same (3 fields) because I didn't want to change the form and I think it's better that way.
author Brian Neal <bgneal@gmail.com>
date Wed, 13 May 2015 20:25:07 -0500
parents ee87ea74d46b
children
rev   line source
gremmie@1 1 """This file contains the automatic admin site definitions for the accounts Models"""
gremmie@1 2
gremmie@1 3 from django.contrib import admin
gremmie@1 4 from accounts.models import IllegalUsername
gremmie@1 5 from accounts.models import IllegalEmail
gremmie@1 6 from accounts.models import PendingUser
bgneal@347 7 from accounts import create_new_user
bgneal@347 8
gremmie@1 9
gremmie@1 10 class PendingUserAdmin(admin.ModelAdmin):
gremmie@1 11 list_display = ('username', 'email', 'date_joined')
bgneal@347 12 actions = ('activate_account', )
bgneal@347 13
bgneal@347 14 def activate_account(self, request, qs):
bgneal@347 15 """
bgneal@347 16 Activate the accounts of the selected pending users.
bgneal@347 17
bgneal@347 18 """
bgneal@347 19 for pending_user in qs:
bgneal@347 20 create_new_user(pending_user, admin_activation=True)
bgneal@347 21
bgneal@348 22 self.message_user(request, "%s accounts activated" % qs.count())
bgneal@348 23
bgneal@347 24 activate_account.short_description = "Activate accounts for selected users"
bgneal@347 25
gremmie@1 26
gremmie@1 27 admin.site.register(IllegalUsername)
gremmie@1 28 admin.site.register(IllegalEmail)
gremmie@1 29 admin.site.register(PendingUser, PendingUserAdmin)