@@ -1,5 +1,6 @@ |
||
| 1 | 1 |
# -*- coding: utf-8 -*- |
| 2 | 2 |
|
| 3 |
+import monetary |
|
| 3 | 4 |
from django.conf import settings |
| 4 | 5 |
from django.contrib import admin |
| 5 | 6 |
from django.contrib.auth.hashers import make_password |
@@ -7,8 +8,29 @@ from django_admin import DeleteModelAdmin, ReadOnlyModelAdmin |
||
| 7 | 8 |
from django_models_ext import ProvinceShortModelMixin |
| 8 | 9 |
from pysnippets.strsnippets import strip |
| 9 | 10 |
|
| 10 |
-from mch.models import (BrandInfo, ConsumeInfoSubmitLogInfo, DistributorInfo, LatestAppInfo, ModelImageInfo, ModelInfo, |
|
| 11 |
- OperatorInfo) |
|
| 11 |
+from mch.models import (AdministratorInfo, BrandInfo, BrandModelDistributorPriceInfo, ConsumeInfoSubmitLogInfo, |
|
| 12 |
+ DistributorInfo, LatestAppInfo, ModelImageInfo, ModelInfo, OperatorInfo) |
|
| 13 |
+ |
|
| 14 |
+ |
|
| 15 |
+class AdministratorInfoAdmin(DeleteModelAdmin, admin.ModelAdmin): |
|
| 16 |
+ list_display = ('admin_id', 'phone', 'password', 'encryption', 'name', 'brand_id', 'brand_name', 'user_status', 'status', 'created_at', 'updated_at')
|
|
| 17 |
+ list_filter = ('user_status', 'status', 'brand_name')
|
|
| 18 |
+ readonly_fields = ('encryption', 'brand_name')
|
|
| 19 |
+ |
|
| 20 |
+ def save_model(self, request, obj, form, change): |
|
| 21 |
+ obj.phone = strip(obj.phone) |
|
| 22 |
+ obj.password = strip(obj.password) |
|
| 23 |
+ if obj.password: |
|
| 24 |
+ obj.encryption = make_password(obj.password, settings.MAKE_PASSWORD_SALT, settings.MAKE_PASSWORD_HASHER) |
|
| 25 |
+ obj.password = '' |
|
| 26 |
+ |
|
| 27 |
+ obj.brand_id = strip(obj.brand_id) |
|
| 28 |
+ try: |
|
| 29 |
+ obj.brand_name = BrandInfo.objects.get(brand_id=obj.brand_id).brand_name |
|
| 30 |
+ except BrandInfo.DoesNotExist: |
|
| 31 |
+ obj.brand_name = '' |
|
| 32 |
+ |
|
| 33 |
+ obj.save() |
|
| 12 | 34 |
|
| 13 | 35 |
|
| 14 | 36 |
class OperatorInfoAdmin(DeleteModelAdmin, admin.ModelAdmin): |
@@ -37,8 +59,10 @@ class BrandInfoAdmin(DeleteModelAdmin, admin.ModelAdmin): |
||
| 37 | 59 |
|
| 38 | 60 |
|
| 39 | 61 |
class ModelInfoAdmin(DeleteModelAdmin, admin.ModelAdmin): |
| 40 |
- list_display = ('brand_id', 'brand_name', 'model_id', 'model_name', 'model_full_name', 'model_descr', 'image', 'url', 'integral', 'position', 'status', 'created_at', 'updated_at')
|
|
| 62 |
+ list_display = ('brand_id', 'brand_name', 'model_id', 'model_name', 'model_full_name', 'model_descr', 'image', 'url', 'factory_yuan', 'integral', 'position', 'status', 'created_at', 'updated_at')
|
|
| 41 | 63 |
list_filter = ('brand_name', 'status')
|
| 64 |
+ readonly_fields = ('brand_name', 'factory_fee')
|
|
| 65 |
+ search_fields = ('brand_id', 'brand_name', 'model_id', 'model_name', 'model_full_name', 'model_descr')
|
|
| 42 | 66 |
|
| 43 | 67 |
def save_model(self, request, obj, form, change): |
| 44 | 68 |
obj.brand_id = strip(obj.brand_id) |
@@ -47,6 +71,9 @@ class ModelInfoAdmin(DeleteModelAdmin, admin.ModelAdmin): |
||
| 47 | 71 |
except BrandInfo.DoesNotExist: |
| 48 | 72 |
obj.brand_name = '' |
| 49 | 73 |
|
| 74 |
+ obj.factory_fee = monetary.Yuan2Fen(obj.factory_yuan) |
|
| 75 |
+ obj.factory_yuan = monetary.Fen2Yuan(obj.factory_fee) |
|
| 76 |
+ |
|
| 50 | 77 |
obj.save() |
| 51 | 78 |
|
| 52 | 79 |
|
@@ -67,7 +94,7 @@ class ModelImageInfoAdmin(DeleteModelAdmin, admin.ModelAdmin): |
||
| 67 | 94 |
class DistributorInfoAdmin(DeleteModelAdmin, admin.ModelAdmin): |
| 68 | 95 |
list_display = ('brand_id', 'brand_name', 'distributor_id', 'distributor_name', 'distributor_province_name', 'position', 'status', 'created_at', 'updated_at')
|
| 69 | 96 |
list_filter = ('brand_name', 'distributor_province_name', 'status')
|
| 70 |
- readonly_fields = ('distributor_province_code', )
|
|
| 97 |
+ readonly_fields = ('brand_name', 'distributor_province_code')
|
|
| 71 | 98 |
search_fields = ('brand_id', 'brand_name', 'distributor_name', 'distributor_descr', 'distributor_province_code', 'distributor_province_name')
|
| 72 | 99 |
|
| 73 | 100 |
def save_model(self, request, obj, form, change): |
@@ -82,6 +109,37 @@ class DistributorInfoAdmin(DeleteModelAdmin, admin.ModelAdmin): |
||
| 82 | 109 |
obj.save() |
| 83 | 110 |
|
| 84 | 111 |
|
| 112 |
+class BrandModelDistributorPriceInfoAdmin(DeleteModelAdmin, admin.ModelAdmin): |
|
| 113 |
+ list_display = ('brand_id', 'brand_name', 'model_id', 'model_name', 'distributor_id', 'distributor_name', 'factory_yuan', 'integral', 'status', 'created_at', 'updated_at')
|
|
| 114 |
+ list_filter = ('brand_name', 'model_name', 'distributor_name', 'status')
|
|
| 115 |
+ readonly_fields = ('brand_name', 'model_name', 'distributor_name', 'factory_fee', )
|
|
| 116 |
+ search_fields = ('brand_id', 'brand_name', 'model_id', 'model_name', 'distributor_id', 'distributor_name')
|
|
| 117 |
+ |
|
| 118 |
+ def save_model(self, request, obj, form, change): |
|
| 119 |
+ obj.brand_id = strip(obj.brand_id) |
|
| 120 |
+ try: |
|
| 121 |
+ obj.brand_name = BrandInfo.objects.get(brand_id=obj.brand_id).brand_name |
|
| 122 |
+ except BrandInfo.DoesNotExist: |
|
| 123 |
+ obj.brand_name = '' |
|
| 124 |
+ |
|
| 125 |
+ obj.model_id = strip(obj.model_id) |
|
| 126 |
+ try: |
|
| 127 |
+ obj.model_name = ModelInfo.objects.get(model_id=obj.model_id).model_name |
|
| 128 |
+ except BrandInfo.DoesNotExist: |
|
| 129 |
+ obj.model_name = '' |
|
| 130 |
+ |
|
| 131 |
+ obj.distributor_id = strip(obj.distributor_id) |
|
| 132 |
+ try: |
|
| 133 |
+ obj.distributor_name = DistributorInfo.objects.get(distributor_id=obj.distributor_id).distributor_name |
|
| 134 |
+ except BrandInfo.DoesNotExist: |
|
| 135 |
+ obj.distributor_name = '' |
|
| 136 |
+ |
|
| 137 |
+ obj.factory_fee = monetary.Yuan2Fen(obj.factory_yuan) |
|
| 138 |
+ obj.factory_yuan = monetary.Fen2Yuan(obj.factory_fee) |
|
| 139 |
+ |
|
| 140 |
+ obj.save() |
|
| 141 |
+ |
|
| 142 |
+ |
|
| 85 | 143 |
class LatestAppInfoAdmin(admin.ModelAdmin): |
| 86 | 144 |
list_display = ('latest_adr_version_code', 'latest_adr_version_name', 'latest_adr_app', 'latest_adr_url', 'status', 'created_at', 'updated_at')
|
| 87 | 145 |
list_filter = ('status', )
|
@@ -101,10 +159,12 @@ class ConsumeInfoSubmitLogInfoAdmin(ReadOnlyModelAdmin, admin.ModelAdmin): |
||
| 101 | 159 |
list_filter = ('test_user', 'verifyResult', 'status')
|
| 102 | 160 |
|
| 103 | 161 |
|
| 162 |
+admin.site.register(AdministratorInfo, AdministratorInfoAdmin) |
|
| 104 | 163 |
admin.site.register(OperatorInfo, OperatorInfoAdmin) |
| 105 | 164 |
admin.site.register(BrandInfo, BrandInfoAdmin) |
| 106 | 165 |
admin.site.register(ModelInfo, ModelInfoAdmin) |
| 107 | 166 |
# admin.site.register(ModelImageInfo, ModelImageInfoAdmin) |
| 108 | 167 |
admin.site.register(DistributorInfo, DistributorInfoAdmin) |
| 168 |
+admin.site.register(BrandModelDistributorPriceInfo, BrandModelDistributorPriceInfoAdmin) |
|
| 109 | 169 |
admin.site.register(LatestAppInfo, LatestAppInfoAdmin) |
| 110 | 170 |
admin.site.register(ConsumeInfoSubmitLogInfo, ConsumeInfoSubmitLogInfoAdmin) |
@@ -0,0 +1,47 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+# Generated by Django 1.11.11 on 2018-05-08 06:33 |
|
| 3 |
+from __future__ import unicode_literals |
|
| 4 |
+ |
|
| 5 |
+from django.db import migrations, models |
|
| 6 |
+import shortuuidfield.fields |
|
| 7 |
+ |
|
| 8 |
+ |
|
| 9 |
+class Migration(migrations.Migration): |
|
| 10 |
+ |
|
| 11 |
+ dependencies = [ |
|
| 12 |
+ ('mch', '0014_auto_20180508_1058'),
|
|
| 13 |
+ ] |
|
| 14 |
+ |
|
| 15 |
+ operations = [ |
|
| 16 |
+ migrations.CreateModel( |
|
| 17 |
+ name='AdministratorInfo', |
|
| 18 |
+ fields=[ |
|
| 19 |
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
| 20 |
+ ('status', models.BooleanField(db_index=True, default=True, help_text='Status', verbose_name='status')),
|
|
| 21 |
+ ('created_at', models.DateTimeField(auto_now_add=True, help_text='Create Time', verbose_name='created_at')),
|
|
| 22 |
+ ('updated_at', models.DateTimeField(auto_now=True, help_text='Update Time', verbose_name='updated_at')),
|
|
| 23 |
+ ('admin_id', shortuuidfield.fields.ShortUUIDField(blank=True, db_index=True, editable=False, help_text='\u7ba1\u7406\u5458\u552f\u4e00\u6807\u8bc6', max_length=22, null=True, unique=True)),
|
|
| 24 |
+ ('phone', models.CharField(blank=True, db_index=True, help_text='\u7ba1\u7406\u5458\u7535\u8bdd', max_length=16, null=True, verbose_name='phone')),
|
|
| 25 |
+ ('password', models.CharField(blank=True, help_text='\u7ba1\u7406\u5458\u5bc6\u7801', max_length=255, null=True, verbose_name='password')),
|
|
| 26 |
+ ('encryption', models.CharField(blank=True, help_text='\u7ba1\u7406\u5458\u5bc6\u7801', max_length=255, null=True, verbose_name='encryption')),
|
|
| 27 |
+ ('name', models.CharField(blank=True, help_text='\u7ba1\u7406\u5458\u59d3\u540d', max_length=255, null=True, verbose_name='name')),
|
|
| 28 |
+ ('brand_id', models.CharField(blank=True, db_index=True, help_text='\u54c1\u724c\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='brand_id')),
|
|
| 29 |
+ ('brand_name', models.CharField(blank=True, help_text='\u54c1\u724c\u540d\u79f0', max_length=255, null=True, verbose_name='brand_name')),
|
|
| 30 |
+ ('user_status', models.IntegerField(choices=[(1, '\u5df2\u6fc0\u6d3b'), (2, '\u5df2\u7981\u7528')], db_index=True, default=1, help_text='\u7ba1\u7406\u5458\u72b6\u6001', verbose_name='user_status')),
|
|
| 31 |
+ ], |
|
| 32 |
+ options={
|
|
| 33 |
+ 'verbose_name': '\u7ba1\u7406\u5458\u4fe1\u606f', |
|
| 34 |
+ 'verbose_name_plural': '\u7ba1\u7406\u5458\u4fe1\u606f', |
|
| 35 |
+ }, |
|
| 36 |
+ ), |
|
| 37 |
+ migrations.AddField( |
|
| 38 |
+ model_name='modelinfo', |
|
| 39 |
+ name='factory_fee', |
|
| 40 |
+ field=models.IntegerField(default=100000, help_text='\u51fa\u5382\u4ef7(\u5206)', verbose_name='factory_fee'), |
|
| 41 |
+ ), |
|
| 42 |
+ migrations.AddField( |
|
| 43 |
+ model_name='modelinfo', |
|
| 44 |
+ name='factory_yuan', |
|
| 45 |
+ field=models.FloatField(default=1000, help_text='\u51fa\u5382\u4ef7(\u5143)', verbose_name='factory_yuan'), |
|
| 46 |
+ ), |
|
| 47 |
+ ] |
@@ -0,0 +1,41 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+# Generated by Django 1.11.11 on 2018-05-08 07:07 |
|
| 3 |
+from __future__ import unicode_literals |
|
| 4 |
+ |
|
| 5 |
+from django.db import migrations, models |
|
| 6 |
+ |
|
| 7 |
+ |
|
| 8 |
+class Migration(migrations.Migration): |
|
| 9 |
+ |
|
| 10 |
+ dependencies = [ |
|
| 11 |
+ ('mch', '0015_auto_20180508_1433'),
|
|
| 12 |
+ ] |
|
| 13 |
+ |
|
| 14 |
+ operations = [ |
|
| 15 |
+ migrations.CreateModel( |
|
| 16 |
+ name='BrandModelDistributorPriceInfo', |
|
| 17 |
+ fields=[ |
|
| 18 |
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
| 19 |
+ ('status', models.BooleanField(db_index=True, default=True, help_text='Status', verbose_name='status')),
|
|
| 20 |
+ ('created_at', models.DateTimeField(auto_now_add=True, help_text='Create Time', verbose_name='created_at')),
|
|
| 21 |
+ ('updated_at', models.DateTimeField(auto_now=True, help_text='Update Time', verbose_name='updated_at')),
|
|
| 22 |
+ ('brand_id', models.CharField(blank=True, db_index=True, help_text='\u54c1\u724c\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='brand_id')),
|
|
| 23 |
+ ('brand_name', models.CharField(blank=True, help_text='\u54c1\u724c\u540d\u79f0', max_length=255, null=True, verbose_name='brand_name')),
|
|
| 24 |
+ ('model_id', models.CharField(blank=True, db_index=True, help_text='\u578b\u53f7\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='model_id')),
|
|
| 25 |
+ ('model_name', models.CharField(blank=True, help_text='\u578b\u53f7\u540d\u79f0', max_length=255, null=True, verbose_name='model_name')),
|
|
| 26 |
+ ('distributor_id', models.CharField(blank=True, db_index=True, help_text='\u7ecf\u9500\u5546\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='distributor_id')),
|
|
| 27 |
+ ('distributor_name', models.CharField(blank=True, help_text='\u7ecf\u9500\u5546\u540d\u79f0', max_length=255, null=True, verbose_name='distributor_name')),
|
|
| 28 |
+ ('factory_yuan', models.FloatField(default=1000, help_text='\u51fa\u5382\u4ef7(\u5143)', verbose_name='factory_yuan')),
|
|
| 29 |
+ ('factory_fee', models.IntegerField(default=100000, help_text='\u51fa\u5382\u4ef7(\u5206)', verbose_name='factory_fee')),
|
|
| 30 |
+ ('integral', models.IntegerField(default=100, help_text='\u79ef\u5206', verbose_name='integral')),
|
|
| 31 |
+ ], |
|
| 32 |
+ options={
|
|
| 33 |
+ 'verbose_name': '\u578b\u53f7/\u4ee3\u7406\u5546\u4ef7\u683c\u4fe1\u606f', |
|
| 34 |
+ 'verbose_name_plural': '\u578b\u53f7/\u4ee3\u7406\u5546\u4ef7\u683c\u4fe1\u606f', |
|
| 35 |
+ }, |
|
| 36 |
+ ), |
|
| 37 |
+ migrations.AlterUniqueTogether( |
|
| 38 |
+ name='brandmodeldistributorpriceinfo', |
|
| 39 |
+ unique_together=set([('brand_id', 'model_id', 'distributor_id')]),
|
|
| 40 |
+ ), |
|
| 41 |
+ ] |
@@ -6,6 +6,36 @@ from django_models_ext import BaseModelMixin, ProvinceShortModelMixin, upload_fi |
||
| 6 | 6 |
from shortuuidfield import ShortUUIDField |
| 7 | 7 |
|
| 8 | 8 |
|
| 9 |
+class AdministratorInfo(BaseModelMixin): |
|
| 10 |
+ ACTIVATED = 1 |
|
| 11 |
+ DISABLED = 2 |
|
| 12 |
+ |
|
| 13 |
+ USER_STATUS_TUPLE = ( |
|
| 14 |
+ (ACTIVATED, u'已激活'), |
|
| 15 |
+ (DISABLED, u'已禁用'), |
|
| 16 |
+ ) |
|
| 17 |
+ |
|
| 18 |
+ admin_id = ShortUUIDField(_(u'admin_id'), max_length=32, blank=True, null=True, help_text=u'管理员唯一标识', db_index=True, unique=True) |
|
| 19 |
+ |
|
| 20 |
+ phone = models.CharField(_(u'phone'), max_length=16, blank=True, null=True, help_text=u'管理员电话', db_index=True) |
|
| 21 |
+ password = models.CharField(_(u'password'), max_length=255, blank=True, null=True, help_text=u'管理员密码') |
|
| 22 |
+ encryption = models.CharField(_(u'encryption'), max_length=255, blank=True, null=True, help_text=u'管理员密码') |
|
| 23 |
+ |
|
| 24 |
+ name = models.CharField(_(u'name'), max_length=255, blank=True, null=True, help_text=u'管理员姓名') |
|
| 25 |
+ |
|
| 26 |
+ brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True) |
|
| 27 |
+ brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称') |
|
| 28 |
+ |
|
| 29 |
+ user_status = models.IntegerField(_(u'user_status'), choices=USER_STATUS_TUPLE, default=ACTIVATED, help_text=u'管理员状态', db_index=True) |
|
| 30 |
+ |
|
| 31 |
+ class Meta: |
|
| 32 |
+ verbose_name = _(u'管理员信息') |
|
| 33 |
+ verbose_name_plural = _(u'管理员信息') |
|
| 34 |
+ |
|
| 35 |
+ def __unicode__(self): |
|
| 36 |
+ return u'{}-{}'.format(self.name, self.phone)
|
|
| 37 |
+ |
|
| 38 |
+ |
|
| 9 | 39 |
class OperatorInfo(BaseModelMixin): |
| 10 | 40 |
ACTIVATED = 1 |
| 11 | 41 |
DISABLED = 2 |
@@ -77,6 +107,9 @@ class ModelInfo(BaseModelMixin): |
||
| 77 | 107 |
image = models.ImageField(_(u'image'), upload_to=upload_path, blank=True, null=True, help_text=u'图片') |
| 78 | 108 |
url = models.CharField(_(u'url'), max_length=255, blank=True, null=True, help_text=u'链接') |
| 79 | 109 |
|
| 110 |
+ factory_yuan = models.FloatField(_(u'factory_yuan'), default=1000, help_text=u'出厂价(元)') |
|
| 111 |
+ factory_fee = models.IntegerField(_(u'factory_fee'), default=100000, help_text=u'出厂价(分)') |
|
| 112 |
+ |
|
| 80 | 113 |
integral = models.IntegerField(_(u'integral'), default=100, help_text=u'积分') |
| 81 | 114 |
|
| 82 | 115 |
position = models.IntegerField(_(u'position'), default=1, help_text=u'排序') |
@@ -171,6 +204,32 @@ class DistributorInfo(BaseModelMixin): |
||
| 171 | 204 |
} |
| 172 | 205 |
|
| 173 | 206 |
|
| 207 |
+class BrandModelDistributorPriceInfo(BaseModelMixin): |
|
| 208 |
+ brand_id = models.CharField(_(u'brand_id'), max_length=32, blank=True, null=True, help_text=u'品牌唯一标识', db_index=True) |
|
| 209 |
+ brand_name = models.CharField(_(u'brand_name'), max_length=255, blank=True, null=True, help_text=u'品牌名称') |
|
| 210 |
+ |
|
| 211 |
+ model_id = models.CharField(_(u'model_id'), max_length=32, blank=True, null=True, help_text=u'型号唯一标识', db_index=True) |
|
| 212 |
+ model_name = models.CharField(_(u'model_name'), max_length=255, blank=True, null=True, help_text=u'型号名称') |
|
| 213 |
+ |
|
| 214 |
+ distributor_id = models.CharField(_(u'distributor_id'), max_length=32, blank=True, null=True, help_text=u'经销商唯一标识', db_index=True) |
|
| 215 |
+ distributor_name = models.CharField(_(u'distributor_name'), max_length=255, blank=True, null=True, help_text=u'经销商名称') |
|
| 216 |
+ |
|
| 217 |
+ factory_yuan = models.FloatField(_(u'factory_yuan'), default=1000, help_text=u'出厂价(元)') |
|
| 218 |
+ factory_fee = models.IntegerField(_(u'factory_fee'), default=100000, help_text=u'出厂价(分)') |
|
| 219 |
+ |
|
| 220 |
+ integral = models.IntegerField(_(u'integral'), default=100, help_text=u'积分') |
|
| 221 |
+ |
|
| 222 |
+ class Meta: |
|
| 223 |
+ verbose_name = _(u'型号/代理商价格信息') |
|
| 224 |
+ verbose_name_plural = _(u'型号/代理商价格信息') |
|
| 225 |
+ unique_together = ( |
|
| 226 |
+ ('brand_id', 'model_id', 'distributor_id'),
|
|
| 227 |
+ ) |
|
| 228 |
+ |
|
| 229 |
+ def __unicode__(self): |
|
| 230 |
+ return unicode(self.pk) |
|
| 231 |
+ |
|
| 232 |
+ |
|
| 174 | 233 |
class LatestAppInfo(BaseModelMixin): |
| 175 | 234 |
latest_adr_version_code = models.IntegerField(_(u'latest_adr_version_code'), default=0, help_text=u'最新安卓版本号') |
| 176 | 235 |
latest_adr_version_name = models.CharField(_(u'latest_adr_version_name'), max_length=16, blank=True, null=True, help_text=u'最新安卓版本名') |
@@ -31,6 +31,7 @@ hiredis==0.2.0 |
||
| 31 | 31 |
isoweek==1.3.3 |
| 32 | 32 |
jsonfield==2.0.2 |
| 33 | 33 |
mock==2.0.0 |
| 34 |
+monetary==1.0.1 |
|
| 34 | 35 |
pysnippets==1.0.5 |
| 35 | 36 |
pywe-jssdk==1.1.0 |
| 36 | 37 |
pywe-membercard==1.0.0 |