1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.utils.translation import ugettext_lazy as _
6 from django.contrib import admin
7 from .models import Offer, Order
10 class OfferAdmin(admin.ModelAdmin):
12 list_display = ['entry', 'price']
13 #~ search_fields = ['entry__title_pl']
16 class PayedFilter(admin.SimpleListFilter):
17 title = _('payment complete')
18 parameter_name = 'payed'
19 def lookups(self, request, model_admin):
24 def queryset(self, request, queryset):
25 if self.value() == 'yes':
26 return queryset.exclude(payed_at=None)
27 elif self.value() == 'no':
28 return queryset.filter(payed_at=None)
30 class OrderAdmin(admin.ModelAdmin):
32 list_display = ['payed_at', 'offer', 'name', 'email']
33 search_fields = ['name', 'email', 'offer']
34 list_filter = [PayedFilter, 'offer']
36 admin.site.register(Offer, OfferAdmin)
37 admin.site.register(Order, OrderAdmin)