优化代码

publicsignpoll
youngS 3 years ago
parent 7c5ab20dd9
commit 08c6b7b87f
  1. 55
      fir_ser/api/migrations/0001_initial.py
  2. 2
      fir_ser/api/utils/middlewares.py
  3. 2
      fir_ser/nginx-vhost.conf
  4. 0
      fir_ser/tmp/.gitkeep

@ -5,6 +5,59 @@ import django.contrib.auth.models
from django.db import migrations, models from django.db import migrations, models
import django.db.models.deletion import django.db.models.deletion
price_info_list = [
{
"name": "1k_times",
"title": "1k_times",
"description": "1k_times",
"price": 2500,
"package_size": 1000,
"download_count_gift": 100,
"is_enable": True,
},
{
"name": "10k_times",
"title": "10k_times",
"description": "10k_times",
"price": 22000,
"package_size": 10000,
"download_count_gift": 800,
"is_enable": True,
},
{
"name": "100k_times",
"title": "100k_times",
"description": "100k_times",
"price": 200000,
"package_size": 100000,
"download_count_gift": 8000,
"is_enable": True,
},
]
WEB_DOMAIN = settings.WEB_DOMAIN.split('//'[1])
domain_cname_info_list = [
{
"domain_record": WEB_DOMAIN,
"ip_address": WEB_DOMAIN,
"is_enable": True,
"is_system": True,
"is_https": True if settings.WEB_DOMAIN.startswith('https') else False,
"description": f"默认下载页域名 {WEB_DOMAIN}",
},
]
def add_default_price(apps, schema_editor):
for price in price_info_list:
price_model = apps.get_model('api', 'Price')
price_model.objects.create(**price)
def add_default_domain_cname(apps, schema_editor):
for domain_cname_info in domain_cname_info_list:
domain_cname_info_model = apps.get_model('api', 'DomainCnameInfo')
domain_cname_info_model.objects.create(**domain_cname_info)
class Migration(migrations.Migration): class Migration(migrations.Migration):
initial = True initial = True
@ -526,4 +579,6 @@ class Migration(migrations.Migration):
name='appiosdeveloperinfo', name='appiosdeveloperinfo',
unique_together={('user_id', 'issuer_id')}, unique_together={('user_id', 'issuer_id')},
), ),
migrations.RunPython(add_default_price),
migrations.RunPython(add_default_domain_cname),
] ]

@ -15,7 +15,7 @@ class CorsMiddleWare(MiddlewareMixin):
response["Access-Control-Allow-Origin"] = request.META.get("HTTP_ORIGIN") response["Access-Control-Allow-Origin"] = request.META.get("HTTP_ORIGIN")
response["Access-Control-Allow-Credentials"] = 'true' response["Access-Control-Allow-Credentials"] = 'true'
response["Cache-Control"] = "no-cache" # response["Cache-Control"] = "no-cache"
except Exception as e: except Exception as e:
logger.error(e) logger.error(e)
return response return response

@ -40,7 +40,7 @@ server
set_real_ip_from 0.0.0.0/0; set_real_ip_from 0.0.0.0/0;
real_ip_header X-Forwarded-For; real_ip_header X-Forwarded-For;
location ~ ^/(download|api|files|udid|captcha|show_udid) { location ~ ^/(download|api|files|udid|captcha|show_udid|flower) {
#proxy_pass http://synchrotron; #proxy_pass http://synchrotron;
#proxy_send_timeout 180; #proxy_send_timeout 180;
#proxy_connect_timeout 180; #proxy_connect_timeout 180;

Loading…
Cancel
Save