2011-11-19 17:02:33 +00:00
|
|
|
from django.contrib.auth.models import User
|
2011-11-19 16:58:59 +00:00
|
|
|
from django.contrib.admin import ModelAdmin
|
|
|
|
from django.contrib.admin.sites import AdminSite
|
|
|
|
|
|
|
|
from regluit.core import models
|
2011-11-30 23:26:41 +00:00
|
|
|
from regluit import payment
|
2011-11-19 16:58:59 +00:00
|
|
|
|
2012-03-30 19:27:35 +00:00
|
|
|
from djcelery.admin import TaskState, WorkerState, TaskMonitor, WorkerMonitor, \
|
|
|
|
IntervalSchedule, CrontabSchedule, PeriodicTask, PeriodicTaskAdmin
|
|
|
|
|
2011-11-19 17:02:33 +00:00
|
|
|
|
2011-11-19 16:58:59 +00:00
|
|
|
class RegluitAdmin(AdminSite):
|
2011-11-19 23:27:15 +00:00
|
|
|
login_template = 'registration/login.html'
|
2011-11-19 16:58:59 +00:00
|
|
|
|
2011-11-19 17:07:44 +00:00
|
|
|
class UserAdmin(ModelAdmin):
|
|
|
|
pass
|
|
|
|
|
2011-11-19 16:58:59 +00:00
|
|
|
class ClaimAdmin(ModelAdmin):
|
|
|
|
date_hierarchy = 'created'
|
|
|
|
|
|
|
|
class RightsHolderAdmin(ModelAdmin):
|
|
|
|
date_hierarchy = 'created'
|
|
|
|
|
|
|
|
class PremiumAdmin(ModelAdmin):
|
|
|
|
date_hierarchy = 'created'
|
|
|
|
|
|
|
|
class CampaignAdmin(ModelAdmin):
|
|
|
|
date_hierarchy = 'created'
|
|
|
|
|
|
|
|
class WorkAdmin(ModelAdmin):
|
|
|
|
search_fields = ('title',)
|
|
|
|
ordering = ('title',)
|
|
|
|
list_display = ('title', 'created')
|
|
|
|
date_hierarchy = 'created'
|
|
|
|
fields = ('title',)
|
|
|
|
|
|
|
|
class AuthorAdmin(ModelAdmin):
|
|
|
|
date_hierarchy = 'created'
|
2011-11-19 20:10:10 +00:00
|
|
|
ordering = ('name',)
|
2011-11-19 16:58:59 +00:00
|
|
|
|
|
|
|
class SubjectAdmin(ModelAdmin):
|
|
|
|
date_hierarchy = 'created'
|
|
|
|
ordering = ('name',)
|
|
|
|
|
|
|
|
class EditionAdmin(ModelAdmin):
|
|
|
|
list_display = ('title', 'publisher', 'created')
|
|
|
|
date_hierarchy = 'created'
|
|
|
|
ordering = ('title',)
|
|
|
|
|
|
|
|
class EbookAdmin(ModelAdmin):
|
|
|
|
date_hierarchy = 'created'
|
|
|
|
ordering = ('edition__title',)
|
|
|
|
|
|
|
|
class WishlistAdmin(ModelAdmin):
|
|
|
|
date_hierarchy = 'created'
|
|
|
|
|
|
|
|
class UserProfileAdmin(ModelAdmin):
|
|
|
|
date_hierarchy = 'created'
|
2012-03-30 19:27:35 +00:00
|
|
|
|
|
|
|
class CeleryTaskAdmin(ModelAdmin):
|
|
|
|
pass
|
2011-11-19 16:58:59 +00:00
|
|
|
|
2011-11-30 23:26:41 +00:00
|
|
|
class TransactionAdmin(ModelAdmin):
|
|
|
|
date_hierarchy = 'date_created'
|
2012-01-03 18:37:20 +00:00
|
|
|
|
|
|
|
class PaymentResponseAdmin(ModelAdmin):
|
|
|
|
pass
|
|
|
|
|
|
|
|
class ReceiverAdmin(ModelAdmin):
|
|
|
|
ordering = ('email',)
|
2011-11-30 23:26:41 +00:00
|
|
|
|
2011-11-19 16:58:59 +00:00
|
|
|
admin_site = RegluitAdmin("Admin")
|
|
|
|
|
2011-11-19 17:34:38 +00:00
|
|
|
admin_site.register(models.User, UserAdmin)
|
2011-11-19 16:58:59 +00:00
|
|
|
admin_site.register(models.Work, WorkAdmin)
|
|
|
|
admin_site.register(models.Claim, ClaimAdmin)
|
|
|
|
admin_site.register(models.RightsHolder, RightsHolderAdmin)
|
|
|
|
admin_site.register(models.Premium, PremiumAdmin)
|
|
|
|
admin_site.register(models.Campaign, CampaignAdmin)
|
|
|
|
admin_site.register(models.Author, AuthorAdmin)
|
|
|
|
admin_site.register(models.Subject, SubjectAdmin)
|
|
|
|
admin_site.register(models.Edition, EditionAdmin)
|
|
|
|
admin_site.register(models.Ebook, EbookAdmin)
|
|
|
|
admin_site.register(models.Wishlist, WishlistAdmin)
|
|
|
|
admin_site.register(models.UserProfile, UserProfileAdmin)
|
2012-03-30 19:27:35 +00:00
|
|
|
admin_site.register(models.CeleryTask, CeleryTaskAdmin)
|
|
|
|
|
|
|
|
# payments
|
|
|
|
|
2011-11-30 23:26:41 +00:00
|
|
|
admin_site.register(payment.models.Transaction, TransactionAdmin)
|
2012-01-03 18:37:20 +00:00
|
|
|
admin_site.register(payment.models.PaymentResponse, PaymentResponseAdmin)
|
|
|
|
admin_site.register(payment.models.Receiver, ReceiverAdmin)
|
2012-03-30 19:27:35 +00:00
|
|
|
|
|
|
|
# add the djcelery admin interface
|
|
|
|
# https://raw.github.com/ask/django-celery/2.4/djcelery/admin.py
|
|
|
|
|
|
|
|
admin_site.register(TaskState, TaskMonitor)
|
|
|
|
admin_site.register(WorkerState, WorkerMonitor)
|
|
|
|
admin_site.register(IntervalSchedule)
|
|
|
|
admin_site.register(CrontabSchedule)
|
|
|
|
admin_site.register(PeriodicTask, PeriodicTaskAdmin)
|