commit
7cf29376bd
@ -3,7 +3,7 @@ from json import dumps
|
||||
|
||||
|
||||
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):
|
||||
|
@ -1,6 +1,7 @@
|
||||
from django.http import HttpResponse, JsonResponse
|
||||
|
||||
from BaseLib.BaseView import BaseView
|
||||
from BaseLib.configurator import *
|
||||
from Platform import settings
|
||||
from experiments.models import Experiment
|
||||
|
||||
@ -17,31 +18,48 @@ class ExperimentsView(BaseView):
|
||||
self.context['stage'] = self.stage
|
||||
|
||||
def get(self):
|
||||
self.context['experiments'] = Experiment.objects.filter(project=self.request.user.selected_project,
|
||||
stage=self.stage).order_by('name')
|
||||
# self.context['experiments'] = Experiment.objects.filter(project=self.request.user.selected_project,
|
||||
# stage=self.stage).order_by('name')
|
||||
self.context['experiments'] = get_experiments(self.request.user.selected_project.name, self.stage)
|
||||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
def post_change(self):
|
||||
exp = Experiment.objects.get(id=self.request.POST['experiment_id'])
|
||||
exp.enabled = 'enabled' in self.request.POST
|
||||
# exp = Experiment.objects.get(id=self.request.POST['experiment_id'])
|
||||
# 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']
|
||||
if condition == 'Другое (только для техлидов)':
|
||||
exp.condition = self.request.POST['condition']
|
||||
condition = self.request.POST['condition']
|
||||
elif condition == 'Никому':
|
||||
exp.condition = 'False'
|
||||
condition = 'False'
|
||||
elif condition == 'Только админам':
|
||||
exp.condition = 'user.is_superuser'
|
||||
condition = 'user.is_superuser'
|
||||
elif condition == 'Только сотрудникам':
|
||||
exp.condition = 'user.platform_staff'
|
||||
condition = 'user.platform_staff'
|
||||
else:
|
||||
exp.condition = 'True'
|
||||
exp.save()
|
||||
condition = 'True'
|
||||
update_experiment(self.request.POST['experiment_id'], enabled, condition)
|
||||
return '/experiments/?stage=' + self.stage
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user