fetch
This commit is contained in:
parent
397e00cefa
commit
20448aa6b0
@ -13,5 +13,6 @@ urlpatterns = [
|
|||||||
path(*PingView.as_path()),
|
path(*PingView.as_path()),
|
||||||
path(*VKAuthView.as_path()),
|
path(*VKAuthView.as_path()),
|
||||||
path(*YandexAuthView.as_path()),
|
path(*YandexAuthView.as_path()),
|
||||||
path('is_staff', is_staff)
|
path('is_staff', is_staff),
|
||||||
|
path('fetch', fetch),
|
||||||
]
|
]
|
||||||
|
@ -8,3 +8,4 @@ from .ping import PingView
|
|||||||
from .vk_auth import VKAuthView
|
from .vk_auth import VKAuthView
|
||||||
from .yandex_auth import YandexAuthView
|
from .yandex_auth import YandexAuthView
|
||||||
from .is_staff import is_staff
|
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,
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user