-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from mythmon/version-filtering-1248265
Release channels and M2M for country and locale
- Loading branch information
Showing
11 changed files
with
395 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,17 @@ | ||
import factory | ||
|
||
from normandy.classifier.models import Bundle | ||
from django.test import RequestFactory | ||
|
||
from normandy.classifier.models import Bundle, Client | ||
|
||
|
||
class BundleFactory(factory.Factory): | ||
class Meta: | ||
model = Bundle | ||
|
||
|
||
class ClientFactory(factory.Factory): | ||
class Meta: | ||
model = Client | ||
|
||
request = factory.LazyAttribute(lambda o: RequestFactory().get('/')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9 on 2016-02-19 01:01 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('recipes', '0015_auto_20160217_1819'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='ReleaseChannel', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('slug', models.SlugField(max_length=255, unique=True)), | ||
('name', models.CharField(max_length=255)), | ||
], | ||
options={ | ||
'ordering': ['slug'], | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name='recipe', | ||
name='release_channels', | ||
field=models.ManyToManyField(blank=True, to='recipes.ReleaseChannel'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9 on 2016-02-18 20:24 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('recipes', '0016_auto_20160219_0101'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Country', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('code', models.CharField(max_length=255, unique=True)), | ||
('name', models.CharField(max_length=255)), | ||
('order', models.IntegerField()), | ||
], | ||
options={ | ||
'ordering': ['order', 'name'], | ||
}, | ||
), | ||
migrations.AddField( | ||
model_name='locale', | ||
name='order', | ||
field=models.IntegerField(default=100), | ||
preserve_default=False, | ||
), | ||
migrations.RemoveField( | ||
model_name='recipe', | ||
name='country', | ||
), | ||
migrations.RemoveField( | ||
model_name='recipe', | ||
name='locale', | ||
), | ||
migrations.AddField( | ||
model_name='recipe', | ||
name='locales', | ||
field=models.ManyToManyField(blank=True, to='recipes.Locale'), | ||
), | ||
migrations.AddField( | ||
model_name='recipe', | ||
name='countries', | ||
field=models.ManyToManyField(blank=True, to='recipes.Country'), | ||
), | ||
migrations.AlterModelOptions( | ||
name='locale', | ||
options={'ordering': ['order', 'code']}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# -*- coding: utf-8 -*- | ||
# Generated by Django 1.9 on 2016-02-18 19:03 | ||
from __future__ import unicode_literals | ||
|
||
from django.db import migrations | ||
|
||
from django_countries import countries | ||
|
||
|
||
def add_countries(apps, schema_editor): | ||
Country = apps.get_model('recipes', 'Country') | ||
for (code, name) in countries: | ||
if code == 'US': | ||
order = 0 | ||
else: | ||
order = 100 | ||
|
||
Country.objects.update_or_create(code=code, defaults={ | ||
'name': name, | ||
'order': order, | ||
}) | ||
|
||
|
||
def remove_countries(apps, schema_editor): | ||
Country = apps.get_model('recipes', 'Country') | ||
Country.objects.all().delete() | ||
|
||
|
||
def set_locale_sort_order(apps, schema_editor): | ||
Locale = apps.get_model('recipes', 'Locale') | ||
try: | ||
english = Locale.objects.get(code='en-US') | ||
english.order = 0 | ||
english.save() | ||
except Locale.DoesNotExist: | ||
pass | ||
|
||
|
||
def noop(apps, schema_editor): | ||
pass | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('recipes', '0017_auto_20160218_2024'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(add_countries, remove_countries), | ||
migrations.RunPython(set_locale_sort_order, noop), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.