38
+                ('spalash_image_airtime', models.DateTimeField(help_text='\u542f\u52a8\u9875\u9762\u56fe\u7247\u5f00\u59cb\u65e5\u671f', null=True, verbose_name='spalash_image_airtime', blank=True)),
39
+                ('spalash_image_deadline', models.DateTimeField(help_text='\u542f\u52a8\u9875\u9762\u56fe\u7247\u622a\u6b62\u65e5\u671f', null=True, verbose_name='spalash_image_deadline', blank=True)),
40
+            ],
41
+            options={
42
+                'verbose_name': 'splashinfo',
43
+                'verbose_name_plural': 'splashinfo',
44
+            },
45
+        ),
46
+    ]

+ 0 - 0
operation/migrations/__init__.py


+ 73 - 0
operation/models.py

@@ -0,0 +1,73 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+from django.conf import settings
4
+from django.db import models
5
+from django.utils.translation import ugettext_lazy as _
6
+
7
+from pai2.basemodels import CreateUpdateMixin
8
+
9
+import datetime
10
+import os
11
+import time
12
+
13
+
14
+def upload_path(instance, old_filename):
15
+    extension = os.path.splitext(old_filename)[1].lower()
16
+    today = datetime.datetime.today()
17
+    return 'file/{year}{month}/{timestamp}{extension}'.format(
18
+        year=today.year,
19
+        month=today.month,
20
+        timestamp=time.time(),
21
+        extension=extension
22
+    )
23
+
24
+
25
+class LatestAppInfo(CreateUpdateMixin):
26
+    latest_version = models.CharField(_(u'latest_version'), max_length=255, help_text=u'最新版本')
27
+    latest_app = models.FileField(_(u'latest_app'), upload_to=upload_path, blank=True, null=True, help_text=u'最新版 APP')
28
+    latest_url = models.URLField(_(u'latest_url'), max_length=255, blank=True, null=True, help_text=u'最新版 APP 链接')
29
+
30
+    class Meta:
31
+        verbose_name = _('latestappinfo')
32
+        verbose_name_plural = _('latestappinfo')
33
+
34
+    def __unicode__(self):
35
+        return u'{0.pk}'.format(self)
36
+
37
+    @property
38
+    def final_latest_url(self):
39
+        return self.latest_url or u'{0}{1}'.format(settings.DOMAIN, self.latest_app and self.latest_app.url)
40
+
41
+    def _data(self):
42
+        return {
43
+            'latest_version': self.latest_version,
44
+            'latest_url': self.final_latest_url,
45
+        }
46
+
47
+    data = property(_data)
48
+
49
+
50
+class SplashInfo(CreateUpdateMixin):
51
+    splash_image = models.ImageField(_(u'splash_image'), upload_to=upload_path, blank=True, null=True, help_text=u'启动页面图片')
52
+    spalash_image_airtime = models.DateTimeField(_(u'spalash_image_airtime'), blank=True, null=True, help_text=u'启动页面图片开始日期')
53
+    spalash_image_deadline = models.DateTimeField(_(u'spalash_image_deadline'), blank=True, null=True, help_text=u'启动页面图片截止日期')
54
+
55
+    class Meta:
56
+        verbose_name = _('splashinfo')
57
+        verbose_name_plural = _('splashinfo')
58
+
59
+    def __unicode__(self):
60
+        return u'{0.pk}'.format(self)
61
+
62
+    @property
63
+    def splash_image_url(self):
64
+        return self.splash_image and (settings.DOMAIN + self.splash_image.url)
65
+
66
+    def _data(self):
67
+        return {
68
+            'splash_image_url': self.splash_image_url,
69
+            'spalash_image_airtime': self.spalash_image_airtime,
70
+            'spalash_image_deadline': self.spalash_image_deadline,
71
+        }
72
+
73
+    data = property(_data)

+ 3 - 0
operation/tests.py

@@ -0,0 +1,3 @@
1
+from django.test import TestCase
2
+
3
+# Create your tests here.

+ 37 - 0
operation/views.py

