">
+    list_display = ('splash_image', 'spalash_image_airtime', 'spalash_image_deadline', 'status', 'created_at', 'updated_at')
14
+
15
+
16
+admin.site.register(LatestAppInfo, LatestAppInfoAdmin)
17
+admin.site.register(SplashInfo, SplashInfoAdmin)

+ 46 - 0
operation/migrations/0001_initial.py

@@ -0,0 +1,46 @@
1
+# -*- coding: utf-8 -*-
2
+from __future__ import unicode_literals
3
+
4
+from django.db import models, migrations
5
+import operation.models
6
+
7
+
8
+class Migration(migrations.Migration):
9
+
10
+    dependencies = [
11
+    ]
12
+
13
+    operations = [
14
+        migrations.CreateModel(
15
+            name='LatestAppInfo',
16
+            fields=[
17
+                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
18
+                ('status', models.BooleanField(default=True, help_text='\u72b6\u6001', verbose_name='status')),
19
+                ('created_at', models.DateTimeField(help_text='\u521b\u5efa\u65f6\u95f4', verbose_name='created_at', auto_now_add=True)),
20
+                ('updated_at', models.DateTimeField(help_text='\u66f4\u65b0\u65f6\u95f4', verbose_name='updated_at', auto_now=True)),
21
+                ('latest_version', models.CharField(help_text='\u6700\u65b0\u7248\u672c', max_length=255, verbose_name='latest_version')),
22
+                ('latest_app', models.FileField(help_text='\u6700\u65b0\u7248 APP', upload_to=operation.models.upload_path, null=True, verbose_name='latest_app', blank=True)),
23
+                ('latest_url', models.URLField(help_text='\u6700\u65b0\u7248 APP \u94fe\u63a5', max_length=255, null=True, verbose_name='latest_url', blank=True)),
24
+            ],
25
+            options={
26
+                'verbose_name': 'latestappinfo',
27
+                'verbose_name_plural': 'latestappinfo',
28
+            },
29
+        ),
30
+        migrations.CreateModel(
31
+            name='SplashInfo',
32
+            fields=[
33
+                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
34
+                ('status', models.BooleanField(default=True, help_text='\u72b6\u6001', verbose_name='status')),
35
+                ('created_at', models.DateTimeField(help_text='\u521b\u5efa\u65f6\u95f4', verbose_name='created_at', auto_now_add=True)),
36
+                ('updated_at', models.DateTimeField(help_text='\u66f4\u65b0\u65f6\u95f4', verbose_name='updated_at', auto_now=True)),
37
+                ('splash_image', models.ImageField(help_text='\u542f\u52a8\u9875\u9762\u56fe\u7247', upload_to=operation.models.upload_path, null=True, verbose_name='splash_image', blank=True)),
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', '')

Kodo/kodo - Gogs: Go Git Service

411 Commity (2eba3ed7f9381fa988bf40c1ecb454f3fa7a2d4f)

Autor SHA1 Wiadomość Data
  Brightcells 8f43551640 add api wx_jsapi_signature_api 10 lat temu
  Brightcells b5857bab0c dialect[+driver]://user:password@host/dbname[?key=value..] 10 lat temu
  Brightcells d50a6c1bae update django-detect in requirements.txt 10 lat temu
  Brightcells 3253541b10 change to exec raw sql from django.db.connection to records 10 lat temu
  Brightcells 8263625d9c new website 10 lat temu
  Brightcells 8d6858fb00 adjust website content 10 lat temu
  Brightcells 80a3496489 fix user join group by session after remove 10 lat temu
  Brightcells e4567ea2de fix call set_group_users_info after group user removed 10 lat temu
  Brightcells 1e620ebab6 *_download.html 10 lat temu
  Brightcells 2f29afecbd modify version in operation 10 lat temu
  Brightcells 65ab52f95a spell error 10 lat temu
  Brightcells 535ac34ee1 add api download_api 10 lat temu
  Brightcells af2b3f483f change download.html to be generated from download.tmpl.html 10 lat temu
  Brightcells 696c8d2e2b adjust download section of photo_detail/session_detail 10 lat temu
  Brightcells 9671c0e989 wrongly written or mispronounced characters 10 lat temu
  Brightcells 5a0b6447ca change RotatingFileHandler to TimedRotatingFileHandler to support rotation of disk log files at certain timed intervals. 10 lat temu
  Brightcells cce055cdf4 change FileHandler to RotatingFileHandler to to supports rotation of disk log files. 10 lat temu
  Brightcells 51959f199b remove overflow: hidden; 10 lat temu
  Brightcells 88294e7647 change title of photo detail 10 lat temu
  Brightcells 4b7cfa2426 adjust photo detail page 10 lat temu
  Brightcells f679be700a adjust title of user_agreement 10 lat temu
  Brightcells a80a911457 change time.time() to int(time.time()) in upload_path 10 lat temu
  Brightcells 771845b52e add param pfrom for statistic_thumbnail_size 10 lat temu
  Brightcells 5c9e21b29b add Only Once Function statistic_thumbnail_size to statistic thumbnail size 10 lat temu
  Brightcells 0339d3dce4 Fix Bug: set_group_photo_data should after group_photo.save() 10 lat temu
  Brightcells bbc43c96ec add photo_share_url 10 lat temu
  Brightcells 398957153c add pk in user's nickname 10 lat temu
  Brightcells 85eb6c6f2d Fix Bug: nickname for GroupPhotoInfo error 10 lat temu
  Brightcells afcdf74a49 add api group_data_api 10 lat temu
  Brightcells e1b319d9a4 'charset': 'utf8mb4' 10 lat temu
  Brightcells a8d890cb70 filter order by pay_status 10 lat temu
  Brightcells 03304ad48a add api guest_status_api & modify api guest_login_api 10 lat temu
  Brightcells c209e83d29 add delete_guest_entrance_control 10 lat temu
  Brightcells 63eaee0951 modify guest_login_api 10 lat temu
  Brightcells 70689e758c add lensman and user's balance 10 lat temu
  Brightcells 269576f8b9 add guest user 10 lat temu
  Brightcells 818e5ae2cd adjust page 10 lat temu
  Brightcells 10fdf9ba1f adjust page 10 lat temu
  Brightcells 805b221885 add content for contact_us.html 10 lat temu
  Brightcells 60b2bc0c09 add content for user_agreement.html 10 lat temu
  Brightcells 95c1d32792 put isort and pep8 in check.sh 10 lat temu
  Brightcells fabef63211 set line_length=200 for isort 10 lat temu
  Brightcells 084a5eece8 order ruler: date/self/7*thumbup_num+3*comment_num/id 10 lat temu
  Brightcells 81e5a71d7f GroupUserInfo order by id desc in group_list_api 10 lat temu
  Brightcells f72ccb1875 isort import 10 lat temu
  Brightcells de60d59c26 order ruler: date/self/thumbup_num/id 10 lat temu
  Brightcells f684a1d89c order ruler: date/self/thumbup_num 10 lat temu
  Brightcells 5bf645c33d change order ruler for paiai home, user_id self upload first 10 lat temu
  Brightcells 414e2cb1b0 change some {number} to {} 10 lat temu
  Brightcells d1ef8ec9e9 download page 10 lat temu