a842270R10">10
+    except ImportError:
11
+        # The above import may fail for some other reason. Ensure that the
12
+        # issue is really that Django is missing to avoid masking other
13
+        # exceptions on Python 2.
14
+        try:
15
+            import django
16
+        except ImportError:
17
+            raise ImportError(
18
+                "Couldn't import Django. Are you sure it's installed and "
19
+                "available on your PYTHONPATH environment variable? Did you "
20
+                "forget to activate a virtual environment?"
21
+            )
22
+        raise
23
+    execute_from_command_line(sys.argv)

+ 9 - 0
pep8.sh

@@ -0,0 +1,9 @@
1
+#!/bin/bash
2
+
3
+# Ignoring autogenerated files
4
+#  -- Migration directories
5
+# Ignoring error codes
6
+#  -- E128 continuation line under-indented for visual indent
7
+#  -- E501 line too long
8
+
9
+pycodestyle --exclude=migrations --ignore=E128,E501 .

+ 37 - 0
requirements.txt

@@ -0,0 +1,37 @@
1
+-e git+https://github.com/Brightcells/django-q.git#egg=django-q
2
+CodeConvert==2.0.4
3
+Django==1.8.4
4
+MySQL-python==1.2.5
5
+Pillow==4.3.0
6
+StatusCode==1.0.0
7
+TimeConvert==1.4.1
8
+cryptography==2.0.3
9
+django-curtail-uuid==1.0.0
10
+django-detect==1.0.5
11
+django-file-md5==1.0.1
12
+django-ip==1.0.2
13
+django-json-response==1.1.5
14
+django-logit==1.0.6
15
+django-multidomain==1.1.4
16
+django-paginator2==1.0.3
17
+django-rlog==1.0.7
18
+django-shortuuidfield==0.1.3
19
+django-six==1.0.4
20
+djangorestframework==3.7.3
21
+furl==1.0.1
22
+hiredis==0.2.0
23
+isoweek==1.3.3
24
+jsonfield==2.0.2
25
+mock==2.0.0
26
+pysnippets==1.0.4
27
+pywe-miniapp==1.0.0
28
+pywe-oauth==1.0.5
29
+pywe-response==1.0.1
30
+qiniu==7.1.9
31
+redis==2.10.6
32
+redis-extensions==1.1.5
33
+requests==2.18.4
34
+rlog==0.3
35
+shortuuid==0.5.0
36
+uWSGI==2.0.15
37
+versions==0.10.0

+ 0 - 0
tamron/__init__.py


+ 14 - 0
tamron/admin.py

@@ -0,0 +1,14 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+from djadmin import ExportExcelModelAdmin, ReadonlyModelAdmin
4
+from django.contrib import admin
5
+
6
+from tamron.models import TamronSliderInfo
7
+
8
+
9
+class TamronSliderInfoAdmin(admin.ModelAdmin):
10
+    list_display = ('fid', 'pic', 'url', 'px')
11
+    list_filter = ('fid', )
12
+
13
+
14
+admin.site.register(TamronSliderInfo, TamronSliderInfoAdmin)

+ 8 - 0
tamron/apps.py

@@ -0,0 +1,8 @@
1
+# -*- coding: utf-8 -*-
2
+from __future__ import unicode_literals
3
+
4
+from django.apps import AppConfig
5
+
6
+
7
+class TamronConfig(AppConfig):
8
+    name = 'tamron'

+ 0 - 0
tamron/migrations/__init__.py


+ 28 - 0
tamron/models.py

@@ -0,0 +1,28 @@
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 upload_path
6
+
7
+
8
+class TamronSliderInfo(models.Model):
9
+    HOME = 1
10
+    PGIST = 2
11
+
12
+    SLIEDER_TYPE_TUPLE = (
13
+        (HOME, u'首页轮播图'),
14
+        (PGIST, u'产品注册页轮播图'),
15
+    )
16
+
17
+    fid = models.IntegerField(_(u'fid'), choices=SLIEDER_TYPE_TUPLE, default=HOME, help_text=u'轮播图类型')
18
+    pic = models.FileField(_(u'pic'), upload_to=upload_path, blank=True, null=True, help_text=u'轮播图图片')
19
+    url = models.CharField(_(u'url'), max_length=255, blank=True, null=True, help_text=u'轮播图链接')
20
+    px = models.IntegerField(_(u'px'), default=1, help_text=u'???')
21
+
22
+    class Meta:
23
+        verbose_name = _(u'轮播图')
24
+        verbose_name_plural = _(u'轮播图')
25
+        db_table = 'shidu_banner'
26
+
27
+    def __unicode__(self):
28
+        return unicode(self.pk)

