data-line="254">+ 254 - 0 tamron/settings.py
View File
@@ -0,0 +1,254 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+"""
4
+Django settings for tamron project.
5
+
6
+Generated by 'django-admin startproject' using Django 1.8.4.
7
+
8
+For more information on this file, see
9
+https://docs.djangoproject.com/en/1.8/topics/settings/
10
+
11
+For the full list of settings and their values, see
12
+https://docs.djangoproject.com/en/1.8/ref/settings/
13
+"""
14
+
15
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
16
+import os
17
+
18
+
19
+BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
20
+PROJ_DIR = os.path.abspath(os.path.dirname(os.path.abspath(__file__)))
21
+
22
+
23
+# Quick-start development settings - unsuitable for production
24
+# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
25
+
26
+# SECURITY WARNING: keep the secret key used in production secret!
27
+SECRET_KEY = '@!_8xi9(8)gj8zvni#)2-arn)4gn^u&coy-0yld0=1r5*ao@4i'
28
+
29
+# SECURITY WARNING: don't run with debug turned on in production!
30
+DEBUG = True
31
+
32
+ALLOWED_HOSTS = []
33
+
34
+
35
+# Application definition
36
+
37
+INSTALLED_APPS = (
38
+    'django.contrib.admin',
39
+    'django.contrib.auth',
40
+    'django.contrib.contenttypes',
41
+    'django.contrib.sessions',
42
+    'django.contrib.messages',
43
+    'django.contrib.staticfiles',
44
+    'api',
45
+    'account',
46
+    'integral',
47
+    'page',
48
+    'product',
49
+)
50
+
51
+MIDDLEWARE_CLASSES = (
52
+    'django.contrib.sessions.middleware.SessionMiddleware',
53
+    'django.middleware.common.CommonMiddleware',
54
+    # 'django.middleware.csrf.CsrfViewMiddleware',
55
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
56
+    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
57
+    'django.contrib.messages.middleware.MessageMiddleware',
58
+    'django.middleware.clickjacking.XFrameOptionsMiddleware',
59
+    'django.middleware.security.SecurityMiddleware',
60
+)
61
+
62
+ROOT_URLCONF = 'tamron.urls'
63
+
64
+TEMPLATES = [
65
+    {
66
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
67
+        'DIRS': [os.path.join(BASE_DIR, 'templates')],
68
+        # 'APP_DIRS': True,
69
+        'OPTIONS': {
70
+            'context_processors': [
71
+                'django.template.context_processors.debug',
72
+                'django.template.context_processors.request',
73
+                'django.contrib.auth.context_processors.auth',
74
+                'django.contrib.messages.context_processors.messages',
75
+            ],
76
+            'loaders': [
77
+                ('django.template.loaders.cached.Loader', [
78
+                    'django.template.loaders.filesystem.Loader',
79
+                    'django.template.loaders.app_directories.Loader',
80
+                ]),
81
+            ],
82
+        },
83
+    },
84
+]
85
+
86
+WSGI_APPLICATION = 'tamron.wsgi.application'
87
+
88
+
89
+# Database
90
+# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
91
+
92
+DATABASES = {
93
+    'default': {
94
+        'ENGINE': 'django.db.backends.mysql',
95
+        'NAME': 'tamron',
96
+        'USER': 'root',
97
+        'PASSWORD': '',
98
+        'CONN_MAX_AGE': 600,
99
+        'OPTIONS': {
100
+            # Utf8mb4 for Emoji
101
+            #
102
+            # Nickname
103
+            #
104
+            # account.WechatInfo ==> nickname
105
+            #   ALTER TABLE account_wechatinfo MODIFY COLUMN nickname VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
106
+            # account.UserInfo ==> nickname
107
+            #   ALTER TABLE account_userinfo MODIFY COLUMN nickname VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
108
+            # group.GroupUserInfo ==> nickname
109
+            #   ALTER TABLE group_groupuserinfo MODIFY COLUMN nickname VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL;
110
+            # group.GroupPhotoInfo ==> nickname
111
+            #   ALTER TABLE group_groupphotoinfo MODIFY COLUMN nickname VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL;
112
+            # group.PhotoCommentInfo ==> nickname
113
+            #   ALTER TABLE group_photocommentinfo MODIFY COLUMN nickname VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL;
114
+            # group.PhotoThumbUpInfo ==> nickname
115
+            #   ALTER TABLE group_photothumbupinfo MODIFY COLUMN nickname VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL;
116
+            # group.UserMessageInfo ==> nickname
117
+            #   ALTER TABLE message_usermessageinfo MODIFY COLUMN from_nickname VARCHAR(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL;
118
+            #
119
+            # Comment
120
+            # group.PhotoCommentInfo ==> comment
121
+            #   ALTER TABLE group_photocommentinfo MODIFY COLUMN comment LONGTEXT CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
122
+            'charset': 'utf8mb4',
123
+        },
124
+    }
125
+}
126
+
127
+
128
+# Internationalization
129
+# https://docs.djangoproject.com/en/1.8/topics/i18n/
130
+
131
+LANGUAGE_CODE = 'zh-Hans'
132
+
133
+TIME_ZONE = 'Asia/Shanghai'
134
+
135
+USE_I18N = True
136
+
137
+USE_L10N = True
138
+
139
+USE_TZ = True
140
+
141
+
142
+# Static files (CSS, JavaScript, Images)
143
+# https://docs.djangoproject.com/en/1.8/howto/static-files/
144
+
145
+STATICFILES_DIRS = (
146
+    os.path.join(PROJ_DIR, 'static').replace('\\', '/'),
147
+)
148
+
149
+STATIC_ROOT = os.path.join(BASE_DIR, 'collect_static').replace('\\', '/')
150
+
151
+STATIC_URL = '/static/'
152
+
153
+STATICFILES_FINDERS = (
154
+    'django.contrib.staticfiles.finders.FileSystemFinder',
155
+    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
156
+    # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
157
+)
158
+
159
+MEDIA_ROOT = os.path.join(BASE_DIR, 'media').replace('\\', '/')
160
+
161
+MEDIA_URL = '/media/'
162
+
163
+# Redis 设置
164
+REDIS = {
165
+    'default': {
166
+        'HOST': '127.0.0.1',
167
+        'PORT': 6379,
168
+        'USER': '',
169
+        'PASSWORD': '',
170
+        'db': 0,
171
+    }
172
+}
173
+
174
+# 微信设置
175
+WECHAT = {
176
+    'JSAPI': {
177
+        'token': '5201314',
178
+        'appID': '',
179
+        'appsecret': '',
180
+        'mchID': '',
181
+        'apiKey': '',
182
+        'mch_cert': '',
183
+        'mch_key': '',
184
+        'redpacket': {
185
+
186
+        }
187
+    },
188
+}
189
+
190
+# 微信授权设置
191
+WECHAT_BASE_REDIRECT_URI = 'https://api.pai.ai/base_redirect'
192
+WECHAT_USERINFO_REDIRECT_URI = 'https://api.pai.ai/userinfo_redirect'
193
+WECHAT_OAUTH2_RETRY_REDIRECT_URI = 'https://api.pai.ai/wx_oauth2?redirect_url={}'
194
+
195
+WECHAT_OAUTH2_REDIRECT_URL = 'https://api.pai.ai/wx_oauth2?redirect_url={}'
196
+
197
+# LOGIT 设置
198
+LOGIT_BODY_FLAG = True
199
+LOGIT_RES_FLAG = True
200
+
201
+DOMAIN = ''
202
+
203
+try:
204
+    from local_settings import *
205
+except ImportError:
206
+    pass
207
+
208
+try:
209
+    from func_settings import redis_connect
210
+    REDIS_CACHE = redis_connect(REDIS.get('default', {}))
211
+
212
+    DJLOGIT = {
213
+        'level': 'DEBUG',
214
+        'class': 'rlog.RedisListHandler',
215
+        'redis_client': REDIS_CACHE,
216
+        'key': 'django:logit:tamron',
217
+        'formatter': 'verbose',
218
+    }
219
+except ImportError:
220
+    REDIS_CACHE = None
221
+
222
+# 日志设置
223
+LOGGING = {
224
+    'version': 1,
225
+    'disable_existing_loggers': False,
226
+    'formatters': {
227
+        'verbose': {
228
+            'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s'
229
+        },
230
+        'simple': {
231
+            'format': '%(levelname)s %(message)s'
232
+        },
233
+    },
234
+    'handlers': {
235
+        'logit': DJLOGIT,
236
+        'console': {
237
+            'level': 'DEBUG',
238
+            'class': 'logging.StreamHandler',
239
+            'formatter': 'verbose'
240
+        },
241
+    },
242
+    'loggers': {
243
+        'logit': {
244
+            'handlers': ['logit'],
245
+            'level': 'DEBUG',
246
+            'propagate': True,
247
+        },
248
+        'console': {
249
+            'handlers': ['console'],
250
+            'level': 'DEBUG',
251
+            'propagate': True,
252
+        },
253
+    },
254
+}

