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

@ -31,6 +31,7 @@ services:
RABBITMQ_PASSWORD: $RABBITMQ_PASSWORD_DEV RABBITMQ_PASSWORD: $RABBITMQ_PASSWORD_DEV
VK_SERVICE_TOKEN: $VK_SERVICE_TOKEN VK_SERVICE_TOKEN: $VK_SERVICE_TOKEN
YANDEX_SERVICE_TOKEN: $YANDEX_SERVICE_TOKEN YANDEX_SERVICE_TOKEN: $YANDEX_SERVICE_TOKEN
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
command: runserver 0.0.0.0:8000 command: runserver 0.0.0.0:8000
healthcheck: healthcheck:
test: curl --fail http://0.0.0.0:8000/ping || exit 1 test: curl --fail http://0.0.0.0:8000/ping || exit 1

View File

@ -36,6 +36,7 @@ services:
VK_SERVICE_TOKEN: $VK_SERVICE_TOKEN VK_SERVICE_TOKEN: $VK_SERVICE_TOKEN
YANDEX_SERVICE_TOKEN: $YANDEX_SERVICE_TOKEN YANDEX_SERVICE_TOKEN: $YANDEX_SERVICE_TOKEN
TELEGRAM_TOKEN: $TELEGRAM_TOKEN TELEGRAM_TOKEN: $TELEGRAM_TOKEN
PLATFORM_SECURITY_TOKEN: $PLATFORM_SECURITY_TOKEN
command: runserver 0.0.0.0:8000 command: runserver 0.0.0.0:8000
healthcheck: healthcheck:
test: curl --fail http://0.0.0.0:8000/ping || exit 1 test: curl --fail http://0.0.0.0:8000/ping || exit 1

View File

@ -148,3 +148,5 @@ MINIO_BUCKET_NAME = 'platform'
VK_SERVICE_TOKEN = os.getenv("VK_SERVICE_TOKEN", None) VK_SERVICE_TOKEN = os.getenv("VK_SERVICE_TOKEN", None)
YANDEX_SERVICE_TOKEN = os.getenv("YANDEX_SERVICE_TOKEN", None) YANDEX_SERVICE_TOKEN = os.getenv("YANDEX_SERVICE_TOKEN", None)
PLATFORM_SECURITY_TOKEN = os.getenv("PLATFORM_SECURITY_TOKEN", None)

View File

@ -4,5 +4,6 @@ from django.urls import path
from .views import * from .views import *
urlpatterns = [ urlpatterns = [
path(*ConfigsView.as_path()) path(*ConfigsView.as_path()),
path('get', get_config)
] ]

View File

@ -1,6 +1,9 @@
from json import loads from json import loads
from django.http import HttpResponse, JsonResponse
from BaseLib.BaseView import BaseView from BaseLib.BaseView import BaseView
from Platform import settings
from configs.models import Config from configs.models import Config
@ -41,3 +44,17 @@ class ConfigsView(BaseView):
config.data = data config.data = data
config.save() config.save()
return '/configs/?stage=' + config.stage 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)

View File

@ -4,5 +4,6 @@ from django.urls import path
from .views import * from .views import *
urlpatterns = [ urlpatterns = [
path(*ExperimentsView.as_path()) path(*ExperimentsView.as_path()),
path('get', get_experiment)
] ]

View File

@ -1,4 +1,7 @@
from django.http import HttpResponse, JsonResponse
from BaseLib.BaseView import BaseView from BaseLib.BaseView import BaseView
from Platform import settings
from experiments.models import Experiment from experiments.models import Experiment
@ -39,4 +42,21 @@ class ExperimentsView(BaseView):
else: else:
exp.condition = 'True' exp.condition = 'True'
exp.save() exp.save()
return '/experiments/?stage=' + self.stage return '/experiments/?stage=' + self.stage
def get_experiment(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)
experiment = Experiment.objects.filter(stage=stage, project=project, name=name).first()
if experiment is None:
return HttpResponse('', status=404)
return JsonResponse({
'enabled': experiment.enabled,
'condition': experiment.condition
})

View File

@ -7,7 +7,7 @@
<div class="row"> <div class="row">
<div class="col-3"> <div class="col-3">
<div style="height: 100%; width: 100%;"> <div style="height: 100%; width: 100%;">
<img src="{{ user.profile_photo_url }}" height="100%" width="100%" alt="Фото профиля"> <img src="{{ account.profile_photo_url }}" height="100%" width="100%" alt="Фото профиля">
</div> </div>
{% if owner %} {% if owner %}
<label for="file-upload" class="btn btn-gray-50" style="margin-top: -120px; margin-left: 20%; width: 60%;"> <label for="file-upload" class="btn btn-gray-50" style="margin-top: -120px; margin-left: 20%; width: 60%;">
@ -22,7 +22,7 @@
</div> </div>
<div class="col-9"> <div class="col-9">
<h3> <h3>
{{ account.userinfo.surname }} {{ account.userinfo.name }} {{ account.surname }} {{ account.name }}
<span style="margin-left: 15px; margin-bottom: 20px;" class="badge bg-{% if account.userinfo.activity_status == online_status %}success{% else %}secondary{% endif %}">{{ account.userinfo.activity_status }}</span> <span style="margin-left: 15px; margin-bottom: 20px;" class="badge bg-{% if account.userinfo.activity_status == online_status %}success{% else %}secondary{% endif %}">{{ account.userinfo.activity_status }}</span>
</h3> </h3>
<table> <table>
@ -55,9 +55,6 @@
{% if account.vk_id %} {% if account.vk_id %}
<div style="margin-top: -15px; margin-left: 30px;"><i style="color: green;" class="fa fa-check-circle"></i></div> <div style="margin-top: -15px; margin-left: 30px;"><i style="color: green;" class="fa fa-check-circle"></i></div>
{% endif %} {% endif %}
</td>
<td><div style="width: 20px;"></div></td>
<td>
<a href="https://oauth.yandex.ru/authorize?response_type=code&client_id=38f1906e99de4810bd79828f420ba885&redirect_uri=https://platform.sprinthub.ru/yandex_auth"><img style="width: 40px; height: 40px;" src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/58/Yandex_icon.svg/2048px-Yandex_icon.svg.png"></a> <a href="https://oauth.yandex.ru/authorize?response_type=code&client_id=38f1906e99de4810bd79828f420ba885&redirect_uri=https://platform.sprinthub.ru/yandex_auth"><img style="width: 40px; height: 40px;" src="https://upload.wikimedia.org/wikipedia/commons/thumb/5/58/Yandex_icon.svg/2048px-Yandex_icon.svg.png"></a>
{% if account.yandex_id %} {% if account.yandex_id %}
<div style="margin-top: -15px; margin-left: 30px;"><i style="color: green;" class="fa fa-check-circle"></i></div> <div style="margin-top: -15px; margin-left: 30px;"><i style="color: green;" class="fa fa-check-circle"></i></div>