configs and experiments
This commit is contained in:
@@ -4,5 +4,6 @@ from django.urls import path
|
||||
from .views import *
|
||||
|
||||
urlpatterns = [
|
||||
path(*ConfigsView.as_path())
|
||||
path(*ConfigsView.as_path()),
|
||||
path('get', get_config)
|
||||
]
|
||||
|
@@ -1,6 +1,9 @@
|
||||
from json import loads
|
||||
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
|
||||
from BaseLib.BaseView import BaseView
|
||||
from Platform import settings
|
||||
from configs.models import Config
|
||||
|
||||
|
||||
@@ -41,3 +44,17 @@ class ConfigsView(BaseView):
|
||||
config.data = data
|
||||
config.save()
|
||||
return '/configs/?stage=' + config.stage
|
||||
|
||||
|
||||
def get_config(request):
|
||||
if request.headers.get("X-Security-Token") != settings.PLATFORM_SECURITY_TOKEN:
|
||||
return HttpResponse('', status=403)
|
||||
project = request.GET.get('project')
|
||||
stage = request.GET.get('stage')
|
||||
name = request.GET.get('name')
|
||||
if project is None or stage is None or name is None:
|
||||
return HttpResponse('', status=400)
|
||||
config = Config.objects.filter(stage=stage, project=project, name=name).first()
|
||||
if config is None:
|
||||
return HttpResponse('', status=404)
|
||||
return JsonResponse(config.data)
|
||||
|
Reference in New Issue
Block a user