# Path: konfera/admin.py
# class EventAdmin(admin.ModelAdmin):
#     list_display = ('title', 'date_from', 'date_to', 'cfp_end', 'event_type', 'status')
#     list_filter = ('event_type', 'status')
#     ordering = ('date_from', 'date_to', 'title')
#     search_fields = ('=title',)
#     readonly_fields = ('uuid', 'date_created', 'date_modified')
#     fieldsets = (
#         (_('Description'), {
#             'fields': ('title', 'slug', 'organizer', 'description', 'contact_email'),
#         }),
#         (_('Dates'), {
#             'fields': ('date_from', 'date_to', 'cfp_end'),
#         }),
#         (_('Details'), {
#             'fields': ('uuid', 'event_type', 'status', 'location', 'cfp_allowed', 'footer_text', 'analytics'),
#         }),
#         (_('Code of Conduct'), {
#             'fields': ('coc', 'coc_phone', 'coc_phone2'),
#         }),
#         (_('Social media'), {
#             'fields': ('enc_social_media_meta_tags', 'enc_social_media_data'),
#             'classes': ('collapse',),
#         }),
#         (_('Modifications'), {
#             'fields': ('date_created', 'date_modified'),
#             'classes': ('collapse',),
#         }),
#     )
#     inlines = [
#         SponsorshipInline,
#     ]
#     prepopulated_fields = {
#         'slug': ('title',),
#     }
# 
# class OrderAdmin(admin.ModelAdmin):
#     list_display = ('uuid', 'variable_symbol', 'purchase_date', 'price', 'discount', 'processing_fee', 'to_pay',
#                     'status', 'receipt_of')
#     list_filter = ('status', 'purchase_date')
#     ordering = ('-purchase_date',)
#     readonly_fields = [
#         'purchase_date', 'uuid', 'date_created', 'date_modified', 'variable_symbol', 'price', 'discount', 'to_pay',
#         'unpaid_notification_sent_at',
#     ]
#     fieldsets = (
#         (_('Details'), {
#             'fields': ('uuid', 'variable_symbol', 'price', 'discount', 'processing_fee', 'to_pay', 'status',
#                        'amount_paid', 'unpaid_notification_sent_at'),
#         }),
#         (_('Modifications'), {
#             'fields': ('purchase_date', 'payment_date', 'date_created', 'date_modified'),
#             'classes': ('collapse',),
#         }),
#     )
#     inlines = [
#         ReceiptInline, OrderedTicketsInline
#     ]
#     actions = ['make_paid']
# 
#     def get_readonly_fields(self, request, obj=None):
#         if obj and obj.status not in (Order.AWAITING, Order.PARTLY_PAID):
#             return self.readonly_fields + ['amount_paid', 'payment_date', 'processing_fee']
# 
#         return self.readonly_fields
# 
#     def make_paid(self, request, queryset):
#         rows_updated = queryset.update(status=Order.PAID)
#         self.message_user(request, "%s order(s) status updated." % rows_updated)
# 
#     make_paid.short_description = "Mark selected order as paid"


from django.contrib.admin.sites import AdminSite
from django.test import TestCase
from django.utils.translation import ugettext_lazy as _
from konfera.admin import EventAdmin, OrderAdmin
from konfera.models import Event, Order

class ModelAdminTests(TestCase):
    fixtures = ['test_data.json']

    def setUp(self):
        self.site = AdminSite()

    def test_default_fields(self):
        ev = EventAdmin(Event, self.site)
        event = Event.objects.get(title='PyCon SK 2016')
        ev_default_fields = ['date_from', 'date_to', 'title', 'slug', 'description', 'event_type', 'status',
                             'location', 'organizer', 'sponsors', 'footer_text', 'analytics',
                             'enc_social_media_meta_tags', 'enc_social_media_data', 'cfp_allowed', 'cfp_end',
                             'contact_email', 'coc', 'coc_phone', 'coc_phone2', 'uuid', 'date_created',
                             'date_modified']

        self.assertEqual(list(ev.get_fields(request)), ev_default_fields)
        self.assertEqual(list(ev.get_fields(request, event)), ev_default_fields)

        ordr = OrderAdmin(Order, self.site)
        # order = Event.objects.get(uuid='PyCon SK 2016')
        ordr_default_fields = [
            'amount_paid', 'processing_fee', 'status', 'payment_date', 'unpaid_notification_sent_amount',
            'purchase_date', 'uuid', 'date_created', 'date_modified', 'variable_symbol', 'price', 'discount', 'to_pay',
            'unpaid_notification_sent_at']

        self.assertEqual(list(ordr.get_fields(request)), ordr_default_fields)
        # self.assertEqual(list(ordr.get_fields(request, order)), ordr_default_fields)

    def test_default_fieldsets(self):

