fetch
This commit is contained in:
@@ -8,3 +8,4 @@ from .ping import PingView
|
||||
from .vk_auth import VKAuthView
|
||||
from .yandex_auth import YandexAuthView
|
||||
from .is_staff import is_staff
|
||||
from .fetch import fetch
|
||||
|
23
web/views/fetch.py
Normal file
23
web/views/fetch.py
Normal file
@@ -0,0 +1,23 @@
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
|
||||
from Platform import settings
|
||||
from configs.models import Config
|
||||
from experiments.models import Experiment
|
||||
|
||||
|
||||
def fetch(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')
|
||||
if project is None or stage is None:
|
||||
return HttpResponse('', status=400)
|
||||
configs = Config.objects.filter(stage=stage, project__name=project)
|
||||
experiments = Experiment.objects.filter(stage=stage, project__name=project)
|
||||
return JsonResponse(
|
||||
data={
|
||||
'configs': {config.name: config.data for config in configs},
|
||||
'experiments': {experiment.name: experiment.condition for experiment in experiments}
|
||||
},
|
||||
safe=False,
|
||||
)
|
Reference in New Issue
Block a user