+ 7 - 0
tamron/tests.py

@@ -0,0 +1,7 @@
1
+# -*- coding: utf-8 -*-
2
+from __future__ import unicode_literals
3
+
4
+from django.test import TestCase
5
+
6
+
7
+# Create your tests here.

+ 7 - 0
tamron/views.py

@@ -0,0 +1,7 @@
1
+# -*- coding: utf-8 -*-
2
+from __future__ import unicode_literals
3
+
4
+from django.shortcuts import render
5
+
6
+
7
+# Create your views here.

+ 0 - 0
tamrondb/__init__.py


+ 149 - 0
tamrondb/settings.py

@@ -0,0 +1,149 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+"""
4
+Django settings for tamrondb project.
5
+
6
+Generated by 'django-admin startproject' using Django 1.11.3.
7
+
8
+For more information on this file, see
9
+https://docs.djangoproject.com/en/1.11/topics/settings/
10
+
11
+For the full list of settings and their values, see
12
+https://docs.djangoproject.com/en/1.11/ref/settings/
13
+"""
14
+
15
+import os
16
+
17
+
18
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
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.11/howto/deployment/checklist/
25
+
26
+# SECURITY WARNING: keep the secret key used in production secret!
27
+SECRET_KEY = '70^&x-7y*t1^osbm8c4-oy3vje+2&ph$j)n&)_q)j%7r%-fjy)'
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
+    'tamron',
45
+]
46
+
47
+MIDDLEWARE = [
48
+    'django.middleware.security.SecurityMiddleware',
49
+    'django.contrib.sessions.middleware.SessionMiddleware',
50
+    'django.middleware.common.CommonMiddleware',
51
+    'django.middleware.csrf.CsrfViewMiddleware',
52
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
53
+    'django.contrib.messages.middleware.MessageMiddleware',
54
+    'django.middleware.clickjacking.XFrameOptionsMiddleware',
55
+]
56
+
57
+ROOT_URLCONF = 'tamrondb.urls'
58
+
59
+TEMPLATES = [
60
+    {
61
+        'BACKEND': 'django.template.backends.django.DjangoTemplates',
62
+        'DIRS': [],
63
+        'APP_DIRS': True,
64
+        'OPTIONS': {
65
+            'context_processors': [
66
+                'django.template.context_processors.debug',
67
+                'django.template.context_processors.request',
68
+                'django.contrib.auth.context_processors.auth',
69
+                'django.contrib.messages.context_processors.messages',
70
+            ],
71
+        },
72
+    },
73
+]
74
+
75
+WSGI_APPLICATION = 'tamrondb.wsgi.application'
76
+
77
+
78
+# Database
79
+# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
80
+
81
+DATABASES = {
82
+    'default': {
83
+        'ENGINE': 'django.db.backends.mysql',
84
+        'NAME': 'tenglong',
85
+        'USER': 'root',
86
+        'PASSWORD': '',
87
+        'HOST': '127.0.0.1',
88
+        'PORT': 3306,
89
+        'CONN_MAX_AGE': 600,
90
+        'OPTIONS': {
91
+            'charset': 'utf8mb4',
92
+        },
93
+    }
94
+}
95
+
96
+
97
+# Password validation
98
+# https://docs.djangoproject.com/en/1.11/ref/settings/#auth-password-validators
99
+
100
+AUTH_PASSWORD_VALIDATORS = [
101
+    {
102
+        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
103
+    },
104
+    {
105
+        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
106
+    },
107
+    {
108
+        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
109
+    },
110
+    {
111
+        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
112
+    },
113
+]
114
+
115
+
116
+# Internationalization
117
+# https://docs.djangoproject.com/en/1.11/topics/i18n/
118
+
119
+LANGUAGE_CODE = 'zh-Hans'
120
+
121
+TIME_ZONE = 'Asia/Shanghai'
122
+
123
+USE_I18N = True
124
+
125
+USE_L10N = True
126
+
127
+USE_TZ = True
128
+
129
+
130
+# Static files (CSS, JavaScript, Images)
131
+# https://docs.djangoproject.com/en/1.11/howto/static-files/
132
+
133
+STATICFILES_DIRS = (
134
+    os.path.join(PROJ_DIR, 'static').replace('\\', '/'),
135
+)
136
+
137
+STATIC_ROOT = os.path.join(BASE_DIR, 'collect_static').replace('\\', '/')
138
+
139
+STATIC_URL = '/static/'
140
+
141
+STATICFILES_FINDERS = (
142
+    'django.contrib.staticfiles.finders.FileSystemFinder',
143
+    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
144
+    # 'django.contrib.staticfiles.finders.DefaultStorageFinder',
145
+)
146
+
147
+MEDIA_ROOT = os.path.join(BASE_DIR, 'media').replace('\\', '/')
148
+
149
+MEDIA_URL = '/media/'