BIN
tamron/settings.pyc


+ 300 - 0
tamron/static/tamron/js/jswe.js

@@ -0,0 +1,300 @@
1
+!(function(e, t) {
2
+    var config = {
3
+        wxconfig: 'http://api.pai.ai/wx/jsapi_signature',
4
+        callback: 'callback'
5
+    }, wxData = {
6
+        debug: false,
7
+        imgUrl: '',
8
+        link: '',
9
+        desc: '',
10
+        title: '',
11
+        timeLine: ''
12
+    }, wxConfig = {
13
+        hide: false,
14
+        close: false
15
+    }, jsApiList = [
16
+        'checkJsApi',
17
+        'onMenuShareTimeline',
18
+        'onMenuShareAppMessage',
19
+        'onMenuShareQQ',
20
+        'onMenuShareWeibo',
21
+        'hideMenuItems',
22
+        'showMenuItems',
23
+        'hideAllNonBaseMenuItem',
24
+        'showAllNonBaseMenuItem',
25
+        'translateVoice',
26
+        'startRecord',
27
+        'stopRecord',
28
+        'onRecordEnd',
29
+        'playVoice',
30
+        'pauseVoice',
31
+        'stopVoice',
32
+        'uploadVoice',
33
+        'downloadVoice',
34
+        'chooseImage',
35
+        'previewImage',
36
+        'uploadImage',
37
+        'downloadImage',
38
+        'getNetworkType',
39
+        'openLocation',
40
+        'getLocation',
41
+        'hideOptionMenu',
42
+        'showOptionMenu',
43
+        'closeWindow',
44
+        'scanQRCode',
45
+        'chooseWXPay',
46
+        'openEnterpriseRedPacket',
47
+        'openProductSpecificView',
48
+        'addCard',
49
+        'chooseCard',
50
+        'openCard'
51
+    ], wxApiFun
52
+
53
+    function isOpenOnPC() {  // 判断当前网页是否在 PC 浏览器中打开
54
+        var ua = navigator.userAgent
55
+        return /windows nt/i.test(ua) || /macintosh/i.test(ua) || /linux x86_64/i.test(ua)
56
+    }
57
+
58
+    function isOpenInWeixin() {  // 判断当前网页是否在微信内置浏览器中打开
59
+        return /micromessenger/i.test(navigator.userAgent)
60
+    }
61
+
62
+    function getWeixinVersion() {
63
+        var ua = navigator.userAgent,
64
+            mt = ua.match(/micromessenger\/([\d.]+)/i)
65
+        return (mt ? mt[1] : '')
66
+    }
67
+
68
+    // This function checks whether Wechat is the appointed version or not
69
+    // Cmp: http://jsperf.com/regexp-test-vs-indexof-ignore-upper-and-lower
70
+    function isWeixinVersion(version) {
71
+        // return new RegExp('micromessenger/' + version , 'i').test(navigator.userAgent)
72
+        return navigator.userAgent.toLowerCase().indexOf('micromessenger/' + version) != -1
73
+    }
74
+
75
+    function hideOptionMenu() {
76
+        wxConfig.hide = true
77
+        fixedWxData()
78
+    }
79
+
80
+    function showOptionMenu() {
81
+        wxConfig.hide = false
82
+        fixedWxData()
83
+    }
84
+
85
+    function closeWindow() {
86
+        wxConfig.close = true
87
+        fixedWxData()
88
+    }
89
+
90
+    function wxReady(data) {
91
+        data = typeof data === 'object' ? data : JSON.parse(data)
92
+        wx.config({
93
+            debug: wxData.debug,
94
+            appId: data.appId,
95
+            timestamp: data.timestamp,
96
+            nonceStr: data.nonceStr,
97
+            signature: data.signature,
98
+            jsApiList: jsApiList
99
+        })
100
+
101
+        var callbacks = {
102
+            trigger: function (res) {
103
+                // alert('用户点击发送给朋友')
104
+                if (JSWE.wxTrigger) {JSWE.wxTrigger(res)}
105
+            },
106
+            success: function (res) {
107
+                // alert('已分享')
108
+                if (JSWE.wxSuccess) {JSWE.wxSuccess(res)}
109
+            },
110
+            cancel: function (res) {
111
+                // alert('已取消')
112
+                if (JSWE.wxCancel) {JSWE.wxCancel(res)}
113
+            },
114
+            fail: function (res) {
115
+                // alert(JSON.stringify(res))
116
+                if (JSWE.wxFail) {JSWE.wxFail(res)}
117
+            }
118
+        }, shareInfo = function(flag) {
119
+            var _share = {
120
+                title: flag ? wxData.title : (wxData.timeLine || wxData.desc),
121
+                link: wxData.link,
122
+                imgUrl: wxData.imgUrl,
123
+                trigger: callbacks.trigger,
124
+                success: callbacks.success,
125
+                cancel: callbacks.cancel,
126
+                fail: callbacks.fail
127
+            }
128
+            if (flag) _share.desc = wxData.desc
129
+            return _share
130
+        }, wxShareApi = function() {
131
+            // 2. 分享接口
132
+            // 2.1 监听“分享给朋友”,按钮点击、自定义分享内容及分享结果接口
133
+            wx.onMenuShareAppMessage(shareInfo(1))
134
+            // 2.2 监听“分享到朋友圈”按钮点击、自定义分享内容及分享结果接口
135
+            wx.onMenuShareTimeline(shareInfo(0))
136
+            // 2.3 监听“分享到QQ”按钮点击、自定义分享内容及分享结果接口
137
+            wx.onMenuShareQQ(shareInfo(1))
138
+            // 2.4 监听“分享到微博”按钮点击、自定义分享内容及分享结果接口
139
+            wx.onMenuShareWeibo(shareInfo(1))
140
+        }, wxMenuApi = function () {
141
+            // 8. 界面操作接口
142
+            // 8.1 隐藏右上角菜单
143
+            // 8.2 显示右上角菜单
144
+            if (wxConfig.hide) {wx.hideOptionMenu()} else {wx.showOptionMenu()}
145
+            // 8.7 关闭当前窗口
146
+            if (wxConfig.close) {wx.closeWindow()}
147
+        }, wxApi = function () {
148
+            wxShareApi()
149
+            wxMenuApi()
150
+        }
151
+
152
+        wx.ready(wxApi)
153
+
154
+        return wxApiFun = wxApi
155
+    }
156
+
157
+    if (isOpenInWeixin() || isOpenOnPC()) {
158
+        if ('undefined' !== typeof JSWE_CONF_UPDATE) JSWE_CONF_UPDATE(config)
159
+        $.ajax({
160
+            url: config.wxconfig,
161
+            type: 'get',
162
+            dataType: 'jsonp',
163
+            jsonpCallback: config.callback,
164
+            data: {
165
+                url: window.location.href.split('#')[0]
166
+            },
167
+            success: wxReady
168
+        })
169
+    }
170
+
171
+    function initWxData(data, flag) {
172
+        for(var d in data) {if (d in wxData) wxData[d] = data[d]}
173
+        if (flag) fixedWxData()
174
+    }
175
+
176
+    function changeWxData(key, value, flag) {
177
+        if (key in falDwxDataata) {wxData[key] = value}
178
+        if (flag) fixedWxData()
179
+    }
180
+
181
+    function fixedWxData() {
182
+        if ('undefined' !== typeof wxApiFun) wxApiFun()
183
+    }
184
+
185
+    // 5 图片接口
186
+    // 5.1 拍照、本地选图
187
+    var images = {
188
+        localIds: [],
189
+        serverIds: []
190
+    };
191
+    function chooseImage(count, directUpload, isShowProgressTips) {
192
+        if ('undefined' === typeof count) {count = 9}
193
+        if ('undefined' === typeof directUpload) {directUpload = false}
194
+        if ('undefined' === typeof isShowProgressTips) {isShowProgressTips = 1}
195
+        wx.chooseImage({
196
+            count: count, // 默认9
197
+            sizeType: ['original', 'compressed'], // 可以指定是原图还是压缩图,默认二者都有
198
+            sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机,默认二者都有
199
+            success: function (res) {
200
+                var localIds = res.localIds; // 返回选定照片的本地ID列表,localId可以作为img标签的src属性显示图片
201
+                images.localIds = localIds;
202
+                // 判断是否直接上传
203
+                if (directUpload) {setTimeout(uploadImages(localIds, isShowProgressTips), 100)}
204
+                // 拍照、本地选图成功后的回调函数
205
+                if (JSWE.wxChooseImageSuccess) {JSWE.wxChooseImageSuccess(res)}
206
+            }
207
+        });
208
+    }
209
+
210
+    // 5.3 上传图片
211
+    function uploadImage(localId, isShowProgressTips) {
212
+        // 上传图片为异步处理,重复上传同一图片,返回的serverId也是不同的
213
+        wx.uploadImage({
214
+            localId: localId, // 需要上传的图片的本地ID,由chooseImage接口获得
215
+            isShowProgressTips: 1, // 默认为1,显示进度提示
216
+            success: function (res) {
217
+                var serverId = res.serverId; // 返回图片的服务器端ID
218
+                images.serverIds.push(serverId);
219
+                // 上传图片成功后的回调函数
220
+                if (JSWE.wxUploadImageSuccess) {JSWE.wxUploadImageSuccess(res)}
221
+            }
222
+        });
223
+    }
224
+
225
+    function uploadImages(localIds, isShowProgressTips) {
226
+        if ('undefined' === typeof localIds) {localIds = images.localIds}
227
+        if ('undefined' === typeof isShowProgressTips) {isShowProgressTips = 1}
228
+        images.serverIds = [];
229
+        for (var index in localIds) {uploadImage(localIds[index], isShowProgressTips)}
230
+    }
231
+
232
+    // 10 微信支付接口
233
+    // 10.1 发起一个支付请求
234
+    function chooseWXPay(wxpay_params) {
235
+        wx.chooseWXPay({
236
+            timestamp: wxpay_params.timeStamp, // 支付签名时间戳,注意微信jssdk中的所有使用timestamp字段均为小写。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
237
+            nonceStr: wxpay_params.nonceStr, // 支付签名随机串,不长于 32 位
238
+            package: wxpay_params.package, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=***)
239
+            signType: wxpay_params.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
240
+            paySign: wxpay_params.paySign, // 支付签名
241
+            success: function (res) {
242
+                // 支付成功后的回调函数
243
+                if (JSWE.wxPaySuccess) {JSWE.wxPaySuccess(res)}
244
+            }
245
+        })
246
+    }
247
+
248
+    // xx 微信原生企业红包接口
249
+    // xx.1 发起一个发送原生企业红包请求
250
+    function openEnterpriseRedPacket(wxredpack_params) {
251
+        wx.openEnterpriseRedPacket({
252
+            timeStamp: wxredpack_params.timeStamp, // 红包签名时间戳,注意原生企业红包接口timeStamp字段名需大写其中的S字符,而支付接口timeStamp字段名无需大写其中的S字符。但最新版的支付后台生成签名使用的timeStamp字段名需大写其中的S字符
253
+            nonceStr: wxredpack_params.nonceStr, // 红包签名随机串,不长于 32 位
254
+            package: encodeURIComponent(wxredpack_params.package), // 发放红包接口返回的prepay_id参数值,提交格式如:prepay_id=***)
255
+            signType: wxredpack_params.signType, // 签名方式,默认为'SHA1',使用新版支付需传入'MD5'
256
+            paySign: wxredpack_params.paySign, // 红包签名
257
+            success: function (res) {
258
+                // 发送原生企业红包成功后的回调函数
259
+                if (JSWE.wxEnterpriseRedPacketSuccess) {JSWE.wxEnterpriseRedPacketSuccess(res)}
260
+            }
261
+        })
262
+    }
263
+
264
+    var v = {
265
+        version: '1.0.5',
266
+
267
+        // Basic Vars
268
+        config: config,
269
+        wxData: wxData,
270
+        jsApiList: jsApiList,
271
+
272
+        // Weixin Function
273
+        isOpenInWeixin: isOpenInWeixin,
274
+        getWeixinVersion: getWeixinVersion,
275
+        isWeixinVersion: isWeixinVersion,
276
+
277
+        // Menu Function
278
+        hideOptionMenu: hideOptionMenu,
279
+        showOptionMenu: showOptionMenu,
280
+        closeWindow: closeWindow,
281
+
282
+        // Share Function
283
+        initWxData: initWxData,
284
+        changeWxData: changeWxData,
285
+        fixedWxData: fixedWxData,
286
+
287
+        // Image Function
288
+        images: images,
289
+        chooseImage: chooseImage,
290
+        uploadImage: uploadImage,
291
+        uploadImages: uploadImages,
292
+
293
+        // Pay Function
294
+        chooseWXPay: chooseWXPay,
295
+
296
+        // EnterpriseRedPacket Function
297
+        openEnterpriseRedPacket: openEnterpriseRedPacket
298
+    }
299
+    e.JSWE = e.V = v
300
+})(window)