@@ -0,0 +1,37 @@
1
+# -*- coding: utf-8 -*-
2
+
3
+from django.conf import settings
4
+from django.core.files.storage import default_storage
5
+from django.db import transaction
6
+from django.http import JsonResponse
7
+from django.shortcuts import render, redirect
8
+
9
+from operation.models import LatestAppInfo, SplashInfo
10
+
11
+
12
+def upgrade_api(request):
13
+    try:
14
+        appinfo = LatestAppInfo.objects.all()[0].data
15
+    except IndexError:
16
+        appinfo = {}
17
+
18
+    return JsonResponse({
19
+        'status': 200,
20
+        'message': u'获取最新版信息成功',
21
+        'data': {
22
+            'appinfo': appinfo,
23
+        },
24
+    })
25
+
26
+
27
+def splash_api(request):
28
+    splashes = SplashInfo.objects.all()
29
+    splashes = [splash.data for splash in splashes]
30
+
31
+    return JsonResponse({
32
+        'status': 200,
33
+        'message': u'获取最新版信息成功',
34
+        'data': {
35
+            'splashes': splashes,
36
+        },
37
+    })

+ 1 - 0
pai2/settings.py

@@ -45,6 +45,7 @@ INSTALLED_APPS = (
45 45
     'account',
46 46
     'group',
47 47
     'photo',
48
+    'operation',
48 49
 )
49 50
 
50 51
 INSTALLED_APPS += ('multidomain', )

+ 3 - 3
pai2/uwsgi.bak/pai2_nginx.conf

@@ -11,7 +11,7 @@ server {
11 11
     # the port your site will be served on
12 12
     listen      80;
13 13
     # the domain name it will serve for
14
-    server_name .img.xfoto.com.cn; # substitute your machine's IP address or FQDN
14
+    server_name .img.pai.ai .img.xfoto.com.cn; # substitute your machine's IP address or FQDN
15 15
     charset     utf-8;
16 16
 
17 17
     # max upload size
@@ -36,7 +36,7 @@ server {
36 36
     # the port your site will be served on
37 37
     listen      80;
38 38
     # the domain name it will serve for
39
-    server_name .api.xfoto.com.cn; # substitute your machine's IP address or FQDN
39
+    server_name .api.pai.ai .api.xfoto.com.cn; # substitute your machine's IP address or FQDN
40 40
     charset     utf-8;
41 41
 
42 42
     # max upload size
@@ -64,7 +64,7 @@ server {
64 64
     # the port your site will be served on
65 65
     listen      80;
66 66
     # the domain name it will serve for
67
-    server_name .xfoto.com.cn; # substitute your machine's IP address or FQDN
67
+    server_name .pai.ai .xfoto.com.cn; # substitute your machine's IP address or FQDN
68 68
     charset     utf-8;
69 69
 
70 70
     # max upload size

+ 2 - 2
photo/views.py

@@ -37,7 +37,7 @@ def uuid_init(request):
37 37
     })
38 38
 
39 39
 
40
-# curl -X POST -F user=xxxxxxx -F num=100 http://api.xfoto.com.cn/uuid
40
+# curl -X POST -F user=xxxxxxx -F num=100 http://api.pai.ai/uuid
41 41
 @transaction.atomic
42 42
 def uuid(request):
43 43
     lensman_id = request.POST.get('user', '')
@@ -67,7 +67,7 @@ def uuid(request):
67 67
 #               name with the symbol <. The difference between @ and < is then that @ makes a file get attached in the post as a file  upload,
68 68
 #               while the < makes a text field and just get the contents for that text field from a file.
69 69
 #
70
-# curl -X POST -F user=xxxxxxx -F session=xxxxxxx -F photo_id=xxxxxxx -F photo=@xxxxxxx.jpg http://api.xfoto.com.cn/photos/upload
70
+# curl -X POST -F user=xxxxxxx -F session=xxxxxxx -F photo_id=xxxxxxx -F photo=@xxxxxxx.jpg http://api.pai.ai/photos/upload
71 71
 def upload_photo(request):
72 72
     lensman_id = request.POST.get('user', '')
73 73
     session_id = request.POST.get('session', '')

paiai/paiai_ios - Gogs: Go Git Service

4 Коммиты (804a40e3b44af5be9d0d3be7ac0f33c8a698a090)

Автор SHA1 Сообщение Дата
  FFIB 2bc442c083 add swiftlint лет %!s(int64=6): %!d(string=назад)
  FFIB b6305c367a 处理页面间数据同步问题,两种方式:1、Coordinator单页面数据同步,2:NotificationCenter 多页面数据同步 лет %!s(int64=6): %!d(string=назад)
  FFIB 5daedc0660 mine module done лет %!s(int64=6): %!d(string=назад)
  FFIB 1f0e157dfc mine module done лет %!s(int64=6): %!d(string=назад)