32
     """
@@ -46,7 +46,7 @@ def tg_group_create_api(request):
46 46
     if not user.istourguide:
47 47
         return response(GroupStatusCode.NOT_GROUP_ADMIN)
48 48
 
49
-    # 导游团校验
49
+    # 旅行团校验
50 50
     if GroupInfo.objects.filter(
51 51
         admin_id=user_id,
52 52
         group_closed=False,
@@ -65,6 +65,8 @@ def tg_group_create_api(request):
65 65
         group_name=group_name,
66 66
         group_default_avatar=group_default_avatar,
67 67
         group_from=GroupInfo.TOURGUIDE_GROUP,
68
+        name=user.name,
69
+        phone=user.phone,
68 70
         started_at=started_at,
69 71
         ended_at=ended_at,
70 72
     )
@@ -87,10 +89,10 @@ def tg_group_create_api(request):
87 89
     # Redis 群组用户数据缓存
88 90
     group_users = set_group_users_info(group)
89 91
 
90
-    # Redis 设置导游拥有的导游团
92
+    # Redis 设置导游拥有的旅行团
91 93
     set_tour_guide_own_group(user_id, group_id)
92 94
 
93
-    return response(200, 'Create Tour Guide Group Success', u'导游团创建成功', {
95
+    return response(200, 'Create Tour Guide Group Success', u'旅行团创建成功', {
94 96
         'group_id': group_id,
95 97
         'group': group_info,
96 98
         'users': group_users,
@@ -100,14 +102,14 @@ def tg_group_create_api(request):
100 102
 @logit
101 103
 def tg_group_detail_api(request):
102 104
     """
103
-    导游团详情
105
+    旅行团详情
104 106
     :param request:
105 107
     :return:
106 108
     """
107 109
     group_id = request.POST.get('group_id', '')
108 110
     user_id = request.POST.get('user_id', '')
109 111
 
110
-    return response(200, 'Get Tour Guide Group Detail Info Success', u'获取导游团详情成功', {
112
+    return response(200, 'Get Tour Guide Group Detail Info Success', u'获取旅行团详情成功', {
111 113
         'group_id': group_id,
112 114
         'group': get_group_info(group_id),
113 115
         'users': get_group_users_info(group_id, user_id),
@@ -117,7 +119,7 @@ def tg_group_detail_api(request):
117 119
 @logit
118 120
 def tg_group_update_api(request):
119 121
     """
120
-    导游团更新
122
+    旅行团更新
121 123
     :param request:
122 124
     :return:
123 125
     """
@@ -128,8 +130,8 @@ def tg_group_update_api(request):
128 130
 
129 131
     group_avatar = request.FILES.get('group_avatar', '')
130 132
 
131
-    started_at = request.POST.get('started_at', '')
132
-    ended_at = request.POST.get('ended_at', '')
133
+    started_at = request.POST.get('started_at', '')  # UTC, %Y-%m-%dT%H:%M:%SZ
134
+    ended_at = request.POST.get('ended_at', '')  # UTC, %Y-%m-%dT%H:%M:%SZ
133 135
 
134 136
     # 群组校验
135 137
     try:
@@ -173,7 +175,7 @@ def tg_group_update_api(request):
173 175
 @logit
174 176
 def tg_group_close_api(request):
175 177
     """
176
-    导游团关闭
178
+    旅行团关闭
177 179
     :param request:
178 180
     :return:
179 181
     """
@@ -198,19 +200,19 @@ def tg_group_close_api(request):
198 200
     # Redis 群组数据缓存更新
199 201
     set_group_info(group)
200 202
 
201
-    return response(200, u'Close Tour Guide Group Success', u'导游团关闭成功')
203
+    return response(200, u'Close Tour Guide Group Success', u'旅行团关闭成功')
202 204
 
203 205
 
204 206
 @logit
205 207
 def tg_group_gather_start_api(request):
206 208
     """
207
-    导游团设置集合时间和地点
209
+    旅行团设置集合时间和地点
208 210
     :param request:
209 211
     :return:
