files.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. from rest_framework_csv.renderers import CSVStreamingRenderer
  2. def file_headers():
  3. return [
  4. 'goods_code',
  5. 'goods_desc',
  6. 'goods_supplier',
  7. 'goods_weight',
  8. 'goods_w',
  9. 'goods_d',
  10. 'goods_h',
  11. 'unit_volume',
  12. 'goods_unit',
  13. 'goods_class',
  14. 'goods_brand',
  15. 'goods_color',
  16. 'goods_shape',
  17. 'goods_specs',
  18. 'goods_origin',
  19. 'goods_cost',
  20. 'goods_price',
  21. 'creater',
  22. 'create_time',
  23. 'update_time'
  24. ]
  25. def cn_data_header():
  26. return dict([
  27. ('goods_code', u'商品编码'),
  28. ('goods_desc', u'商品描述'),
  29. ('goods_supplier', u'商品供应商'),
  30. ('goods_weight', u'商品单位重量'),
  31. ('goods_w', u'商品单位长度'),
  32. ('goods_d', u'商品单位宽度'),
  33. ('goods_h', u'商品单位高度'),
  34. ('unit_volume', u'最小单位体积'),
  35. ('goods_unit', u'商品单位'),
  36. ('goods_class', u'商品类别'),
  37. ('goods_brand', u'商品品牌'),
  38. ('goods_color', u'商品颜色'),
  39. ('goods_shape', u'商品形状'),
  40. ('goods_specs', u'商品规格'),
  41. ('goods_origin', u'商品产地'),
  42. ('goods_cost', u'商品成本'),
  43. ('goods_price', u'商品价格'),
  44. ('creater', u'创建人'),
  45. ('create_time', u'创建时间'),
  46. ('update_time', u'更新时间')
  47. ])
  48. def en_data_header():
  49. return dict([
  50. ('goods_code', u'Goods Code'),
  51. ('goods_desc', u'Goods Description'),
  52. ('goods_supplier', u'Goods Supplier'),
  53. ('goods_weight', u'Goods Weight'),
  54. ('goods_w', u'Goods Wide'),
  55. ('goods_d', u'Goods Depth'),
  56. ('goods_h', u'Goods Height'),
  57. ('unit_volume', u'Unit Volume'),
  58. ('goods_unit', u'Goods Unit'),
  59. ('goods_class', u'Goods Class'),
  60. ('goods_brand', u'Goods Brand'),
  61. ('goods_color', u'Goods Color'),
  62. ('goods_shape', u'Goods Shape'),
  63. ('goods_specs', u'Goods Specs'),
  64. ('goods_origin', u'Goods Origin'),
  65. ('goods_cost', u'Goods Cost'),
  66. ('goods_price', u'Goods Price'),
  67. ('creater', u'Creater'),
  68. ('create_time', u'Create Time'),
  69. ('update_time', u'Update Time')
  70. ])
  71. class FileRenderCN(CSVStreamingRenderer):
  72. header = file_headers()
  73. labels = cn_data_header()
  74. class FileRenderEN(CSVStreamingRenderer):
  75. header = file_headers()
  76. labels = en_data_header()