Compare commits

..

No commits in common. "7cf29376bd16ef425bb0a79bf526fe269b68a1ba" and "a1d0b8e14fb0e2ffac8bfaaaeee06b6c1adc2e73" have entirely different histories.

2 changed files with 13 additions and 31 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/experiments' URL_EXPERIMENTS = 'http://configurator/api/v1/configs'
def get_configs(project, stage): def get_configs(project, stage):

View File

@ -1,7 +1,6 @@
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
@ -18,48 +17,31 @@ 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 == 'Другое (только для техлидов)':
condition = self.request.POST['condition'] exp.condition = self.request.POST['condition']
elif condition == 'Никому': elif condition == 'Никому':
condition = 'False' exp.condition = 'False'
elif condition == 'Только админам': elif condition == 'Только админам':
condition = 'user.is_superuser' exp.condition = 'user.is_superuser'
elif condition == 'Только сотрудникам': elif condition == 'Только сотрудникам':
condition = 'user.platform_staff' exp.condition = 'user.platform_staff'
else: else:
condition = 'True' exp.condition = 'True'
update_experiment(self.request.POST['experiment_id'], enabled, condition) exp.save()
return '/experiments/?stage=' + self.stage return '/experiments/?stage=' + self.stage