210 212
     """
211 213
     group_id = request.POST.get('group_id', '')
212 214
     admin_id = request.POST.get('admin_id', '') or request.POST.get('user_id', '')
213
-    gather_at = request.POST.get('gather_at', '')
215
+    gather_at = request.POST.get('gather_at', '')  # UTC, %Y-%m-%dT%H:%M:%SZ
214 216
     gather_lon = request.POST.get('lon', '')  # 经度
215 217
     gather_lat = request.POST.get('lat', '')  # 纬度
216 218
 
@@ -236,4 +238,4 @@ def tg_group_gather_start_api(request):
236 238
     # 更新Session
237 239
     r.set(TOUR_GUIDE_GROUP_CUR_SESSION, shortuuid.uuid())
238 240
 
239
-    return response(200, u'Set Tour Guide Group Gather Info Success', u'设置导游团集合信息成功')
241
+    return response(200, u'Set Tour Guide Group Gather Info Success', u'设置旅行团集合信息成功')

+ 7 - 7
group/tourguidegroupuser_views.py

@@ -26,7 +26,7 @@ r = settings.REDIS_CACHE
26 26
 @logit
27 27
 def tgu_group_user_join_api(request):
28 28
     """
29
-    导游团用户加群
29
+    旅行团用户加群
30 30
     :param request:
31 31
     :return:
32 32
     """
@@ -34,7 +34,7 @@ def tgu_group_user_join_api(request):
34 34
     user_id = request.POST.get('user_id', '')
35 35
     nickname = request.POST.get('nickname', '')
36 36
 
37
-    # 获取导游团唯一标识
37
+    # 获取旅行团唯一标识
38 38
     group_id = get_tour_guide_own_group(admin_id)
39 39
 
40 40
     # 用户校验
@@ -92,7 +92,7 @@ def tgu_group_user_join_api(request):
92 92
 @logit
93 93
 def tgu_group_user_update_api(request):
94 94
     """
95
-    导游团用户更新
95
+    旅行团用户更新
96 96
     :param request:
97 97
     :return:
98 98
     """
@@ -141,7 +141,7 @@ def tgu_group_user_update_api(request):
141 141
 @logit
142 142
 def tgu_group_user_locations_api(request):
143 143
     """
144
-    导游团所有用户位置信息
144
+    旅行团所有用户位置信息
145 145
     :param request:
146 146
     :return:
147 147
     """
@@ -152,7 +152,7 @@ def tgu_group_user_locations_api(request):
152 152
     if not GroupUserInfo.objects.filter(group_id=group_id, user_id=admin_id, subadmin=True, status=True).exists():
153 153
         return response(GroupStatusCode.NO_LOCATION_PERMISSION)
154 154
 
155
-    return response(200, 'Get Tour Guide Group All User Location Success', u'获取导游团用户地理位置信息成功', {
155
+    return response(200, 'Get Tour Guide Group All User Location Success', u'获取旅行团用户地理位置信息成功', {
156 156
         'group_id': group_id,
157 157
         'locations': r.georadius(TOUR_GUIDE_GROUP_GEO_INFO % group_id, 0, 0, '+inf', unit='m', withdist=True, withcoord=True, sort='ASC')
158 158
         # 'locations': [['x', 0.33, (2.68220901489e-06, 1.26736058093e-06)]]
@@ -162,7 +162,7 @@ def tgu_group_user_locations_api(request):
162 162
 @logit
163 163
 def tgu_group_user_location_api(request):
164 164
     """
165
-    导游团单个用户位置信息
165
+    旅行团单个用户位置信息
166 166
     :param request:
167 167
     :return:
