@@ -78,6 +78,7 @@ urlpatterns += [ |
||
78 | 78 |
url(r'^op/upgrade$', op_views.upgrade_api, name='upgrade_api'), # APP 升级 |
79 | 79 |
url(r'^op/splash$', op_views.splash_api, name='splash_api'), # 启动页面 |
80 | 80 |
url(r'^op/feedback$', op_views.feedback_api, name='feedback_api'), # 用户反馈 |
81 |
+ url(r'^op/downlaod$', op_views.download_api, name='download_api'), # 下载接口 |
|
81 | 82 |
] |
82 | 83 |
|
83 | 84 |
# 支付相关 |
@@ -6,6 +6,7 @@ from django.template.loader import render_to_string |
||
6 | 6 |
|
7 | 7 |
from operation.models import FeedbackInfo, GuestEntranceControlInfo, LatestAppInfo, SplashInfo |
8 | 8 |
from utils.disk_utils import write_to_disk |
9 |
+from utils.redis.rapp import set_latest_app |
|
9 | 10 |
from utils.redis.rversion import delete_guest_entrance_control, set_guest_entrance_control |
10 | 11 |
|
11 | 12 |
|
@@ -20,6 +21,9 @@ class LatestAppInfoAdmin(admin.ModelAdmin): |
||
20 | 21 |
'version': obj.latest_version, |
21 | 22 |
}), settings.DOWNLOAD_PAGE_PATH) |
22 | 23 |
|
24 |
+ # 设置最新 APP 信息 |
|
25 |
+ set_latest_app() |
|
26 |
+ |
|
23 | 27 |
|
24 | 28 |
class SplashInfoAdmin(admin.ModelAdmin): |
25 | 29 |
list_display = ('splash_image', 'spalash_image_airtime', 'spalash_image_deadline', 'status', 'created_at', 'updated_at') |
@@ -1,11 +1,14 @@ |
||
1 | 1 |
# -*- coding: utf-8 -*- |
2 | 2 |
|
3 |
+from django.conf import settings |
|
3 | 4 |
from django.http import JsonResponse |
5 |
+from django.shortcuts import redirect |
|
4 | 6 |
|
5 | 7 |
from account.models import UserInfo |
6 | 8 |
from operation.models import FeedbackInfo, LatestAppInfo, SplashInfo |
7 | 9 |
from utils.error.errno_utils import UserStatusCode |
8 | 10 |
from utils.error.response_utils import response |
11 |
+from utils.redis.rapp import get_latest_app |
|
9 | 12 |
|
10 | 13 |
|
11 | 14 |
def upgrade_api(request): |
@@ -14,16 +17,11 @@ def upgrade_api(request): |
||
14 | 17 |
:param request: |
15 | 18 |
:return: |
16 | 19 |
""" |
17 |
- try: |
|
18 |
- appinfo = LatestAppInfo.objects.all()[0].data |
|
19 |
- except IndexError: |
|
20 |
- appinfo = {} |
|
21 |
- |
|
22 | 20 |
return JsonResponse({ |
23 | 21 |
'status': 200, |
24 | 22 |
'message': u'获取最新版信息成功', |
25 | 23 |
'data': { |
26 |
- 'appinfo': appinfo, |
|
24 |
+ 'appinfo': get_latest_app(), |
|
27 | 25 |
}, |
28 | 26 |
}) |
29 | 27 |
|
@@ -69,3 +67,16 @@ def feedback_api(request): |
||
69 | 67 |
'data': { |
70 | 68 |
}, |
71 | 69 |
}) |
70 |
+ |
|
71 |
+ |
|
72 |
+def download_api(request): |
|
73 |
+ """ |
|
74 |
+ 下载接口 |
|
75 |
+ :param request: |
|
76 |
+ :return: |
|
77 |
+ """ |
|
78 |
+ if request.weixin: |
|
79 |
+ return redirect(settings.DOWNLOAD_WX_URL) |
|
80 |
+ if request.iOS: |
|
81 |
+ return redirect(settings.DOWNLOAD_IOS_URL) |
|
82 |
+ return redirect(get_latest_app().get('latest_url', '')) |
@@ -271,6 +271,10 @@ PAI2_HOME_MAX_ROWS = 400 # 首页照片最大数量, PAI2_HOME_PER_PAGE * PAI2_ |
||
271 | 271 |
DOWNLOAD_TMPL_PATH = os.path.join(BASE_DIR, 'page/templates/page/download.tmpl.html').replace('\\', '/') |
272 | 272 |
DOWNLOAD_PAGE_PATH = os.path.join(BASE_DIR, 'page/templates/page/download.html').replace('\\', '/') |
273 | 273 |
|
274 |
+# 下载设置 |
|
275 |
+DOWNLOAD_WX_URL = '' |
|
276 |
+DOWNLOAD_IOS_URL = '' |
|
277 |
+ |
|
274 | 278 |
# 群组设置 |
275 | 279 |
GROUP_PER_PAGE = 20 # 群组每页数量 |
276 | 280 |
|
@@ -0,0 +1,29 @@ |
||
1 |
+# -*- coding: utf-8 -*- |
|
2 |
+ |
|
3 |
+import json |
|
4 |
+ |
|
5 |
+from django.conf import settings |
|
6 |
+ |
|
7 |
+from operation.models import LatestAppInfo |
|
8 |
+from utils.redis.rkeys import LATEST_APP_INFO |
|
9 |
+ |
|
10 |
+ |
|
11 |
+r = settings.REDIS_CACHE |
|
12 |
+ |
|
13 |
+ |
|
14 |
+# 最新 APP 相关 |
|
15 |
+ |
|
16 |
+ |
|
17 |
+def set_latest_app(): |
|
18 |
+ """ 设置最新 APP 信息 """ |
|
19 |
+ try: |
|
20 |
+ appinfo = LatestAppInfo.objects.all()[0].data |
|
21 |
+ except IndexError: |
|
22 |
+ appinfo = {} |
|
23 |
+ r.set(LATEST_APP_INFO, json.dumps(appinfo)) |
|
24 |
+ return appinfo |
|
25 |
+ |
|
26 |
+ |
|
27 |
+def get_latest_app(): |
|
28 |
+ """ 获取最新 APP 信息 """ |
|
29 |
+ return json.loads(r.get(LATEST_APP_INFO) or '{}') or set_latest_app() |
@@ -30,3 +30,6 @@ SYSTEM_MESSAGE_DELETED_INFO = 'system:message:deleted:info:%s' # STRING,系 |
||
30 | 30 |
|
31 | 31 |
# 游客入口相关 |
32 | 32 |
GUEST_ENTRANCE_CONTROL_INFO = 'guest:entrance:control:info' # STRING,游客入口控制信息 |
33 |
+ |
|
34 |
+# APP 相关 |
|
35 |
+LATEST_APP_INFO = 'latest:app:info' # STRING,最新 APP 信息 |