39 lines
1.6 KiB
Python
39 lines
1.6 KiB
Python
# Generated by Django 2.2.16 on 2020-11-16 09:19
|
|
|
|
from django.conf import settings
|
|
from django.db import migrations, models
|
|
import django.db.models.deletion
|
|
import djangoldp.fields
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
dependencies = [
|
|
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
|
|
('djangoldp_notification', '0009_auto_20200619_0802'),
|
|
]
|
|
|
|
def create_settings(apps, schema_editor):
|
|
Users = apps.get_model('djangoldp_account', 'LDPUser')
|
|
Settings = apps.get_model('djangoldp_notification', 'NotificationSetting')
|
|
|
|
# iterate over all objects
|
|
for user in Users.objects.all():
|
|
if user.urlid.startswith(settings.SITE_URL):
|
|
Settings.objects.create(user=user)
|
|
|
|
operations = [
|
|
migrations.CreateModel(
|
|
name='NotificationSetting',
|
|
fields=[
|
|
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
('urlid', djangoldp.fields.LDPUrlField(blank=True, null=True, unique=True)),
|
|
('is_backlink', models.BooleanField(default=False, help_text='set automatically to indicate the Model is a backlink')),
|
|
('allow_create_backlink', models.BooleanField(default=True, help_text='set to False to disable backlink creation after Model save')),
|
|
('receiveMail', models.BooleanField(default=True)),
|
|
('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='settings', to=settings.AUTH_USER_MODEL)),
|
|
],
|
|
),
|
|
migrations.RunPython(create_settings),
|
|
]
|