Add Experiment Change Log fixes #157
This commit is contained in:
Родитель
7573f8ed0f
Коммит
aaf1b15764
|
@ -0,0 +1,39 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11 on 2017-08-15 15:44
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.db.models.deletion
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('experiments', '0013_auto_20170711_1745'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='ExperimentChangeLog',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('changed_on', models.DateTimeField(auto_now_add=True)),
|
||||
('changed_by', models.CharField(max_length=255)),
|
||||
('message', models.TextField()),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'Experiment Change Log',
|
||||
'verbose_name_plural': 'Experiment Change Logs',
|
||||
},
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='experiment',
|
||||
name='status',
|
||||
field=models.CharField(choices=[('Created', 'Created'), ('Pending Review', 'Pending Review'), ('Accepted', 'Accepted'), ('Launched', 'Launched'), ('Complete', 'Complete'), ('Rejected', 'Rejected')], default='Created', max_length=255),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='experimentchangelog',
|
||||
name='experiment',
|
||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='changes', to='experiments.Experiment'),
|
||||
),
|
||||
]
|
|
@ -152,3 +152,25 @@ class ExperimentVariant(models.Model):
|
|||
experiment_slug=self.experiment.slug,
|
||||
variant_slug=self.slug,
|
||||
)
|
||||
|
||||
|
||||
class ExperimentChangeLog(models.Model):
|
||||
experiment = models.ForeignKey(
|
||||
Experiment, blank=False, null=False, related_name='changes')
|
||||
changed_on = models.DateTimeField(auto_now_add=True)
|
||||
changed_by = models.CharField(max_length=255, blank=False, null=False)
|
||||
message = models.TextField()
|
||||
|
||||
def __str__(self): # pragma: no cover
|
||||
return (
|
||||
'{changed_by} changed {experiment} on {datetime}: {message}'
|
||||
).format(
|
||||
changed_by=self.changed_by,
|
||||
experiment=self.experiment,
|
||||
datetime=self.changed_on,
|
||||
message=self.message,
|
||||
)
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'Experiment Change Log'
|
||||
verbose_name_plural = 'Experiment Change Logs'
|
||||
|
|
|
@ -22,7 +22,7 @@ class OpenIDCAuthMiddlewareTests(TestCase):
|
|||
self.assertFalse(Group.objects.all().exists())
|
||||
group = self.middleware.get_experimenter_group()
|
||||
self.assertTrue(Group.objects.all().exists())
|
||||
self.assertEqual(group.permissions.all().count(), 9)
|
||||
self.assertEqual(group.permissions.all().count(), 12)
|
||||
self.assertEqual(
|
||||
set([
|
||||
permission.content_type.app_label for
|
||||
|
|
Загрузка…
Ссылка в новой задаче