# Path: konfera/admin.py
# class EventAdmin(admin.ModelAdmin):
#     list_display = ('title', 'date_from', 'date_to', 'cfp_end', 'event_type', 'status')
#     list_filter = ('event_type', 'status')
#     ordering = ('date_from', 'date_to', 'title')
#     search_fields = ('=title',)
#     readonly_fields = ('uuid', 'date_created', 'date_modified')
#     fieldsets = (
#         (_('Description'), {
#             'fields': ('title', 'slug', 'organizer', 'description', 'contact_email'),
#         }),
#         (_('Dates'), {
#             'fields': ('date_from', 'date_to', 'cfp_end'),
#         }),
#         (_('Details'), {
#             'fields': ('uuid', 'event_type', 'status', 'location', 'cfp_allowed', 'footer_text', 'analytics'),
#         }),
#         (_('Code of Conduct'), {
#             'fields': ('coc', 'coc_phone', 'coc_phone2'),
#         }),
#         (_('Social media'), {
#             'fields': ('enc_social_media_meta_tags', 'enc_social_media_data'),
#             'classes': ('collapse',),
#         }),
#         (_('Modifications'), {
#             'fields': ('date_created', 'date_modified'),
#             'classes': ('collapse',),
#         }),
#     )
#     inlines = [
#         SponsorshipInline,
#     ]
#     prepopulated_fields = {
#         'slug': ('title',),
#     }
# 
# class OrderAdmin(admin.ModelAdmin):
#     list_display = ('uuid', 'variable_symbol', 'purchase_date', 'price', 'discount', 'processing_fee', 'to_pay',
#                     'status', 'receipt_of')
#     list_filter = ('status', 'purchase_date')
#     ordering = ('-purchase_date',)
#     readonly_fields = [
#         'purchase_date', 'uuid', 'date_created', 'date_modified', 'variable_symbol', 'price', 'discount', 'to_pay',
#         'unpaid_notification_sent_at',
#     ]
#     fieldsets = (
#         (_('Details'), {
#             'fields': ('uuid', 'variable_symbol', 'price', 'discount', 'processing_fee', 'to_pay', 'status',
#                        'amount_paid', 'unpaid_notification_sent_at'),
#         }),
#         (_('Modifications'), {
#             'fields': ('purchase_date', 'payment_date', 'date_created', 'date_modified'),
#             'classes': ('collapse',),
#         }),
#     )
#     inlines = [
#         ReceiptInline, OrderedTicketsInline
#     ]
#     actions = ['make_paid']
# 
#     def get_readonly_fields(self, request, obj=None):
#         if obj and obj.status not in (Order.AWAITING, Order.PARTLY_PAID):
#             return self.readonly_fields + ['amount_paid', 'payment_date', 'processing_fee']
# 
#         return self.readonly_fields
# 
#     def make_paid(self, request, queryset):
#         rows_updated = queryset.update(status=Order.PAID)
#         self.message_user(request, "%s order(s) status updated." % rows_updated)
# 
#     make_paid.short_description = "Mark selected order as paid"


# Path: konfera/tests/test_admin.py
from django.contrib.admin.sites import AdminSite
from django.test import TestCase
from django.utils.translation import ugettext_lazy as _
from konfera.admin import EventAdmin, OrderAdmin
from konfera.models import Event, Order


class ModelAdminTests(TestCase):
    fixtures = ['test_data.json']

    def setUp(self):
        self.site = AdminSite()

    def test_default_fields(self):
        ev = EventAdmin(Event, self.site)
        event = Event.objects.get(title='PyCon SK 2016')
        ev_default_fields = ['date_from', 'date_to', 'title', 'slug', 'description', 'event_type', 'status',
                             'location', 'organizer', 'sponsors', 'footer_text', 'analytics',
                             'enc_social_media_meta_tags', 'enc_social_media_data', 'cfp_allowed', 'cfp_end',
                             'contact_email', 'coc', 'coc_phone', 'coc_phone2', 'uuid', 'date_created',
                             'date_modified']

        self.assertEqual(list(ev.get_fields(request)), ev_default_fields)
        self.assertEqual(list(ev.get_fields(request, event)), ev_default_fields)

        ordr = OrderAdmin(Order, self.site)
        # order = Event.objects.get(uuid='PyCon SK 2016')
        ordr_default_fields = [
            'amount_paid', 'processing_fee', 'status', 'payment_date', 'unpaid_notification_sent_amount',
            'purchase_date', 'uuid', 'date_created', 'date_modified', 'variable_symbol', 'price', 'discount', 'to_pay',
            'unpaid_notification_sent_at']

        self.assertEqual(list(ordr.get_fields(request)), ordr_default_fields)
        # self.assertEqual(list(ordr.get_fields(request, order)), ordr_default_fields)

    def test_default_fieldsets(self):

        ev = EventAdmin(Event, self.site)