# pylint: disable=W0401,W0614, E0102
from django.contrib import admin

from oscar.apps.basket import admin as oscar
from oscar.apps.basket.admin import *  # noqa
from oscar.core.loading import get_model

Basket = get_model("basket", "basket")


class BasketAdmin(oscar.BasketAdmin):
    list_display = (
        "id",
        "get_email",
        "status",
        "num_lines",
        "contains_a_voucher",
        "date_created",
        "date_submitted",
        "time_before_submit",
    )
    search_fields = ("owner__email",)

    def get_email(self, obj):
        if obj.owner is not None:
            return obj.owner.email
        else:
            return "-"


admin.site.unregister(Basket)
admin.site.register(Basket, BasketAdmin)
