el_id = ShortUUIDField(_(u'model_id'), max_length=32, help_text=u'型号唯一标识', db_index=True, unique=True) 126
-    model_name = models.CharField(_(u'model_name'), max_length=255, blank=True, null=True, help_text=u'型号名称')
128
+    model_name = models.CharField(_(u'model_name'), max_length=32, blank=True, null=True, help_text=u'型号名称')
129
+    model_uni_name = models.CharField(_(u'model_uni_name'), max_length=32, blank=True, null=True, help_text=u'型号统一名称')
127 130
     model_full_name = models.CharField(_(u'model_full_name'), max_length=255, blank=True, null=True, help_text=u'型号全名称')
128 131
     model_descr = models.TextField(_(u'model_descr'), max_length=255, blank=True, null=True, help_text=u'型号描述')
129 132
 
133
+    category = models.CharField(_(u'category'), max_length=32, blank=True, null=True, help_text=u'型号类别', db_index=True)
134
+    warehouse = models.CharField(_(u'warehouse'), max_length=32, blank=True, null=True, help_text=u'所属仓库', db_index=True)
135
+
130 136
     image = models.ImageField(_(u'image'), upload_to=upload_path, blank=True, null=True, help_text=u'图片')
131 137
     url = models.CharField(_(u'url'), max_length=255, blank=True, null=True, help_text=u'链接')
132 138
 
@@ -137,6 +143,8 @@ class ModelInfo(BaseModelMixin):
137 143
 
138 144
     position = models.IntegerField(_(u'position'), default=1, help_text=u'排序')
139 145
 
146
+    display = models.BooleanField(_(u'display'), default=True, help_text=_(u'Display'), db_index=True)
147
+
140 148
     class Meta:
141 149
         verbose_name = _(u'型号信息')
142 150
         verbose_name_plural = _(u'型号信息')
@@ -176,9 +184,13 @@ class ModelInfo(BaseModelMixin):
176 184
     @property
177 185
     def admindata(self):
178 186
         return {
187
+            'jancode': self.jancode,
179 188
             'model_id': self.model_id,
180 189
             'model_name': self.model_name,
190
+            'model_uni_name': self.model_uni_name,
181 191
             'model_full_name': self.model_full_name,
192
+            'category': self.category,
193
+            'warehouse': self.warehouse,
182 194
             'image_path': self.image_path,
183 195
             'image_url': self.image_url,
184 196
             'factory_yuan': self.factory_yuan,

BIN
pre/static/models_20180816.xls


+ 45 - 0
pre/views.py

@@ -2,6 +2,10 @@
2 2
 
3 3
 from __future__ import division
4 4
 
5
+import xlrd
6
+from django.conf import settings
7
+from pysnippets.strsnippets import strip
8
+
5 9
 from mch.models import BrandInfo, DistributorInfo, ModelInfo
6 10
 from statistic.models import (ConsumeDistributorSaleStatisticInfo, ConsumeModelSaleStatisticInfo,
7 11
                               ConsumeProvinceSaleStatisticInfo, DistributorSaleStatisticInfo, ModelSaleStatisticInfo,
@@ -91,3 +95,44 @@ def pre_all():
91 95
     pre_provinces()
92 96
     pre_models()
93 97
     pre_distributors()
98
+
99
+
100
+# In [55]: cv
101
+# Out[55]: 991000295147.0
102
+#
103
+# In [56]: str(cv)
104
+# Out[56]: '9.91000295147e+11'
105
+#
106
+# In [57]: repr(cv)
107
+# Out[57]: '991000295147.0'
108
+def convert_to_str(cv):
109
+    if isinstance(cv, (int, float)):
110
+        cv = repr(cv)[:-2] if repr(cv).endswith('.0') else repr(cv)
111
+    if isinstance(cv, str):
112
+        cv = cv.strip()
113
+    return cv
114
+
115
+
116
+def pre_new_models(fpath='./pre/static/models_20180816.xls'):
117
+    workbook = xlrd.open_workbook(fpath)
118
+    # sheet = workbook.sheet_by_name('SMR')
119
+    sheets = workbook.sheets()
120
+    sheet = sheets[0]
121
+    nrows = sheet.nrows
122
+    for idx in range(1, nrows):
123
+        rvals = sheet.row_values(idx)
124
+        print rvals
125
+
126
+        jancode = strip(rvals[0])
127
+        if not jancode:
128
+            continue
129
+
130
+        mdl, _ = ModelInfo.objects.get_or_create(jancode=jancode)
131
+        mdl.brand_id = settings.KODO_DEFAULT_BRAND_ID
132
+        mdl.brand_name = settings.KODO_DEFAULT_BRAND_NAME
133
+        mdl.model_name = strip(rvals[1])
134
+        mdl.model_uni_name = strip(rvals[2])
135
+        mdl.category = strip(rvals[3])
136
+        mdl.model_full_name = strip(rvals[4])
137
+        mdl.warehouse = strip(rvals[5])
138
+        mdl.save()

kodo - Gogs: Go Git Service

Нет описания

0011_auto_20191212_1827.py 1.0KB

    # -*- coding: utf-8 -*- # Generated by Django 1.11.26 on 2019-12-12 10:27 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('member', '0010_auto_20191212_1821'), ] operations = [ migrations.AddField( model_name='couponinfo', name='admin_id', field=models.CharField(blank=True, db_index=True, help_text='\u6838\u9500\u5458\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='admin_id'), ), migrations.AddField( model_name='couponinfo', name='has_used', field=models.BooleanField(db_index=True, default=False, help_text='\u662f\u5426\u5df2\u6838\u9500', verbose_name='has_used'), ), migrations.AddField( model_name='couponinfo', name='used_at', field=models.DateTimeField(blank=True, help_text='\u7ef4\u4fee\u5238\u6838\u9500\u65f6\u95f4', null=True, verbose_name='used_at'), ), ]