fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 6s
Deploy Dev / Push (pull_request) Successful in 9s
Deploy Dev / Deploy dev (pull_request) Successful in 11s

This commit is contained in:
emmatveev 2024-11-24 22:49:23 +03:00
parent 965a015c51
commit fba06976d4
2 changed files with 31 additions and 13 deletions

View File

@ -3,7 +3,7 @@ from json import dumps
URL_CONFIGS = 'http://configurator/api/v1/configs' URL_CONFIGS = 'http://configurator/api/v1/configs'
URL_EXPERIMENTS = 'http://configurator/api/v1/configs' URL_EXPERIMENTS = 'http://configurator/api/v1/experiments'
def get_configs(project, stage): def get_configs(project, stage):

View File

@ -1,6 +1,7 @@
from django.http import HttpResponse, JsonResponse from django.http import HttpResponse, JsonResponse
from BaseLib.BaseView import BaseView from BaseLib.BaseView import BaseView
from BaseLib.configurator import *
from Platform import settings from Platform import settings
from experiments.models import Experiment from experiments.models import Experiment
@ -17,31 +18,48 @@ class ExperimentsView(BaseView):
self.context['stage'] = self.stage self.context['stage'] = self.stage
def get(self): def get(self):
self.context['experiments'] = Experiment.objects.filter(project=self.request.user.selected_project, # self.context['experiments'] = Experiment.objects.filter(project=self.request.user.selected_project,
stage=self.stage).order_by('name') # stage=self.stage).order_by('name')
self.context['experiments'] = get_experiments(self.request.user.selected_project.name, self.stage)
def post_create(self): def post_create(self):
Experiment.objects.create(project=self.request.user.selected_project, stage=self.stage, name=self.request.POST['name']) # Experiment.objects.create(project=self.request.user.selected_project, stage=self.stage, name=self.request.POST['name'])
create_experiment(self.request.user.selected_project.name, self.stage, self.request.POST['name'])
return '/experiments/?stage=' + self.stage return '/experiments/?stage=' + self.stage
def post_delete(self): def post_delete(self):
Experiment.objects.get(id=self.request.POST['experiment_id']).delete() # Experiment.objects.get(id=self.request.POST['experiment_id']).delete()
delete_experiment(self.request.POST['experiment_id'])
return '/experiments/?stage=' + self.stage return '/experiments/?stage=' + self.stage
def post_change(self): def post_change(self):
exp = Experiment.objects.get(id=self.request.POST['experiment_id']) # exp = Experiment.objects.get(id=self.request.POST['experiment_id'])
exp.enabled = 'enabled' in self.request.POST # exp.enabled = 'enabled' in self.request.POST
# condition = self.request.POST['condition_select']
# if condition == 'Другое (только для техлидов)':
# exp.condition = self.request.POST['condition']
# elif condition == 'Никому':
# exp.condition = 'False'
# elif condition == 'Только админам':
# exp.condition = 'user.is_superuser'
# elif condition == 'Только сотрудникам':
# exp.condition = 'user.platform_staff'
# else:
# exp.condition = 'True'
# exp.save()
enabled = 'enabled' in self.request.POST
condition = self.request.POST['condition_select'] condition = self.request.POST['condition_select']
if condition == 'Другое (только для техлидов)': if condition == 'Другое (только для техлидов)':
exp.condition = self.request.POST['condition'] condition = self.request.POST['condition']
elif condition == 'Никому': elif condition == 'Никому':
exp.condition = 'False' condition = 'False'
elif condition == 'Только админам': elif condition == 'Только админам':
exp.condition = 'user.is_superuser' condition = 'user.is_superuser'
elif condition == 'Только сотрудникам': elif condition == 'Только сотрудникам':
exp.condition = 'user.platform_staff' condition = 'user.platform_staff'
else: else:
exp.condition = 'True' condition = 'True'
exp.save() update_experiment(self.request.POST['experiment_id'], enabled, condition)
return '/experiments/?stage=' + self.stage return '/experiments/?stage=' + self.stage