-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.py
50 lines (40 loc) · 1.74 KB
/
admin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from django.contrib import admin
from django.contrib.sites.models import RequestSite
from django.contrib.sites.models import Site
from django.utils.translation import ugettext_lazy as _
from registration.backends.token.models import InvitationCode
def mark_issued(modeladmin, request, queryset):
queryset.update(is_issued=True)
mark_issued.short_description = "Mark selected codes as 'issued'"
class InvitationCodeAdmin(admin.ModelAdmin):
actions = [mark_issued]
list_display = ('code', 'is_issued', 'is_used')
#raw_id_fields = ['user']
#search_fields = ('user__username', 'user__first_name', 'user__last_name')
#def activate_users(self, request, queryset):
# """
# Activates the selected users, if they are not alrady
# activated.
#
# """
# for profile in queryset:
# RegistrationProfile.objects.activate_user(profile.activation_key)
#activate_users.short_description = _("Activate users")
#def resend_activation_email(self, request, queryset):
# """
# Re-sends activation emails for the selected users.
# Note that this will *only* send activation emails for users
# who are eligible to activate; emails will not be sent to users
# whose activation keys have expired or who have already
# activated.
# """
# if Site._meta.installed:
# site = Site.objects.get_current()
# else:
# site = RequestSite(request)
# for profile in queryset:
# if not profile.activation_key_expired():
# profile.send_activation_email(site)
#resend_activation_email.short_description = _("Re-send activation emails")
pass
admin.site.register(InvitationCode, InvitationCodeAdmin)