+ 22 - 0
tamrondb/urls.py

@@ -0,0 +1,22 @@
1
+"""tamrondb URL Configuration
2
+
3
+The `urlpatterns` list routes URLs to views. For more information please see:
4
+    https://docs.djangoproject.com/en/1.11/topics/http/urls/
5
+Examples:
6
+Function views
7
+    1. Add an import:  from my_app import views
8
+    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
9
+Class-based views
10
+    1. Add an import:  from other_app.views import Home
11
+    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
12
+Including another URLconf
13
+    1. Import the include() function: from django.conf.urls import url, include
14
+    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
15
+"""
16
+from django.conf.urls import url
17
+from django.contrib import admin
18
+
19
+
20
+urlpatterns = [
21
+    url(r'^admin/', admin.site.urls),
22
+]

+ 17 - 0
tamrondb/wsgi.py

@@ -0,0 +1,17 @@
1
+"""
2
+WSGI config for tamrondb 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.11/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", "tamrondb.settings")
16
+
17
+application = get_wsgi_application()

kodo - Gogs: Go Git Service

Nav apraksta

subscribe.py 3.4KB

    # -*- coding: utf-8 -*-' import json import requests from django.conf import settings class KuaiDi100: def __init__(self): self.key = settings.KUAIDI00.get('key', '') # TODO 客户授权key self.url = 'https://poll.kuaidi100.com/poll' # 请求地址 def submit(self, com, num, phone=None, ship_from=None, ship_to=None, callbackurl=None): """ 物流轨迹订阅 :param com: 快递公司编码 :param num: 快递单号 :param phone: 收件人或寄件人的手机号或固话(也可以填写后四位,如果是固话,请不要上传分机号) :param ship_from: 出发地城市,省-市-区,非必填,填了有助于提升签收状态的判断的准确率,请尽量提供 :param ship_to: 目的地城市,省-市-区,非必填,填了有助于提升签收状态的判断的准确率,且到达目的地后会加大监控频率,请尽量提供 :return: requests.Response.text """ param = { 'company': com, 'number': num, 'from': ship_from, 'to': ship_to, 'key': self.key, 'parameters': { 'callbackurl': callbackurl, # 'callbackurl': 'https://www.baidu.com/kd100/callback', # 回调接口的地址。如果需要在推送信息回传自己业务参数,可以在回调地址URL后面拼接上去,例如:https://www.baidu.com/kd100/callback?orderId=123 'salt': None, # 签名用随机字符串。32位自定义字符串。添加该参数,则推送的时候会增加sign给贵司校验消息的可靠性 'resultv2': '1', # 添加此字段表示开通行政区域解析功能。0:关闭(默认),1:开通行政区域解析功能 'autoCom': '0', # 添加此字段且将此值设为1,则表示开始智能判断单号所属公司的功能,开启后,company字段可为空,即只传运单号(number字段),我方收到后会根据单号判断出其所属的快递公司(即company字段)。建议只有在无法知道单号对应的快递公司(即company的值)的情况下才开启此功能 'interCom': '0', # 添加此字段且将此值设为1,则表示开启国际版,开启后,若订阅的单号(即number字段)属于国际单号,会返回出发国与目的国两个国家的跟踪信息,本功能暂时只支持邮政体系(国际类的邮政小包、EMS)内的快递公司,若单号我方识别为非国际单,即使添加本字段,也不会返回destResult元素组 'departureCountry': '', # 出发国家编码,interCom=1的国际单号最好提供该值 'departureCom': '', # 出发国家快递公司的编码,interCom=1的国际单号最好提供该值 'destinationCountry': '', # 目的国家编码,interCom=1的国际单号最好提供该值 'destinationCom': '', # 目的国家快递公司的编码,interCom=1的国际单号最好提供该值 'phone': phone } } req_params = { 'schema': 'json', # 查询公司编号 'param': json.dumps(param) # 参数数据 } return requests.post(self.url, req_params).text # 发送请求 # result = KuaiDi100().submit('yuantong', 'YT9693083639795', '', '江门市', '深圳市') # print(result)