+ 33 - 0
tamron/urls.py

@@ -0,0 +1,33 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+"""tamron URL Configuration
4
+
5
+The `urlpatterns` list routes URLs to views. For more information please see:
6
+    https://docs.djangoproject.com/en/1.8/topics/http/urls/
7
+Examples:
8
+Function views
9
+    1. Add an import:  from my_app import views
10
+    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
11
+Class-based views
12
+    1. Add an import:  from other_app.views import Home
13
+    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
14
+Including another URLconf
15
+    1. Add an import:  from blog import urls as blog_urls
16
+    2. Add a URL to urlpatterns:  url(r'^blog/', include(blog_urls))
17
+"""
18
+from django.conf.urls import include, url
19
+from django.contrib import admin
20
+
21
+from page import info_views, oauth_views, sale_views
22
+
23
+
24
+urlpatterns = [
25
+    url(r'^admin/', include(admin.site.urls)),
26
+    url(r'^api/', include('api.urls', namespace='api')),
27
+]
28
+
29
+urlpatterns += [
30
+    url(r'^page/clerk$', oauth_views.clerk_oauth, name='clerk_oauth'),  # 店员授权页面
31
+    url(r'^page/clerk/sale$', sale_views.clerk_sale_oauth, name='clerk_sale_oauth'),  # 店员销售授权页面
32
+    url(r'^page/clerk/info$', info_views.clerk_info_oauth, name='clerk_info_oauth'),  # 店员信息授权页面
33
+]

