Check tour guide group whether ended

Brightcells лет %!s(int64=8): %!d(string=назад)
Родитель
Сommit
d19a7d5efb
2 измененных файлов с 9 добавлено и 1 удалено
  1. 7 0
      group/tourguidegroup_views.py
  2. 2 1
      utils/error/errno_utils.py

+ 7 - 0
group/tourguidegroup_views.py

@@ -135,6 +135,13 @@ def pai2_tginfo_api(request):
135 135
         return response(GroupUserStatusCode.USER_HAS_NOT_JOIN_GROUP)
136 136
 
137 137
     group_info = get_group_info(group_id)
138
+
139
+    # Check whether ended
140
+    ended_at = group_info.get('ended_at', '')
141
+    if ended_at and tc.utc_datetime() > (tc.utc_string_to_utc_datetime(ended_at, format='%Y-%m-%dT%H:%M:%SZ') if isinstance(ended_at, basestring) else ended_at):
142
+        return response(GroupStatusCode.GROUP_HAS_ENDED)
143
+
144
+    # Check gather info
138 145
     gather_at = group_info.get('gather_at', '')
139 146
     if gather_at and tc.utc_datetime() > (tc.utc_string_to_utc_datetime(gather_at, format='%Y-%m-%dT%H:%M:%SZ') if isinstance(gather_at, basestring) else gather_at):
140 147
         group_info['gather_at'] = ''

+ 2 - 1
utils/error/errno_utils.py

@@ -73,7 +73,8 @@ class GroupStatusCode(BaseStatusCode):
73 73
     DUPLICATE_JOIN_REQUEST = StatusCodeField(402020, 'Duplicate Join Request', description=u'重复加群申请')
74 74
     JOIN_REQUEST_NOT_FOUND = StatusCodeField(402021, 'Join Request Not Found', description=u'加群申请不存在')
75 75
     # 旅行团
76
-    COULD_HAVE_ONLY_ONE_ACTIVE_GROUP = StatusCodeField(402030, 'Could Have Only One Active Group', description=u'只能创建一个活跃团')
76
+    GROUP_HAS_ENDED = StatusCodeField(402030, 'Group Has Ended', description=u'群组已结束')
77
+    COULD_HAVE_ONLY_ONE_ACTIVE_GROUP = StatusCodeField(402031, 'Could Have Only One Active Group', description=u'只能创建一个活跃团')
77 78
 
78 79
 
79 80
 class GroupUserStatusCode(BaseStatusCode):