168 168
     """
@@ -177,7 +177,7 @@ def tgu_group_user_location_api(request):
177 177
     session_id = r.get(TOUR_GUIDE_GROUP_CUR_SESSION % group_id)
178 178
     locations = r.lrange(TOUR_GUIDE_GROUP_USER_GEO_LIST % (group_id, session_id, user_id), 0, -1)
179 179
 
180
-    return response(200, 'Get Tour Guide Group User Location Success', u'获取导游团用户地理位置信息成功', {
180
+    return response(200, 'Get Tour Guide Group User Location Success', u'获取旅行团用户地理位置信息成功', {
181 181
         'group_id': group_id,
182 182
         'user_id': user_id,
183 183
         'locations': [json.loads(loc) for loc in locations]

+ 2 - 1
message/models.py

@@ -3,6 +3,7 @@
3 3
 from django.conf import settings
4 4
 from django.db import models
5 5
 from django.utils.translation import ugettext_lazy as _
6
+from TimeConvert import TimeConvert as tc
6 7
 
7 8
 from group.models import GroupPhotoInfo
8 9
 from pai2.basemodels import CreateUpdateMixin
@@ -72,7 +73,7 @@ class UserMessageInfo(CreateUpdateMixin):
72 73
             'msg_title': self.msg_title,
73 74
             'msg_content': self.msg_content,
74 75
             'read': self.read,
75
-            'created_at': self.created_at.replace(microsecond=0),
76
+            'created_at': tc.remove_microsecond(self.created_at),
76 77
         }
77 78
 
78 79
 

+ 3 - 2
pay/models.py

@@ -3,6 +3,7 @@
3 3
 from django.db import models
4 4
 from django.utils.translation import ugettext_lazy as _
5 5
 from shortuuidfield import ShortUUIDField
6
+from TimeConvert import TimeConvert as tc
6 7
 
7 8
 from group.models import GroupPhotoInfo
8 9
 from pai2.basemodels import CreateUpdateMixin
@@ -96,8 +97,8 @@ class OrderInfo(CreateUpdateMixin):
96 97
             'body': self.body,
97 98
             'total_fee': self.total_fee,
98 99
             'pay_status': self.pay_status,
99
-            'paid_at': self.paid_at and self.paid_at.replace(microsecond=0),
100
-            'created_at': self.created_at.replace(microsecond=0),
100
+            'paid_at': tc.remove_microsecond(self.paid_at),
101
+            'created_at': tc.remove_microsecond(self.created_at),
101 102
         }
102 103
 
103 104
     @property

+ 1 - 1
utils/error/errno_utils.py

@@ -80,7 +80,7 @@ class GroupUserStatusCode(BaseStatusCode):
80 80
     GROUP_USER_NOT_FOUND = StatusCodeField(402101, u'Group User Not Found', description=u'群组用户不存在')
81 81
     GROUP_USER_HAS_DELETED = StatusCodeField(402102, u'Group User Has Deleted', description=u'群组用户被移除')
82 82
 
83
-    USER_HAS_NOT_JOIN_GROUP = StatusCodeField(402131, u'User Has Not Join Group', description=u'用户未加入导游团')
83
+    USER_HAS_NOT_JOIN_GROUP = StatusCodeField(402131, u'User Has Not Join Group', description=u'用户未加入旅行团')
84 84
 
85 85
 
86 86
 class GroupPhotoStatusCode(BaseStatusCode):

+ 2 - 2
utils/redis/rkeys.py

@@ -11,8 +11,8 @@ TOUR_GUIDE_GROUP_GEO_INFO = 'tour:guide:group:geo:info:%s'  # ZSET,旅游团
11 11
 TOUR_GUIDE_GROUP_CUR_SESSION = 'tour:guide:group:cur:session:%s'  # STRING,旅游团当前Session,group_id,导游设置集合时间的时候更新
12 12
 TOUR_GUIDE_GROUP_USER_GEO_LIST = 'tour:guide:group:user:geo:list:%s:%s:%s'  # LIST,旅游团当前用户地理位置列表,group_id、session_id、user_id
13 13
 
14
-TOUR_GUIDE_GROUP_USER_OWN = 'tour:guide:group:user:own:%s'  # STRING,导游当前拥有的导游团,user_id,导游创建导游团的时候更新
15
-TOUR_GUIDE_GROUP_USER_BELONG = 'tour:guide:group:user:belong:%s'  # STRING,用户当前所属导游团,user_id,用户加入导游团的时候更新
14
+TOUR_GUIDE_GROUP_USER_OWN = 'tour:guide:group:user:own:%s'  # STRING,导游当前拥有的旅行团,user_id,导游创建旅行团的时候更新
15
+TOUR_GUIDE_GROUP_USER_BELONG = 'tour:guide:group:user:belong:%s'  # STRING,用户当前所属旅行团,user_id,用户加入旅行团的时候更新
16 16
 
17 17
 # 群组相关
18 18
 GROUP_INFO = 'group:info:%s'  # STRING,群组信息,group_id

+ 2 - 2
utils/redis/rtourguide.py

@@ -12,10 +12,10 @@ r = settings.REDIS_CACHE
12 12
 
13 13
 
14 14
 def set_tour_guide_own_group(user_id, group_id):
15
-    """ 设置导游拥有的导游团 """
15
+    """ 设置导游拥有的旅行团 """
16 16
     r.set(TOUR_GUIDE_GROUP_USER_OWN % user_id, group_id)
17 17
 
18 18
 
19 19
 def get_tour_guide_own_group(user_id):
20
-    """ 获取导游拥有的导游团 """
20
+    """ 获取导游拥有的旅行团 """
21 21
     return r.get(TOUR_GUIDE_GROUP_USER_OWN % user_id)

adminSystem - Gogs: Go Git Service

Нет описания

FFIB: 11e3a9652a first лет %!s(int64=8): %!d(string=назад)
..
lib 11e3a9652a first лет %!s(int64=8): %!d(string=назад)
History.md 11e3a9652a first лет %!s(int64=8): %!d(string=назад)
LICENSE 11e3a9652a first лет %!s(int64=8): %!d(string=назад)
Readme.md 11e3a9652a first лет %!s(int64=8): %!d(string=назад)
index.js 11e3a9652a first лет %!s(int64=8): %!d(string=назад)
package.json 11e3a9652a first лет %!s(int64=8): %!d(string=назад)

Readme.md

depd

NPM Version NPM Downloads Node.js Version Linux Build Windows Build Coverage Status Gratipay

Deprecate all the things

With great modules comes great responsibility; mark things deprecated!

Install

This module is installed directly using npm:

$ npm install depd

This module can also be bundled with systems like Browserify or webpack, though by default this module will alter it's API to no longer display or track deprecations.

API

var deprecate = require('depd')('my-module')

This library allows you to display deprecation messages to your users. This library goes above and beyond with deprecation warnings by introspection of the call stack (but only the bits that it is interested in).

Instead of just warning on the first invocation of a deprecated function and never again, this module will warn on the first invocation of a deprecated function per unique call site, making it ideal to alert users of all deprecated uses across the code base, rather than just whatever happens to execute first.

The deprecation warnings from this module also include the file and line information for the call into the module that the deprecated function was in.

NOTE this library has a similar interface to the debug module, and this module uses the calling file to get the boundary for the call stacks, so you should always create a new deprecate object in each file and not within some central file.

depd(namespace)

Create a new deprecate function that uses the given namespace name in the messages and will display the call site prior to the stack entering the file this function was called from. It is highly suggested you use the name of your module as the namespace.

deprecate(message)

Call this function from deprecated code to display a deprecation message. This message will appear once per unique caller site. Caller site is the first call site in the stack in a different file from the caller of this function.

If the message is omitted, a message is generated for you based on the site of the deprecate() call and will display the name of the function called, similar to the name displayed in a stack trace.

deprecate.function(fn, message)

Call this function to wrap a given function in a deprecation message on any call to the function. An optional message can be supplied to provide a custom message.

deprecate.property(obj, prop, message)

Call this function to wrap a given property on object in a deprecation message on any accessing or setting of the property. An optional message can be supplied to provide a custom message.

The method must be called on the object where the property belongs (not inherited from the prototype).

If the property is a data descriptor, it will be converted to an accessor descriptor in order to display the deprecation message.

process.on('deprecation', fn)

This module will allow easy capturing of deprecation errors by emitting the errors as the type "deprecation" on the global process. If there are no listeners for this type, the errors are written to STDERR as normal, but if there are any listeners, nothing will be written to STDERR and instead only emitted. From there, you can write the errors in a different format or to a logging source.

The error represents the deprecation and is emitted only once with the same rules as writing to STDERR. The error has the following properties:

  • message - This is the message given by the library
  • name - This is always 'DeprecationError'
  • namespace - This is the namespace the deprecation came from
  • stack - This is the stack of the call to the deprecated thing

Example error.stack output:

DeprecationError: my-cool-module deprecated oldfunction
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:456:26)
    at evalScript (node.js:532:25)
    at startup (node.js:80:7)
    at node.js:902:3

process.env.NO_DEPRECATION

As a user of modules that are deprecated, the environment variable NO_DEPRECATION is provided as a quick solution to silencing deprecation warnings from being output. The format of this is similar to that of DEBUG:

$ NO_DEPRECATION=my-module,othermod node app.js

This will suppress deprecations from being output for "my-module" and "othermod". The value is a list of comma-separated namespaces. To suppress every warning across all namespaces, use the value * for a namespace.

Providing the argument --no-deprecation to the node executable will suppress all deprecations (only available in Node.js 0.8 or higher).

NOTE This will not suppress the deperecations given to any "deprecation" event listeners, just the output to STDERR.

process.env.TRACE_DEPRECATION

As a user of modules that are deprecated, the environment variable TRACE_DEPRECATION is provided as a solution to getting more detailed location information in deprecation warnings by including the entire stack trace. The format of this is the same as NO_DEPRECATION:

$ TRACE_DEPRECATION=my-module,othermod node app.js

This will include stack traces for deprecations being output for "my-module" and "othermod". The value is a list of comma-separated namespaces. To trace every warning across all namespaces, use the value * for a namespace.

Providing the argument --trace-deprecation to the node executable will trace all deprecations (only available in Node.js 0.8 or higher).

NOTE This will not trace the deperecations silenced by NO_DEPRECATION.

Display

message

When a user calls a function in your library that you mark deprecated, they will see the following written to STDERR (in the given colors, similar colors and layout to the debug module):

bright cyan    bright yellow
|              |          reset       cyan
|              |          |           |
▼              ▼          ▼           ▼
my-cool-module deprecated oldfunction [eval]-wrapper:6:22
▲              ▲          ▲           ▲
|              |          |           |
namespace      |          |           location of mycoolmod.oldfunction() call
               |          deprecation message
               the word "deprecated"

If the user redirects their STDERR to a file or somewhere that does not support colors, they see (similar layout to the debug module):

Sun, 15 Jun 2014 05:21:37 GMT my-cool-module deprecated oldfunction at [eval]-wrapper:6:22
▲                             ▲              ▲          ▲              ▲
|                             |              |          |              |
timestamp of message          namespace      |          |             location of mycoolmod.oldfunction() call
                                             |          deprecation message
                                             the word "deprecated"

Examples

Deprecating all calls to a function

This will display a deprecated message about "oldfunction" being deprecated from "my-module" on STDERR.

var deprecate = require('depd')('my-cool-module')

// message automatically derived from function name
// Object.oldfunction
exports.oldfunction = deprecate.function(function oldfunction () {
  // all calls to function are deprecated
})

// specific message
exports.oldfunction = deprecate.function(function () {
  // all calls to function are deprecated
}, 'oldfunction')

Conditionally deprecating a function call

This will display a deprecated message about "weirdfunction" being deprecated from "my-module" on STDERR when called with less than 2 arguments.

var deprecate = require('depd')('my-cool-module')

exports.weirdfunction = function () {
  if (arguments.length < 2) {
    // calls with 0 or 1 args are deprecated
    deprecate('weirdfunction args < 2')
  }
}

When calling deprecate as a function, the warning is counted per call site within your own module, so you can display different deprecations depending on different situations and the users will still get all the warnings:

var deprecate = require('depd')('my-cool-module')

exports.weirdfunction = function () {
  if (arguments.length < 2) {
    // calls with 0 or 1 args are deprecated
    deprecate('weirdfunction args < 2')
  } else if (typeof arguments[0] !== 'string') {
    // calls with non-string first argument are deprecated
    deprecate('weirdfunction non-string first arg')
  }
}

Deprecating property access

This will display a deprecated message about "oldprop" being deprecated from "my-module" on STDERR when accessed. A deprecation will be displayed when setting the value and when getting the value.

var deprecate = require('depd')('my-cool-module')

exports.oldprop = 'something'

// message automatically derives from property name
deprecate.property(exports, 'oldprop')

// explicit message
deprecate.property(exports, 'oldprop', 'oldprop >= 0.10')

License

MIT