tildetown-admin/ttadmin/users/admin.py

28 lines
886 B
Python
Raw Normal View History

2016-11-20 05:34:38 +00:00
from django.contrib import admin
2017-01-14 06:22:28 +00:00
from django.contrib.auth.models import User
from django.contrib.auth.models import Group
2017-01-14 06:34:08 +00:00
from .models import Townie, Pubkey
2017-11-09 21:58:57 +00:00
from common.social import post_users_to_social
2016-11-20 05:34:38 +00:00
2017-01-14 06:34:08 +00:00
class PubkeyInline(admin.TabularInline):
model = Pubkey
2017-01-21 09:06:35 +00:00
extra = 1
2017-01-14 06:34:08 +00:00
def bulk_review(madmin, req, qs):
for townie in qs:
townie.reviewed = True
townie.save()
2017-11-09 21:58:57 +00:00
post_users_to_social(qs)
bulk_review.short_description = 'mark selected townies as reviewed'
2016-11-20 05:34:38 +00:00
@admin.register(Townie)
class TownieAdmin(admin.ModelAdmin):
2017-01-14 06:34:08 +00:00
inlines = [PubkeyInline]
2017-01-21 09:06:35 +00:00
list_display = ('username', 'reviewed', 'email')
2017-01-14 22:25:50 +00:00
ordering = ('reviewed',)
2017-11-10 23:00:22 +00:00
exclude = ('first_name', 'last_name', 'password', 'groups', 'user_permissions', 'last_login', 'is_staff', 'is_active', 'is_superuser')
actions = (bulk_review,)
2017-01-21 09:25:02 +00:00
search_fields = ('username', 'email', 'displayname')