BIN
tamron/urls.pyc


+ 2 - 0
tamron/uwsgi.bak/shutdown.sh

@@ -0,0 +1,2 @@
1
+killall -9 uwsgi
2
+echo "2敏加油~~~!!!↖(^ω^)↗"

+ 2 - 0
tamron/uwsgi.bak/startup.sh

@@ -0,0 +1,2 @@
1
+nohup uwsgi --ini pai2.ini &>pai2.log &
2
+echo "Start Success !!!"

+ 27 - 0
tamron/uwsgi.bak/tamron.ini

@@ -0,0 +1,27 @@
1
+# tamron_uwsgi.ini file
2
+[uwsgi]
3
+
4
+# Django-related settings
5
+# the base directory (full path)
6
+chdir           = /home/paiai/work/tamron
7
+# Django's wsgi file
8
+module          = tamron.wsgi
9
+# the virtualenv (full path)
10
+# home            = /path/to/virtualenv
11
+
12
+# process-related settings
13
+# master
14
+master          = true
15
+# maximum number of worker processes
16
+processes       = 10
17
+# the socket (use the full path to be safe
18
+socket          = /home/paiai/work/tamron/tamron/uwsgi/tamron.sock
19
+# ... with appropriate permissions - may be needed
20
+chmod-socket    = 777
21
+# clear environment on exit
22
+vacuum          = true
23
+
24
+# 11: Resource temporarily unavailable
25
+reload-mercy    = 64
26
+max-requests    = 8192
27
+listen          = 4096

