# -*- coding: utf-8 -*-
from __future__ import absolute_import
from import_export import resources
from import_export.fields import Field
from apps.base import Formater
from apps.order.models import Order
from utils.format import strftime,strfdate


class OrderResource(resources.ModelResource):

    def dehydrate_total_amount(self, instance):
        return Formater.formatPriceShow(instance.total_amount)

    def get_export_headers(self):
        return [u'订单号', u'餐费名称', u'费用', u'下单时间',  u'学生姓名', u'班级', u'年级', ]

    class Meta:
        model = Order
        fields = ('no', 'name', 'total_amount', 'create_time', 'student__name',
                  'student__classes__name','student__classes__grade__name',) # 支持外键__方式访问
        export_order = fields
