configs and experiments

This commit is contained in:
Administrator
2023-09-26 00:19:48 +03:00
parent 6b95a74681
commit c4b65ff11f
8 changed files with 48 additions and 8 deletions

View File

@@ -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)
]

View File

@@ -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)