+ 35 - 0
tamron/uwsgi.bak/tamron_nginx.conf

@@ -0,0 +1,35 @@
1
+# tamron_nginx.conf
2
+
3
+# the upstream component nginx needs to connect to
4
+upstream pai2 {
5
+    # server unix:///home/paiai/work/tamron/tamron/uwsgi/tamron.sock; # for a file socket
6
+    server 127.0.0.1:8888; # for a web port socket (we'll use this first)
7
+}
8
+
9
+# configuration of the server
10
+server {
11
+    # the port your site will be served on
12
+    listen      80;
13
+    # the domain name it will serve for
14
+    server_name .tamron.xfoto.com.cn; # substitute your machine's IP address or FQDN
15
+    charset     utf-8;
16
+
17
+    # max upload size
18
+    client_max_body_size 75M;   # adjust to taste
19
+
20
+    # Django media
21
+    location /media  {
22
+        alias /home/paiai/work/tamron/media;  # your Django project's media files - amend as required
23
+    }
24
+
25
+    location /static {
26
+        alias /home/paiai/work/tamron/collect_static; # your Django project's static files - amend as required
27
+    }
28
+
29
+    # Finally, send all non-media requests to the Django server.
30
+    location / {
31
+        # uwsgi_pass  tamron;
32
+        proxy_pass  http://tamron;
33
+        include     /home/paiai/work/tamron/tamron/uwsgi/uwsgi_params; # the uwsgi_params file you installed
34
+    }
35
+}

