Coverage for ivatar/ivataraccount/migrations/0008_userpreference.py: 100%
10 statements
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-26 00:11 +0000
« prev ^ index » next coverage.py v7.6.9, created at 2024-12-26 00:11 +0000
1# pylint: disable=invalid-name,missing-docstring
2# Generated by Django 2.0.6 on 2018-07-04 12:32
4from django.conf import settings
5from django.db import migrations, models
6import django.db.models.deletion
9def add_preference_to_user(apps, schema_editor): # pylint: disable=unused-argument
10 '''
11 Make sure all users have preferences set up
12 '''
13 from django.contrib.auth.models import User
14 UserPreference = apps.get_model('ivataraccount', 'UserPreference') # pylint: disable=invalid-name
15 for user in User.objects.filter(userpreference=None):
16 pref = UserPreference.objects.create(user_id=user.pk) # pragma: no cover
17 pref.save() # pragma: no cover
20class Migration(migrations.Migration): # pylint: disable=missing-docstring
22 dependencies = [
23 ('auth', '0009_alter_user_last_name_max_length'),
24 ('ivataraccount', '0007_auto_20180627_0624'),
25 ]
27 operations = [
28 migrations.CreateModel(
29 name='UserPreference',
30 fields=[
31 ('theme', models.CharField(
32 choices=[
33 ('default', 'Default theme'),
34 ('clime', 'Climes theme')],
35 default='default', max_length=10)),
36 ('user', models.OneToOneField(
37 on_delete=django.db.models.deletion.CASCADE,
38 primary_key=True,
39 serialize=False,
40 to=settings.AUTH_USER_MODEL)),
41 ],
42 ),
43 migrations.RunPython(add_preference_to_user),
44 ]