eateUpdateMixin, PlatformMixin):
+ channel = models.CharField(_(u'channel'), max_length=255, blank=True, null=True, help_text=u'渠道')
+ version = models.CharField(_(u'version'), max_length=255, blank=True, null=True, help_text=u'版本')
+
+ online = models.BooleanField(_(u'online'), default=True, help_text=u'是否上线')
+
+ class Meta:
+ verbose_name = _('appsettingsinfo')
+ verbose_name_plural = _('appsettingsinfo')
+
+ def __unicode__(self):
+ return u'{0.pk}'.format(self)
+
+ @property
+ def data(self):
+ return {
+ 'online': self.online,
+ }
+
+
class SplashInfo(CreateUpdateMixin):
PAIAI_USER = 0
PAIAI_LENSMAN = 1
@@ -9,6 +9,7 @@ from operation.models import FeedbackInfo, SplashInfo |
||
| 9 | 9 |
from utils.error.errno_utils import UserStatusCode |
| 10 | 10 |
from utils.error.response_utils import response |
| 11 | 11 |
from utils.redis.rapp import get_latest_app |
| 12 |
+from utils.redis.rsettings import get_app_settings_info |
|
| 12 | 13 |
|
| 13 | 14 |
|
| 14 | 15 |
@logit |
@@ -40,6 +41,23 @@ def upgrade_api(request): |
||
| 40 | 41 |
}) |
| 41 | 42 |
|
| 42 | 43 |
|
| 44 |
+def online_api(request): |
|
| 45 |
+ """ |
|
| 46 |
+ 是否上线 |
|
| 47 |
+ :param request: |
|
| 48 |
+ :return: |
|
| 49 |
+ """ |
|
| 50 |
+ platform = request.REQUEST.get('platform', '')
|
|
| 51 |
+ channel = request.REQUEST.get('channel', '')
|
|
| 52 |
+ version = request.REQUEST.get('version', '')
|
|
| 53 |
+ |
|
| 54 |
+ app_settings = get_app_settings_info(platform, channel, version) |
|
| 55 |
+ |
|
| 56 |
+ return response(200, 'Get Online Status Success', u'获取是否上线成功', {
|
|
| 57 |
+ 'online': app_settings.get('online', True),
|
|
| 58 |
+ }) |
|
| 59 |
+ |
|
| 60 |
+ |
|
| 43 | 61 |
@logit |
| 44 | 62 |
def splash_api(request): |
| 45 | 63 |
""" |
@@ -31,6 +31,12 @@ class PlatformMixin(models.Model): |
||
| 31 | 31 |
class Meta: |
| 32 | 32 |
abstract = True |
| 33 | 33 |
|
| 34 |
+ Platforms = {
|
|
| 35 |
+ 'iOS': IOS, |
|
| 36 |
+ 'android': ADR, |
|
| 37 |
+ 'Android': ADR, |
|
| 38 |
+ } |
|
| 39 |
+ |
|
| 34 | 40 |
|
| 35 | 41 |
class VersionMixin(models.Model): |
| 36 | 42 |
min_adr = models.CharField(_(u'min_adr'), max_length=255, blank=True, null=True, help_text=u'Adr 最低版本') |
@@ -52,3 +52,4 @@ GUEST_ENTRANCE_CONTROL_INFO = 'guest:entrance:control:info' # STRING,游客 |
||
| 52 | 52 |
|
| 53 | 53 |
# APP 相关 |
| 54 | 54 |
LATEST_APP_INFO = 'latest:app:info:%s' # STRING,最新 APP 信息,src |
| 55 |
+APP_SETTINGS_INFO = 'app:settings:info:%s:%s:%s' # STRING,APP 设置信息,platform、channel、version |
@@ -0,0 +1,28 @@ |
||
| 1 |
+# -*- coding: utf-8 -*- |
|
| 2 |
+ |
|
| 3 |
+import json |
|
| 4 |
+ |
|
| 5 |
+from django.conf import settings |
|
| 6 |
+ |
|
| 7 |
+from pai2.basemodels import PlatformMixin |
|
| 8 |
+from utils.redis.rkeys import APP_SETTINGS_INFO |
|
| 9 |
+ |
|
| 10 |
+ |
|
| 11 |
+r = settings.REDIS_CACHE |
|
| 12 |
+ |
|
| 13 |
+ |
|
| 14 |
+def set_app_settings_info(appset): |
|
| 15 |
+ """ 设置 APP 设置信息 """ |
|
| 16 |
+ r.set(APP_SETTINGS_INFO % (appset.platform, appset.channel, appset.version), json.dumps(appset.data)) |
|
| 17 |
+ |
|
| 18 |
+ |
|
| 19 |
+def del_app_settings_info(appset): |
|
| 20 |
+ """ 删除 APP 设置信息 """ |
|
| 21 |
+ r.delete(APP_SETTINGS_INFO % (appset.platform, appset.channel, appset.version)) |
|
| 22 |
+ |
|
| 23 |
+ |
|
| 24 |
+def get_app_settings_info(platform, channel, version): |
|
| 25 |
+ """ 获取 APP 设置信息 """ |
|
| 26 |
+ if type(platform) != int: |
|
| 27 |
+ platform = PlatformMixin.Platforms[platform] |
|
| 28 |
+ return json.loads(r.get(APP_SETTINGS_INFO % (platform, channel, version)) or '{}')
|