+ 15 - 0
tamron/uwsgi.bak/uwsgi_params

@@ -0,0 +1,15 @@
1
+uwsgi_param	QUERY_STRING		$query_string;
2
+uwsgi_param	REQUEST_METHOD		$request_method;
3
+uwsgi_param	CONTENT_TYPE		$content_type;
4
+uwsgi_param	CONTENT_LENGTH		$content_length;
5
+
6
+uwsgi_param	REQUEST_URI		$request_uri;
7
+uwsgi_param	PATH_INFO		$document_uri;
8
+uwsgi_param	DOCUMENT_ROOT		$document_root;
9
+uwsgi_param	SERVER_PROTOCOL		$server_protocol;
10
+uwsgi_param	UWSGI_SCHEME		$scheme;
11
+
12
+uwsgi_param	REMOTE_ADDR		$remote_addr;
13
+uwsgi_param	REMOTE_PORT		$remote_port;
14
+uwsgi_param	SERVER_PORT		$server_port;
15
+uwsgi_param	SERVER_NAME		$server_name;

+ 17 - 0
tamron/wsgi.py

@@ -0,0 +1,17 @@
1
+"""
2
+WSGI config for tamron project.
3
+
4
+It exposes the WSGI callable as a module-level variable named ``application``.
5
+
6
+For more information on this file, see
7
+https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
8
+"""
9
+
10
+import os
11
+
12
+from django.core.wsgi import get_wsgi_application
13
+
14
+
15
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "tamron.settings")
16
+
17
+application = get_wsgi_application()

BIN
tamron/wsgi.pyc


+ 0 - 0
utils/__init__.py


BIN
utils/__init__.pyc


+ 0 - 0
utils/error/__init__.py


BIN
utils/error/__init__.pyc


+ 62 - 0
utils/error/errno_utils.py

@@ -0,0 +1,62 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+from StatusCode import BaseStatusCode, StatusCodeField
4
+
5
+
6
+class FranchiserStatusCode(BaseStatusCode):
7
+    """ 店员相关错误码 4001xx """
8
+    CHISER_NOT_FOUND = StatusCodeField(400001, 'Chiser Not Found', description=u'经销商不存在')
9
+
10
+
11
+class SaleclerkStatusCode(BaseStatusCode):
12
+    """ 店员相关错误码 4001xx """
13
+    CLERK_NOT_FOUND = StatusCodeField(400101, 'Clerk Not Found', description=u'店员不存在')
14
+    # 手机号
15
+    CLERK_PHONE_ALREADY_EXISTS = StatusCodeField(400105, 'Clerk Phone Already Exists', description=u'手机号已经存在')
16
+    # 状态
17
+    CLERK_ALREADY_NOT_UNVERIFIED = StatusCodeField(400110, 'Clerk Already Not Unverified', description=u'店员帐号已激活')
18
+    CLERK_NOT_ACTIVATED = StatusCodeField(400115, 'Clerk Not Activated', description=u'店员帐号未激活')
19
+
20
+
21
+class ProductModelStatusCode(BaseStatusCode):
22
+    """ 型号相关错误码 4010xx """
23
+    MODEL_NOT_FOUND = StatusCodeField(401001, 'Model Not Found', description=u'型号不存在')
24
+
25
+
26
+class ProductStatusCode(BaseStatusCode):
27
+    """ 产品相关错误码 4020xx """
28
+    PRODUCT_NOT_FOUND = StatusCodeField(402001, 'Product Not Found', description=u'产品不存在')
29
+    # 状态
30
+    PRODUCT_HAS_USED = StatusCodeField(402011, 'Product Has Used', description=u'产品已使用')
31
+
32
+
33
+class OrderStatusCode(BaseStatusCode):
34
+    """ 订单/支付相关错误码 4040xx """
35
+    WX_UNIFIED_ORDER_FAIL = StatusCodeField(404000, 'WX Unified Order Fail', description=u'微信统一下单失败')
36
+    WX_ORDER_NOT_FOUND = StatusCodeField(404001, 'WX Order Not Found', description=u'订单不存在')
37
+    WX_ORDER_NOT_PAY = StatusCodeField(404002, 'WX Order Not Pay', description=u'订单未支付')
38
+    WX_ORDER_PAYING = StatusCodeField(404003, 'WX Order Paying', description=u'订单支付中')
39
+    WX_ORDER_PAY_FAIL = StatusCodeField(404009, 'WX Order Pay Fail', description=u'微信支付失败')
40
+    SIGN_CHECK_FAIL = StatusCodeField(404010, 'Sign Check Fail', description=u'签名校验失败')
41
+    FEE_CHECK_FAIL = StatusCodeField(404011, 'FEE Check Fail', description=u'金额校验失败')
42
+    NO_DETAIL_PERMISSION = StatusCodeField(404015, 'No Detail Permission', description=u'无详情权限')
43
+    WX_ORDER_PAID_ALREADY_EXISTS = StatusCodeField(404020, 'WX Order Paid Already Exists', description=u'照片已购买')
44
+
45
+
46
+class PayStatusCode(BaseStatusCode):
47
+    """ 支付相关错误码 4041xx """
48
+
49
+
50
+class WithdrawStatusCode(BaseStatusCode):
51
+    """ 提现相关错误码 4042xx """
52
+    BALANCE_NOT_ENOUGH = StatusCodeField(404200, 'Balance Not Enough', description=u'提现金额不足')
53
+
54
+
55
+class MessageStatusCode(BaseStatusCode):
56
+    """ 消息相关错误码 4090xx """
57
+    MESSAGE_NOT_FOUND = StatusCodeField(409001, 'Message Not Found', description=u'消息不存在')
58
+
59
+
60
+class TokenStatusCode(BaseStatusCode):
61
+    """ 票据相关错误码 4090xx """
62
+    TOKEN_NOT_FOUND = StatusCodeField(409901, 'Token Not Found', description=u'票据不存在')

