experiments
This commit is contained in:
29
experiments/models.py
Normal file
29
experiments/models.py
Normal file
@@ -0,0 +1,29 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
||||
|
||||
|
||||
class Experiment(models.Model):
|
||||
name = models.TextField()
|
||||
enabled = models.BooleanField(default=False)
|
||||
condition = models.TextField(default='False')
|
||||
project = models.ForeignKey('web.Project', on_delete=models.CASCADE)
|
||||
stage = models.TextField(default='production')
|
||||
|
||||
class Meta:
|
||||
indexes = [
|
||||
models.Index(fields=['project', 'stage']),
|
||||
models.Index(fields=['project', 'name', 'stage'])
|
||||
]
|
||||
|
||||
@property
|
||||
def exp_type(self):
|
||||
if self.condition == 'False':
|
||||
return 0
|
||||
if self.condition == 'user.is_superuser':
|
||||
return 1
|
||||
if self.condition == 'user.is_staff':
|
||||
return 2
|
||||
if self.condition == 'True':
|
||||
return 3
|
||||
return 4
|
Reference in New Issue
Block a user