old"> 57
return response(200, 'Get UUID Success', u'获取唯一标识成功', uuids)
@@ -0,0 +1,29 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+ |
|
| 3 |
+from django.contrib import admin |
|
| 4 |
+ |
|
| 5 |
+from product.models import ProductCodeSubmitLogInfo, ProductInfo, ProductModelInfo |
|
| 6 |
+ |
|
| 7 |
+ |
|
| 8 |
+class ProductModelInfoAdmin(admin.ModelAdmin): |
|
| 9 |
+ readonly_fields = ('model_id', )
|
|
| 10 |
+ list_display = ('model_id', 'model_name', 'integral', 'has_mount', 'status', 'created_at', 'updated_at')
|
|
| 11 |
+ search_fields = ('model_id', 'model_name')
|
|
| 12 |
+ list_filter = ('has_mount', 'status')
|
|
| 13 |
+ |
|
| 14 |
+ |
|
| 15 |
+class ProductInfoAdmin(admin.ModelAdmin): |
|
| 16 |
+ list_display = ('model_id', 'model_name', 'code', 'code_status', 'integral', 'integral_status', 'franchiser_id', 'clerk_id', 'consumer_name', 'consumer_sex', 'consumer_age', 'consumer_phone', 'status', 'created_at', 'updated_at')
|
|
| 17 |
+ search_fields = ('model_id', 'model_name', 'code', 'consumer_name', 'consumer_phone')
|
|
| 18 |
+ list_filter = ('code_status', 'integral_status', 'franchiser_id', 'consumer_sex', 'status')
|
|
| 19 |
+ |
|
| 20 |
+ |
|
| 21 |
+class ProductCodeSubmitLogInfoAdmin(admin.ModelAdmin): |
|
| 22 |
+ list_display = ('model_id', 'model_name', 'mount', 'code', 'franchiser_id', 'clerk_id', 'consumer_name', 'consumer_sex', 'consumer_age', 'consumer_phone', 'status', 'created_at', 'updated_at')
|
|
| 23 |
+ search_fields = ('model_id', 'model_name', 'code', 'consumer_name', 'consumer_phone')
|
|
| 24 |
+ list_filter = ('step', 'mount', 'franchiser_id', 'consumer_sex', 'status')
|
|
| 25 |
+ |
|
| 26 |
+ |
|
| 27 |
+admin.site.register(ProductModelInfo, ProductModelInfoAdmin) |
|
| 28 |
+admin.site.register(ProductInfo, ProductInfoAdmin) |
|
| 29 |
+admin.site.register(ProductCodeSubmitLogInfo, ProductCodeSubmitLogInfoAdmin) |
@@ -0,0 +1,86 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+# Generated by Django 1.11.9 on 2018-02-07 14:16 |
|
| 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 |
+ initial = True |
|
| 12 |
+ |
|
| 13 |
+ dependencies = [ |
|
| 14 |
+ ] |
|
| 15 |
+ |
|
| 16 |
+ operations = [ |
|
| 17 |
+ migrations.CreateModel( |
|
| 18 |
+ name='ProductCodeSubmitLogInfo', |
|
| 19 |
+ fields=[ |
|
| 20 |
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
| 21 |
+ ('status', models.BooleanField(db_index=True, default=True, help_text='Status', verbose_name='status')),
|
|
| 22 |
+ ('created_at', models.DateTimeField(auto_now_add=True, help_text='Create Time', verbose_name='created_at')),
|
|
| 23 |
+ ('updated_at', models.DateTimeField(auto_now=True, help_text='Update Time', verbose_name='updated_at')),
|
|
| 24 |
+ ('sex', models.BooleanField(choices=[(1, '\u7537'), (0, '\u5973')], db_index=True, default=1, help_text='Sex', verbose_name='sex')),
|
|
| 25 |
+ ('step', models.IntegerField(db_index=True, default=1, help_text='\u63d0\u4ea4\u6b65\u9aa4', verbose_name='step')),
|
|
| 26 |
+ ('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')),
|
|
| 27 |
+ ('model_name', models.CharField(blank=True, db_index=True, help_text='\u578b\u53f7\u540d\u79f0', max_length=32, null=True, verbose_name='model_name')),
|
|
| 28 |
+ ('mount', models.CharField(blank=True, db_index=True, help_text='\u5361\u53e3', max_length=255, null=True, verbose_name='mount')),
|
|
| 29 |
+ ('code', models.CharField(blank=True, help_text='\u673a\u8eab\u7801', max_length=32, null=True, verbose_name='code')),
|
|
| 30 |
+ ('franchiser_id', models.CharField(blank=True, db_index=True, help_text='\u7ecf\u9500\u5546\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='franchiser_id')),
|
|
| 31 |
+ ('clerk_id', models.CharField(blank=True, db_index=True, help_text='\u5e97\u5458\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='clerk_id')),
|
|
| 32 |
+ ('consumer_name', models.CharField(blank=True, help_text='\u6d88\u8d39\u8005\u540d\u79f0', max_length=32, null=True, verbose_name='consumer_name')),
|
|
| 33 |
+ ('consumer_sex', models.IntegerField(choices=[(1, '\u7537'), (0, '\u5973')], db_index=True, default=1, help_text='\u6d88\u8d39\u8005\u6027\u522b', verbose_name='consumer_sex')),
|
|
| 34 |
+ ('consumer_age', models.IntegerField(default=0, help_text='\u6d88\u8d39\u8005\u5e74\u9f84', verbose_name='consumer_age')),
|
|
| 35 |
+ ('consumer_phone', models.CharField(blank=True, help_text='\u6d88\u8d39\u8005\u8054\u7cfb\u7535\u8bdd', max_length=11, null=True, verbose_name='consumer_phone')),
|
|
| 36 |
+ ], |
|
| 37 |
+ options={
|
|
| 38 |
+ 'verbose_name': 'productcodesubmitloginfo', |
|
| 39 |
+ 'verbose_name_plural': 'productcodesubmitloginfo', |
|
| 40 |
+ }, |
|
| 41 |
+ ), |
|
| 42 |
+ migrations.CreateModel( |
|
| 43 |
+ name='ProductInfo', |
|
| 44 |
+ fields=[ |
|
| 45 |
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
| 46 |
+ ('status', models.BooleanField(db_index=True, default=True, help_text='Status', verbose_name='status')),
|
|
| 47 |
+ ('created_at', models.DateTimeField(auto_now_add=True, help_text='Create Time', verbose_name='created_at')),
|
|
| 48 |
+ ('updated_at', models.DateTimeField(auto_now=True, help_text='Update Time', verbose_name='updated_at')),
|
|
| 49 |
+ ('sex', models.BooleanField(choices=[(1, '\u7537'), (0, '\u5973')], db_index=True, default=1, help_text='Sex', verbose_name='sex')),
|
|
| 50 |
+ ('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')),
|
|
| 51 |
+ ('model_name', models.CharField(blank=True, db_index=True, help_text='\u578b\u53f7\u540d\u79f0', max_length=32, null=True, verbose_name='model_name')),
|
|
| 52 |
+ ('mount', models.CharField(blank=True, db_index=True, help_text='\u5361\u53e3', max_length=32, null=True, verbose_name='mount')),
|
|
| 53 |
+ ('code', models.CharField(blank=True, help_text='\u673a\u8eab\u7801', max_length=32, null=True, verbose_name='code')),
|
|
| 54 |
+ ('code_status', models.BooleanField(db_index=True, default=False, help_text='\u673a\u8eab\u7801\u72b6\u6001, True\u5df2\u4f7f\u7528\uff0cFalse\u672a\u4f7f\u7528', verbose_name='code_status')),
|
|
| 55 |
+ ('integral', models.IntegerField(default=0, help_text='\u79ef\u5206', verbose_name='integral')),
|
|
| 56 |
+ ('integral_status', models.BooleanField(db_index=True, default=False, help_text='\u79ef\u5206\u72b6\u6001, True\u5df2\u79ef\u5206\uff0cFalse\u672a\u79ef\u5206', verbose_name='integral_status')),
|
|
| 57 |
+ ('franchiser_id', models.CharField(blank=True, db_index=True, help_text='\u7ecf\u9500\u5546\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='franchiser_id')),
|
|
| 58 |
+ ('clerk_id', models.CharField(blank=True, db_index=True, help_text='\u5e97\u5458\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='clerk_id')),
|
|
| 59 |
+ ('consumer_name', models.CharField(blank=True, help_text='\u6d88\u8d39\u8005\u540d\u79f0', max_length=32, null=True, verbose_name='consumer_name')),
|
|
| 60 |
+ ('consumer_sex', models.IntegerField(choices=[(1, '\u7537'), (0, '\u5973')], db_index=True, default=1, help_text='\u6d88\u8d39\u8005\u6027\u522b', verbose_name='consumer_sex')),
|
|
| 61 |
+ ('consumer_age', models.IntegerField(default=0, help_text='\u6d88\u8d39\u8005\u5e74\u9f84', verbose_name='consumer_age')),
|
|
| 62 |
+ ('consumer_phone', models.CharField(blank=True, help_text='\u6d88\u8d39\u8005\u8054\u7cfb\u7535\u8bdd', max_length=11, null=True, verbose_name='consumer_phone')),
|
|
| 63 |
+ ], |
|
| 64 |
+ options={
|
|
| 65 |
+ 'verbose_name': 'productinfo', |
|
| 66 |
+ 'verbose_name_plural': 'productinfo', |
|
| 67 |
+ }, |
|
| 68 |
+ ), |
|
| 69 |
+ migrations.CreateModel( |
|
| 70 |
+ name='ProductModelInfo', |
|
| 71 |
+ fields=[ |
|
| 72 |
+ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
| 73 |
+ ('status', models.BooleanField(db_index=True, default=True, help_text='Status', verbose_name='status')),
|
|
| 74 |
+ ('created_at', models.DateTimeField(auto_now_add=True, help_text='Create Time', verbose_name='created_at')),
|
|
| 75 |
+ ('updated_at', models.DateTimeField(auto_now=True, help_text='Update Time', verbose_name='updated_at')),
|
|
| 76 |
+ ('model_id', shortuuidfield.fields.ShortUUIDField(blank=True, db_index=True, editable=False, help_text='\u578b\u53f7\u552f\u4e00\u6807\u8bc6', max_length=22, unique=True)),
|
|
| 77 |
+ ('model_name', models.CharField(blank=True, help_text='\u578b\u53f7\u540d\u79f0', max_length=32, null=True, unique=True, verbose_name='model_name')),
|
|
| 78 |
+ ('integral', models.IntegerField(default=0, help_text='\u578b\u53f7\u79ef\u5206', verbose_name='integral')),
|
|
| 79 |
+ ('has_mount', models.BooleanField(db_index=True, default=True, help_text='\u662f\u5426\u6709\u5361\u53e3', verbose_name='has_mount')),
|
|
| 80 |
+ ], |
|
| 81 |
+ options={
|
|
| 82 |
+ 'verbose_name': '\u4ea7\u54c1\u578b\u53f7\u4fe1\u606f', |
|
| 83 |
+ 'verbose_name_plural': '\u4ea7\u54c1\u578b\u53f7\u4fe1\u606f', |
|
| 84 |
+ }, |
|
| 85 |
+ ), |
|
| 86 |
+ ] |
@@ -0,0 +1,88 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+ |
|
| 3 |
+from django.db import models |
|
| 4 |
+from django.utils.translation import ugettext_lazy as _ |
|
| 5 |
+from models_ext import BaseModelMixin, SexModelMixin |
|
| 6 |
+from shortuuidfield import ShortUUIDField |
|
| 7 |
+ |
|
| 8 |
+ |
|
| 9 |
+class ProductModelInfo(BaseModelMixin): |
|
| 10 |
+ model_id = ShortUUIDField(_(u'model_id'), max_length=32, help_text=u'型号唯一标识', db_index=True, unique=True) |
|
| 11 |
+ model_name = models.CharField(_(u'model_name'), max_length=32, blank=True, null=True, help_text=u'型号名称', unique=True) |
|
| 12 |
+ integral = models.IntegerField(_(u'integral'), default=0, help_text=u'型号积分') |
|
| 13 |
+ has_mount = models.BooleanField(_(u'has_mount'), default=True, help_text=u'是否有卡口', db_index=True) |
|
| 14 |
+ |
|
| 15 |
+ class Meta: |
|
| 16 |
+ verbose_name = _(u'产品型号信息') |
|
| 17 |
+ verbose_name_plural = _(u'产品型号信息') |
|
| 18 |
+ |
|
| 19 |
+ def __unicode__(self): |
|
| 20 |
+ return unicode(self.pk) |
|
| 21 |
+ |
|
| 22 |
+ @property |
|
| 23 |
+ def data(self): |
|
| 24 |
+ return {
|
|
| 25 |
+ 'model_id': self.model_id, |
|
| 26 |
+ 'model_name': self.model_name, |
|
| 27 |
+ 'integral': self.integral, |
|
| 28 |
+ 'has_mount': self.has_mount, |
|
| 29 |
+ } |
|
| 30 |
+ |
|
| 31 |
+ |
|
| 32 |
+class ProductInfo(BaseModelMixin, SexModelMixin): |
|
| 33 |
+ model_id = models.CharField(_(u'model_id'), max_length=32, blank=True, null=True, help_text=u'型号唯一标识', db_index=True) |
|
| 34 |
+ model_name = models.CharField(_(u'model_name'), max_length=32, blank=True, null=True, help_text=u'型号名称', db_index=True) |
|
| 35 |
+ |
|
| 36 |
+ mount = models.CharField(_(u'mount'), max_length=32, blank=True, null=True, help_text=u'卡口', db_index=True) |
|
| 37 |
+ code = models.CharField(_(u'code'), max_length=32, blank=True, null=True, help_text=u'机身码') |
|
| 38 |
+ code_status = models.BooleanField(_(u'code_status'), default=False, help_text=u'机身码状态, True已使用,False未使用', db_index=True) |
|
| 39 |
+ |
|
| 40 |
+ integral = models.IntegerField(_(u'integral'), default=0, help_text=u'积分') |
|
| 41 |
+ integral_status = models.BooleanField(_(u'integral_status'), default=False, help_text=u'积分状态, True已积分,False未积分', db_index=True) |
|
| 42 |
+ |
|
| 43 |
+ franchiser_id = models.CharField(_(u'franchiser_id'), max_length=32, blank=True, null=True, help_text=u'经销商唯一标识', db_index=True) |
|
| 44 |
+ clerk_id = models.CharField(_(u'clerk_id'), max_length=32, blank=True, null=True, help_text=u'店员唯一标识', db_index=True) |
|
| 45 |
+ |
|
| 46 |
+ consumer_name = models.CharField(_(u'consumer_name'), max_length=32, blank=True, null=True, help_text=u'消费者名称') |
|
| 47 |
+ consumer_sex = models.IntegerField(_(u'consumer_sex'), choices=SexModelMixin.SEX_TUPLE, default=SexModelMixin.MALE, help_text=u'消费者性别', db_index=True) |
|
| 48 |
+ consumer_age = models.IntegerField(_(u'consumer_age'), default=0, help_text=u'消费者年龄') |
|
| 49 |
+ consumer_phone = models.CharField(_(u'consumer_phone'), max_length=11, blank=True, null=True, help_text=u'消费者联系电话') |
|
| 50 |
+ |
|
| 51 |
+ class Meta: |
|
| 52 |
+ verbose_name = _(u'productinfo') |
|
| 53 |
+ verbose_name_plural = _(u'productinfo') |
|
| 54 |
+ |
|
| 55 |
+ def __unicode__(self): |
|
| 56 |
+ return unicode(self.pk) |
|
| 57 |
+ |
|
| 58 |
+ @property |
|
| 59 |
+ def data(self): |
|
| 60 |
+ return {
|
|
| 61 |
+ 'model_id': self.model_id, |
|
| 62 |
+ 'model_name': self.model_name, |
|
| 63 |
+ 'code': self.code, |
|
| 64 |
+ } |
|
| 65 |
+ |
|
| 66 |
+ |
|
| 67 |
+class ProductCodeSubmitLogInfo(BaseModelMixin, SexModelMixin): |
|
| 68 |
+ step = models.IntegerField(_(u'step'), default=1, help_text=u'提交步骤', db_index=True) |
|
| 69 |
+ |
|
| 70 |
+ model_id = models.CharField(_(u'model_id'), max_length=32, blank=True, null=True, help_text=u'型号唯一标识', db_index=True) |
|
| 71 |
+ model_name = models.CharField(_(u'model_name'), max_length=32, blank=True, null=True, help_text=u'型号名称', db_index=True) |
|
| 72 |
+ mount = models.CharField(_(u'mount'), max_length=255, blank=True, null=True, help_text=u'卡口', db_index=True) |
|
| 73 |
+ code = models.CharField(_(u'code'), max_length=32, blank=True, null=True, help_text=u'机身码') |
|
| 74 |
+ |
|
| 75 |
+ franchiser_id = models.CharField(_(u'franchiser_id'), max_length=32, blank=True, null=True, help_text=u'经销商唯一标识', db_index=True) |
|
| 76 |
+ clerk_id = models.CharField(_(u'clerk_id'), max_length=32, blank=True, null=True, help_text=u'店员唯一标识', db_index=True) |
|
| 77 |
+ |
|
| 78 |
+ consumer_name = models.CharField(_(u'consumer_name'), max_length=32, blank=True, null=True, help_text=u'消费者名称') |
|
| 79 |
+ consumer_sex = models.IntegerField(_(u'consumer_sex'), choices=SexModelMixin.SEX_TUPLE, default=SexModelMixin.MALE, help_text=u'消费者性别', db_index=True) |
|
| 80 |
+ consumer_age = models.IntegerField(_(u'consumer_age'), default=0, help_text=u'消费者年龄') |
|
| 81 |
+ consumer_phone = models.CharField(_(u'consumer_phone'), max_length=11, blank=True, null=True, help_text=u'消费者联系电话') |
|
| 82 |
+ |
|
| 83 |
+ class Meta: |
|
| 84 |
+ verbose_name = _(u'productcodesubmitloginfo') |
|
| 85 |
+ verbose_name_plural = _(u'productcodesubmitloginfo') |
|
| 86 |
+ |
|
| 87 |
+ def __unicode__(self): |
|
| 88 |
+ return unicode(self.pk) |
@@ -0,0 +1,4 @@ |
||
| 1 |
+from django.test import TestCase |
|
| 2 |
+ |
|
| 3 |
+ |
|
| 4 |
+# Create your tests here. |
@@ -0,0 +1,4 @@ |
||
| 1 |
+from django.shortcuts import render |
|
| 2 |
+ |
|
| 3 |
+ |
|
| 4 |
+# Create your views here. |
@@ -3,6 +3,34 @@ |
||
| 3 | 3 |
from StatusCode import BaseStatusCode, StatusCodeField |
| 4 | 4 |
|
| 5 | 5 |
|
| 6 |
+class FranchiserStatusCode(BaseStatusCode): |
|
| 7 |
+ """ 经销商相关错误码 5000xx """ |
|
| 8 |
+ CHISER_NOT_FOUND = StatusCodeField(500001, 'Chiser Not Found', description=u'经销商不存在') |
|
| 9 |
+ |
|
| 10 |
+ |
|
| 11 |
+class SaleclerkStatusCode(BaseStatusCode): |
|
| 12 |
+ """ 店员相关错误码 5001xx """ |
|
| 13 |
+ CLERK_NOT_FOUND = StatusCodeField(500101, 'Clerk Not Found', description=u'店员不存在') |
|
| 14 |
+ # 手机号 |
|
| 15 |
+ CLERK_PHONE_ALREADY_EXISTS = StatusCodeField(500105, 'Clerk Phone Already Exists', description=u'手机号已经存在') |
|
| 16 |
+ # 状态 |
|
| 17 |
+ CLERK_ALREADY_NOT_UNVERIFIED = StatusCodeField(500110, 'Clerk Already Not Unverified', description=u'店员帐号已激活') |
|
| 18 |
+ CLERK_NOT_ACTIVATED = StatusCodeField(500115, 'Clerk Not Activated', description=u'店员帐号未激活') |
|
| 19 |
+ |
|
| 20 |
+ |
|
| 21 |
+class ProductModelStatusCode(BaseStatusCode): |
|
| 22 |
+ """ 型号相关错误码 5010xx """ |
|
| 23 |
+ MODEL_NOT_FOUND = StatusCodeField(501001, 'Model Not Found', description=u'型号不存在') |
|
| 24 |
+ |
|
| 25 |
+ |
|
| 26 |
+class ProductStatusCode(BaseStatusCode): |
|
| 27 |
+ """ 产品相关错误码 5020xx """ |
|
| 28 |
+ PRODUCT_NOT_FOUND = StatusCodeField(502001, 'Product Not Found', description=u'产品不存在') |
|
| 29 |
+ # 状态 |
|
| 30 |
+ PRODUCT_HAS_USED = StatusCodeField(502011, 'Product Has Used', description=u'产品已使用') |
|
| 31 |
+ PRODUCT_NOT_USED = StatusCodeField(502012, 'Product Not Used', description=u'产品未使用') |
|
| 32 |
+ |
|
| 33 |
+ |
|
| 6 | 34 |
class LensmanStatusCode(BaseStatusCode): |
| 7 | 35 |
""" 摄影师相关错误码 4000xx """ |
| 8 | 36 |
LENSMAN_NOT_FOUND = StatusCodeField(400001, 'Lensman Not Found', description=u'摄影师不存在') |