BIN
utils/error/errno_utils.pyc


+ 18 - 0
utils/error/response_utils.py

@@ -0,0 +1,18 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+from django.http import JsonResponse
4
+from StatusCode import StatusCodeField
5
+
6
+
7
+def response_data(status_code=200, message=None, description=None, data={}, **kwargs):
8
+    return dict({
9
+        'status': status_code,
10
+        'message': message,
11
+        'description': description,
12
+        'data': data,
13
+    }, **kwargs)
14
+
15
+
16
+def response(status_code=200, message=None, description=None, data={}, **kwargs):
17
+    message, description = (message or status_code.message, description or status_code.description) if isinstance(status_code, StatusCodeField) else (message, description)
18
+    return JsonResponse(response_data(status_code, message, description, data, **kwargs), safe=False)

BIN
utils/error/response_utils.pyc


+ 0 - 0
utils/redis/__init__.py


BIN
utils/redis/__init__.pyc


+ 6 - 0
utils/redis/connect.py

@@ -0,0 +1,6 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+from django.conf import settings
4
+
5
+
6
+r = settings.REDIS_CACHE

BIN
utils/redis/connect.pyc


+ 68 - 0
utils/redis/rkeys.py

@@ -0,0 +1,68 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+# 唯一标识相关
4
+UUID_LIST = 'uuid:list'  # List,唯一标识列表
5
+
6
+# 用户相关
7
+PROFILE_INFO = 'profile:info:%s'  # STRING,用户信息,user_id
8
+
9
+# 导游相关
10
+TOUR_GUIDE_GROUP_GEO_INFO = 'tour:guide:group:geo:info:%s'  # ZSET,旅游团地理位置信息,group_id
11
+TOUR_GUIDE_GROUP_GEO_SUBMIT_DT = 'tour:guide:group:geo:submit:dt:%s'  # ZSET,旅游团地理位置最后上传时间,group_id
12
+TOUR_GUIDE_GROUP_CUR_SESSION = 'tour:guide:group:cur:session:%s'  # STRING,旅游团当前Session,group_id,导游设置集合时间的时候更新
13
+TOUR_GUIDE_GROUP_CUR_GATHER_INFO = 'tour:guide:group:cur:gather:info:%s'  # STRING,旅游团当前Session,group_id,导游设置集合时间的时候更新
14
+TOUR_GUIDE_GROUP_USER_GEO_LIST = 'tour:guide:group:user:geo:list:%s:%s:%s'  # LIST,旅游团当前用户地理位置列表,group_id、session_id、user_id
15
+
16
+TOUR_GUIDE_GROUP_USER_OWN = 'tour:guide:group:user:own:%s'  # STRING,导游当前拥有的旅行团,user_id,导游创建旅行团的时候更新
17
+TOUR_GUIDE_GROUP_USER_BELONG = 'tour:guide:group:user:belong:%s'  # STRING,用户当前所属旅行团,user_id,用户加入旅行团的时候更新
18
+
19
+# 群组相关
20
+GROUP_INFO = 'group:info:%s'  # STRING,群组信息,group_id
21
+
22
+# 群组用户相关
23
+GROUP_USERS_INFO = 'group:users:info:%s'  # STRING,群组用户信息,group_id
24
+GROUP_USERS_KV_INFO = 'group:users:kv:info:%s'  # STRING,群组用户信息,group_id
25
+GROUP_USERS_APPLYING_SET = 'group:users:applying:set:%s'  # SET,群组用户申请集合,group_id
26
+GROUP_USERS_PASSED_SET = 'group:users:passed:set:%s'  # SET,群组用户通过集合,group_id
27
+GROUP_USERS_REFUSED_SET = 'group:users:refused:set:%s'  # SET,群组用户拒绝集合,group_id
28
+GROUP_USERS_DELETED_SET = 'group:users:deleted:set:%s'  # SET,群组用户移除集合,group_id
29
+GROUP_USERS_QUIT_SET = 'group:users:quit:set:%s'  # SET,群组用户退出集合,group_id
30
+
31
+# 群组照片相关
32
+GROUP_PHOTO_DATA = 'group:photo:data:%s'  # STRING,群组数据记录,group_id
33
+GROUP_PHOTO_THUMB_UP = 'group:photo:thumb:up:%s:%s'  # STRING,群组照片用户点赞记录,photo_id、user_id
34
+GROUP_PHOTO_COMMENT_LIST = 'group:photo:comment:list:%s'  # STRING,群组照片用户评论列表,photo_id
35
+GROUP_PHOTO_THUMB_UP_LIST = 'group:photo:thumb:up:list:%s'  # STRING,群组照片用户点赞列表,photo_id
36
+GROUP_PHOTO_WATCHER_SET = 'group:photo:watcher:set:%s'  # SET,群组照片用户关注集合,photo_id,关注即评论点赞
37
+GROUP_LAST_PHOTO_PK = 'group:last:photo:pk:%s'  # STRING,群组最后一张照片PK,group_id
38
+
39
+# 摄影师照片相关
40
+LENSMAN_PHOTO_ORDER_RECORD = 'lensman:photo:order:record:%s:%s'  # STRING,摄影师照片购买记录,photo_id、user_id
41
+
42
+# 摄影师简报相关
43
+# 收入
44
+TOTAL_INCOME = 'total:income:%s:%s'  # STRING,总收入,user_id、photo_type
45
+WEEK_INCOME = 'week:income:%s:%s:%s'  # STRING,周收入,user_id、photo_type、Week.thisweek().isoformat()
46
+TODAY_INCOME = 'today:income:%s:%s:%s'  # STRING,日收入,user_id、photo_type、tc.local_string(format='%Y%m%d')
47
+# 上传
48
+TODAY_UPLOAD_PHOTO_AMOUNT = 'today:upload:photo:amount:%s:%s'  # STRING,日上传照片数量,user_id、tc.local_string(format='%Y%m%d')
49
+# 售出
50
+WEEK_SOLD = 'week:sold:%s:%s:%s'  # STRING,周售出,user_id、photo_type、Week.thisweek().isoformat()
51
+
52
+# 摄影师定价相关
53
+LENSMAN_PHOTO_PRICE_FIXED = 'lensman:photo:price:fixed:%s'  # STRING,摄影师照片定价(单位:分),user_id
54
+
55
+# 系统消息相关
56
+SYSTEM_MESSAGE_READ_INFO = 'system:message:read:info:%s'  # STRING,系统消息读取信息,user_id
57
+SYSTEM_MESSAGE_DELETED_INFO = 'system:message:deleted:info:%s'  # STRING,系统消息删除信息,user_id
58
+
59
+# 游客入口相关
60
+GUEST_ENTRANCE_CONTROL_INFO = 'guest:entrance:control:info:%s'  # STRING,游客入口控制信息,src
61
+
62
+# APP 相关
63
+LATEST_APP_INFO = 'latest:app:info:%s'  # STRING,最新 APP 信息,src
64
+APP_SETTINGS_INFO = 'app:settings:info:%s:%s:%s'  # STRING,APP 设置信息,platform、channel、version
65
+APP_PATCH_INFO = 'app:patch:info:%s:%s:%s'  # STRING,APP 补丁信息,platform、version、src
66
+
67
+# BOX 相关
68
+BOX_PROGRAM_VERSION_INFO = 'box:program:version:info'  # STRING,BOX 程序版本信息

kodo - Gogs: Go Git Service

Aucune description

0013_auto_20180103_0446.py 2.8KB

    # -*- coding: utf-8 -*- # Generated by Django 1.11.3 on 2018-01-02 20:46 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('message', '0012_auto_20180101_2220'), ] operations = [ migrations.AlterField( model_name='systemmessagedeleteinfo', name='msg_id', field=models.CharField(blank=True, db_index=True, help_text='\u7cfb\u7edf\u6d88\u606f\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='msg_id'), ), migrations.AlterField( model_name='systemmessagedeleteinfo', name='user_id', field=models.CharField(blank=True, db_index=True, help_text='\u7528\u6237\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='user_id'), ), migrations.AlterField( model_name='systemmessagereadinfo', name='msg_id', field=models.CharField(blank=True, db_index=True, help_text='\u7cfb\u7edf\u6d88\u606f\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='msg_id'), ), migrations.AlterField( model_name='systemmessagereadinfo', name='user_id', field=models.CharField(blank=True, db_index=True, help_text='\u7528\u6237\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='user_id'), ), migrations.AlterField( model_name='usermessageinfo', name='from_uid', field=models.CharField(blank=True, db_index=True, help_text='\u53d1\u9001\u6d88\u606f\u7528\u6237\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='from_uid'), ), migrations.AlterField( model_name='usermessageinfo', name='group_id', field=models.CharField(blank=True, db_index=True, help_text='\u7fa4\u7ec4\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='group_id'), ), migrations.AlterField( model_name='usermessageinfo', name='msg_type', field=models.CharField(db_index=True, default=b'system', help_text='\u6d88\u606f\u7c7b\u578b', max_length=8, verbose_name='msg_type'), ), migrations.AlterField( model_name='usermessageinfo', name='photo_id', field=models.CharField(blank=True, db_index=True, help_text='\u98de\u56fe\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='photo_id'), ), migrations.AlterField( model_name='usermessageinfo', name='to_uid', field=models.CharField(blank=True, db_index=True, help_text='\u63a5\u6536\u6d88\u606f\u7528\u6237\u552f\u4e00\u6807\u8bc6', max_length=32, null=True, verbose_name='to_uid'), ), ]