Esempio n. 1
0
 class Meta:
     required_db_features = {'supports_table_check_constraints'}
     constraints = [models.CheckConstraint(check=models.Q(age__gte=18), name='is_adult')]
Esempio n. 2
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("auth", "0012_alter_user_first_name_max_length"),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name="Address",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("street1", models.CharField(max_length=50)),
                ("street2", models.CharField(blank=True, max_length=50, null=True)),
                ("zip", models.CharField(max_length=5)),
                ("city", models.CharField(max_length=50)),
            ],
        ),
        migrations.CreateModel(
            name="Membership",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "role",
                    models.CharField(
                        choices=[
                            (
                                "O",
                                "User has full control of the organization and its inventory.",
                            ),
                            (
                                "A",
                                "User can perform a restricted set of tasks in the organization.",
                            ),
                            ("I", "User can inspect the organization's inventory."),
                        ],
                        default="I",
                        max_length=1,
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Node",
            fields=[
                ("id", models.UUIDField(primary_key=True, serialize=False)),
                ("device_id", models.CharField(max_length=32, unique=True)),
                ("alias", models.CharField(max_length=30)),
            ],
        ),
        migrations.CreateModel(
            name="NodeInstallation",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("from_timestamp", models.PositiveIntegerField()),
                ("to_timestamp", models.PositiveIntegerField(null=True)),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "node",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="node_installations",
                        to="core.node",
                    ),
                ),
            ],
            options={
                "ordering": ["-from_timestamp"],
                "get_latest_by": "from_timestamp",
            },
        ),
        migrations.CreateModel(
            name="NodeProtocol",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("identifier", models.CharField(max_length=30, unique=True)),
                ("num_uplink_msgs", models.PositiveIntegerField(default=1)),
                ("num_downlink_msgs", models.PositiveIntegerField(default=1)),
            ],
        ),
        migrations.CreateModel(
            name="Organization",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=50)),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "users",
                    models.ManyToManyField(
                        through="core.Membership", to=settings.AUTH_USER_MODEL
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Profile",
            fields=[
                (
                    "user",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        primary_key=True,
                        serialize=False,
                        to="auth.user",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Quantity",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("quantity", models.CharField(max_length=30, unique=True)),
                ("base_unit", models.CharField(max_length=30)),
            ],
        ),
        migrations.CreateModel(
            name="NodeFidelity",
            fields=[
                (
                    "node",
                    models.OneToOneField(
                        on_delete=django.db.models.deletion.CASCADE,
                        primary_key=True,
                        serialize=False,
                        to="core.node",
                    ),
                ),
                (
                    "fidelity",
                    models.CharField(
                        choices=[
                            ("U", "node has never reported data"),
                            ("E", "node did report data recently"),
                            ("M", "node has not reported data recently"),
                            ("D", "node has not reported data for some time"),
                        ],
                        default="U",
                        max_length=1,
                    ),
                ),
                ("last_contact_s", models.PositiveIntegerField(null=True)),
                ("last_check_s", models.PositiveIntegerField()),
            ],
        ),
        migrations.CreateModel(
            name="Site",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=50)),
                ("description", models.TextField(blank=True, null=True)),
                (
                    "address",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="sites",
                        to="core.address",
                    ),
                ),
                (
                    "nodes",
                    models.ManyToManyField(
                        through="core.NodeInstallation", to="core.Node"
                    ),
                ),
                (
                    "operated_by",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="sites",
                        to="core.organization",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Sample",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("timestamp_s", models.PositiveIntegerField()),
                ("co2_ppm", models.PositiveSmallIntegerField()),
                (
                    "temperature_celsius",
                    models.DecimalField(decimal_places=1, max_digits=3, null=True),
                ),
                ("rel_humidity_percent", models.PositiveSmallIntegerField(null=True)),
                (
                    "measurement_status",
                    models.CharField(
                        choices=[
                            ("M", "measured value"),
                            ("R", "replacement value"),
                            ("E", "measurement error"),
                        ],
                        default="M",
                        max_length=1,
                    ),
                ),
                (
                    "node",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="samples",
                        to="core.node",
                    ),
                ),
            ],
            options={
                "ordering": ["-timestamp_s"],
                "get_latest_by": "timestamp_s",
            },
        ),
        migrations.CreateModel(
            name="NodeModel",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=30, unique=True)),
                ("trade_name", models.CharField(max_length=30)),
                ("manufacturer", models.CharField(max_length=30)),
                ("sensor_type", models.CharField(max_length=100)),
                (
                    "quantities",
                    models.ManyToManyField(
                        related_name="node_models", to="core.Quantity"
                    ),
                ),
            ],
        ),
        migrations.AddField(
            model_name="nodeinstallation",
            name="site",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="node_installations",
                to="core.site",
            ),
        ),
        migrations.AddField(
            model_name="node",
            name="model",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="nodes",
                to="core.nodemodel",
            ),
        ),
        migrations.AddField(
            model_name="node",
            name="owner",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="nodes",
                to="core.organization",
            ),
        ),
        migrations.AddField(
            model_name="node",
            name="protocol",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="nodes",
                to="core.nodeprotocol",
            ),
        ),
        migrations.AddField(
            model_name="membership",
            name="organization",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="user_membership",
                to="core.organization",
            ),
        ),
        migrations.AddField(
            model_name="membership",
            name="user",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="organization_membership",
                to=settings.AUTH_USER_MODEL,
            ),
        ),
        migrations.AddConstraint(
            model_name="address",
            constraint=models.UniqueConstraint(
                fields=("street1", "street2", "zip", "city"), name="unique_address"
            ),
        ),
        migrations.AddConstraint(
            model_name="site",
            constraint=models.UniqueConstraint(
                fields=("name", "operated_by"), name="unique_site_per_organization"
            ),
        ),
        migrations.AddConstraint(
            model_name="sample",
            constraint=models.UniqueConstraint(
                fields=("node", "timestamp_s"), name="unique_sampling_times_per_node"
            ),
        ),
        migrations.AddConstraint(
            model_name="sample",
            constraint=models.CheckConstraint(
                check=models.Q(rel_humidity_percent__lte=100),
                name="rel_humidity_percent",
            ),
        ),
        migrations.AddConstraint(
            model_name="sample",
            constraint=models.CheckConstraint(
                check=models.Q(temperature_celsius__gte=-20), name="not_too_cold"
            ),
        ),
        migrations.AddConstraint(
            model_name="sample",
            constraint=models.CheckConstraint(
                check=models.Q(temperature_celsius__lte=40), name="not_too_hot"
            ),
        ),
        migrations.AddConstraint(
            model_name="sample",
            constraint=models.CheckConstraint(
                check=models.Q(co2_ppm__lte=10000), name="co2_upper_limit"
            ),
        ),
        migrations.AddConstraint(
            model_name="nodeinstallation",
            constraint=models.UniqueConstraint(
                fields=("node", "from_timestamp"), name="unique_node_attribution"
            ),
        ),
        migrations.AddConstraint(
            model_name="membership",
            constraint=models.UniqueConstraint(
                fields=("user", "organization"), name="unique-membership"
            ),
        ),
    ]
Esempio n. 3
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('auth', '0011_update_proxy_permissions'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='CustomGoal',
            fields=[
                ('goal_id', models.AutoField(primary_key=True, serialize=False)),
                ('goal_description', models.TextField()),
                ('start_date', models.DateField()),
                ('date', models.DateField()),
                ('is_met', models.BooleanField(db_column='is_met')),
                ('checkin_interval', models.IntegerField()),
                ('act_frequency', models.IntegerField()),
                ('act_period_length', models.IntegerField()),
                ('pass_interval', models.IntegerField()),
                ('group_id', models.IntegerField(blank=True, null=True)),
            ],
            options={
                'verbose_name_plural': 'custom_goal',
                'db_table': 'custom_goal',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='ExerciseDictionary',
            fields=[
                ('exercise_id', models.AutoField(db_column='exercise_id', primary_key=True, serialize=False)),
                ('activity', models.CharField(blank=True, max_length=150, null=True)),
                ('specific_motion', models.CharField(blank=True, db_column='specific_motion', max_length=150, null=True)),
                ('met_value', models.FloatField(blank=True, db_column='met_value', null=True)),
            ],
            options={
                'verbose_name_plural': 'exercise_dictionary',
                'db_table': 'exercise_dictionary',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='FoodDictionary',
            fields=[
                ('food_id', models.AutoField(db_column='food_id', primary_key=True, serialize=False)),
                ('food_name', models.CharField(blank=True, db_column='food_name', max_length=150, unique=True)),
                ('calories', models.FloatField()),
            ],
            options={
                'verbose_name_plural': 'food_dictionary',
                'db_table': 'food_dictionary',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='UserProfile',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date_of_birth', models.DateField()),
                ('height', models.DecimalField(decimal_places=1, max_digits=4)),
                ('weight', models.DecimalField(decimal_places=1, max_digits=4)),
                ('waist_circumference', models.DecimalField(blank=True, decimal_places=1, max_digits=4, null=True)),
                ('profile_picture', models.ImageField(blank=True, upload_to='profile_image')),
                ('gender', models.TextField(choices=[('Male', 'Male'), ('Female', 'Female'), ('Prefer Not To Say', 'Other')], default='Prefer Not To Say')),
                ('user', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name_plural': 'user_profiles',
                'db_table': 'user_profile',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='UserFood',
            fields=[
                ('consumption_id', models.AutoField(db_column='consumption_id', primary_key=True, serialize=False)),
                ('calorie_eaten_per_food', models.FloatField()),
                ('date_intake', models.DateField(auto_now_add=True)),
                ('meal_category', models.TextField(choices=[('Breakfast', 'Breakfast'), ('Lunch', 'Lunch'), ('Dinner', 'Dinner')])),
                ('food_amount', models.IntegerField()),
                ('food_id', models.ForeignKey(db_column='food_id', on_delete=django.db.models.deletion.CASCADE, to='health_tracker.FoodDictionary')),
                ('user_id', models.ForeignKey(db_column='user_id', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name_plural': 'user_foods',
                'db_table': 'user_food',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='UserExercise',
            fields=[
                ('activity_id', models.AutoField(db_column='activity_id', primary_key=True, serialize=False)),
                ('calories_burnt', models.FloatField(db_column='calories_burnt')),
                ('activity_date', models.DateField(auto_now_add=True, db_column='activity_date', null=True)),
                ('duration', models.IntegerField(db_column='duration')),
                ('exercise_id', models.ForeignKey(db_column='exercise_id', on_delete=django.db.models.deletion.CASCADE, to='health_tracker.ExerciseDictionary')),
                ('user_id', models.ForeignKey(db_column='user_id', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name_plural': 'user_exercises',
                'db_table': 'user_exercise',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='UserCustomGoal',
            fields=[
                ('user_custom_goal', models.AutoField(primary_key=True, serialize=False)),
                ('goal_id', models.ForeignKey(db_column='goal_id', on_delete=django.db.models.deletion.CASCADE, to='health_tracker.CustomGoal')),
                ('user_id', models.ForeignKey(db_column='user_id', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name_plural': 'user_custom_goals',
                'db_table': 'user_custom_goal',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Post',
            fields=[
                ('post_id', models.AutoField(primary_key=True, serialize=False)),
                ('content', models.TextField()),
                ('date', models.DateTimeField(auto_now_add=True)),
                ('group', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='auth.Group')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'post',
                'ordering': ['-date'],
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Invitation',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=50)),
                ('email', models.EmailField(max_length=200)),
                ('code', models.CharField(max_length=200)),
                ('sender', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'invitation',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Groups',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('group_type', models.TextField(choices=[('OPEN', 'Open'), ('CLOSED', 'Closed')])),
                ('group_description', models.TextField(blank=True)),
                ('group', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='auth.Group')),
            ],
            options={
                'verbose_name_plural': 'groups',
                'db_table': 'groups',
                'managed': True,
            },
        ),
        migrations.AddField(
            model_name='fooddictionary',
            name='UserFood',
            field=models.ManyToManyField(through='health_tracker.UserFood', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='exercisedictionary',
            name='UserExercise',
            field=models.ManyToManyField(through='health_tracker.UserExercise', to=settings.AUTH_USER_MODEL),
        ),
        migrations.CreateModel(
            name='DailyWaterIntake',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('date', models.DateField(null=True)),
                ('cups_of_water', models.IntegerField(blank=True, null=True)),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'daily_water_intake',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='DailyUserExerciseNotes',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('note_date', models.DateField(auto_now_add=True, db_column='activity_date', null=True)),
                ('note_value', models.TextField(blank=True)),
                ('user_id', models.ForeignKey(db_column='user_id', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'daily_user_exercise_notes',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='CustomGoalProgress',
            fields=[
                ('custom_goal_progress', models.AutoField(primary_key=True, serialize=False)),
                ('date', models.DateField(null=True)),
                ('user_custom_goal', models.ForeignKey(db_column='user_custom_goal', on_delete=django.db.models.deletion.CASCADE, to='health_tracker.UserCustomGoal')),
            ],
            options={
                'verbose_name_plural': 'custom_goal_progress',
                'db_table': 'custom_goal_progress',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Comment',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('comment', models.TextField()),
                ('date', models.DateTimeField(auto_now_add=True)),
                ('post', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='health_tracker.Post')),
                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'db_table': 'comment',
                'ordering': ['date'],
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='BasicGoalProgress',
            fields=[
                ('basic_goal_progress_id', models.AutoField(primary_key=True, serialize=False)),
                ('date', models.DateField(null=True)),
                ('weight', models.FloatField()),
                ('user_id', models.ForeignKey(blank=True, db_column='user_id', null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name_plural': 'basic_goal_progress',
                'db_table': 'basic_goal_progress',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='BasicGoal',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('target_weight', models.FloatField()),
                ('date', models.DateField()),
                ('is_met', models.BooleanField(db_column='is_met')),
                ('metric', models.TextField(choices=[('Weight', 'Weight'), ('WaistCircumference', 'Waistcircumference')])),
                ('user_id', models.OneToOneField(db_column='user_id', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name_plural': 'basic_goal',
                'db_table': 'basic_goal',
                'managed': True,
            },
        ),
        migrations.CreateModel(
            name='Usergroup',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('is_admin', models.BooleanField(db_column='is_admin')),
                ('group_id', models.ForeignKey(db_column='group_id', on_delete=django.db.models.deletion.CASCADE, to='auth.Group')),
                ('user_id', models.ForeignKey(db_column='user_id', on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'verbose_name_plural': 'user_groups',
                'db_table': 'user_groups',
                'managed': True,
                'unique_together': {('user_id', 'group_id')},
            },
        ),
        migrations.AddConstraint(
            model_name='userfood',
            constraint=models.CheckConstraint(check=models.Q(calorie_eaten_per_food__gte=0), name='calorie_eaten_per_food_constraint'),
        ),
        migrations.AlterUniqueTogether(
            name='userfood',
            unique_together={('meal_category', 'user_id', 'food_id', 'date_intake')},
        ),
        migrations.AlterUniqueTogether(
            name='usercustomgoal',
            unique_together={('user_id', 'goal_id')},
        ),
        migrations.AddConstraint(
            model_name='fooddictionary',
            constraint=models.CheckConstraint(check=models.Q(calories__gt=0), name='calories_per_food_constraint'),
        ),
        migrations.AddConstraint(
            model_name='dailywaterintake',
            constraint=models.CheckConstraint(check=models.Q(cups_of_water__gte=0), name='cups_of_water_constraint'),
        ),
        migrations.AlterUniqueTogether(
            name='dailywaterintake',
            unique_together={('user_id', 'date')},
        ),
        migrations.AlterUniqueTogether(
            name='customgoalprogress',
            unique_together={('user_custom_goal', 'date')},
        ),
        migrations.AddConstraint(
            model_name='basicgoalprogress',
            constraint=models.CheckConstraint(check=models.Q(weight__gte=0), name='weight_constraint'),
        ),
        migrations.AlterUniqueTogether(
            name='basicgoalprogress',
            unique_together={('user_id', 'date')},
        ),
    ]
Esempio n. 4
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name='Choice',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('text',
                 models.CharField(max_length=4096,
                                  verbose_name='Choice text')),
            ],
            options={
                'verbose_name': 'Choice',
                'verbose_name_plural': 'Choices',
            },
        ),
        migrations.CreateModel(
            name='Poll',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title',
                 models.CharField(max_length=1024, verbose_name='Poll title')),
                ('created',
                 models.DateTimeField(auto_now_add=True,
                                      verbose_name='Poll created datetime')),
                ('finished',
                 models.DateField(verbose_name='Poll finished datetime')),
                ('description',
                 models.CharField(max_length=8192,
                                  verbose_name='Poll description')),
            ],
            options={
                'verbose_name': 'Poll',
                'verbose_name_plural': 'Polls',
            },
        ),
        migrations.CreateModel(
            name='Question',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title',
                 models.CharField(max_length=1024, verbose_name='Title')),
                ('text',
                 models.CharField(max_length=4096,
                                  verbose_name='Question text')),
                ('type',
                 models.CharField(choices=[('T', 'Text'), ('C', 'One choice'),
                                           ('M', 'Multipal choices')],
                                  default='T',
                                  max_length=1,
                                  verbose_name='Question type')),
            ],
            options={
                'verbose_name': 'Question',
                'verbose_name_plural': 'Questions',
            },
        ),
        migrations.AddConstraint(
            model_name='question',
            constraint=models.CheckConstraint(
                check=models.Q(type__in=('T', 'C', 'M')),
                name='%(app_label)s_%(class)s_type_valid'),
        ),
        migrations.AddField(
            model_name='choice',
            name='question',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.DO_NOTHING,
                related_name='choices_set',
                to='polls.Question'),
        ),
    ]
Esempio n. 5
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Category',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('slug', models.SlugField(unique=True)),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Genre',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('slug', models.SlugField(unique=True)),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Genre_Title',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('genre', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='api.Genre')),
            ],
        ),
        migrations.CreateModel(
            name='Title',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('name', models.CharField(max_length=100)),
                ('year', models.PositiveIntegerField()),
                ('description', models.CharField(blank=True, max_length=1000, null=True)),
                ('category', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='titles', to='api.Category')),
                ('genre', models.ManyToManyField(blank=True, through='api.Genre_Title', to='api.Genre')),
            ],
            options={
                'ordering': ['name'],
            },
        ),
        migrations.CreateModel(
            name='Review',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField(max_length=2000)),
                ('score', models.IntegerField(validators=[django.core.validators.MinValueValidator(1), django.core.validators.MaxValueValidator(10)])),
                ('pub_date', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews', to=settings.AUTH_USER_MODEL)),
                ('title', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='reviews', to='api.Title')),
            ],
            options={
                'verbose_name': 'Отзыв',
                'verbose_name_plural': 'Отзывы',
                'ordering': ['-pub_date'],
            },
        ),
        migrations.AddField(
            model_name='genre_title',
            name='title',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, to='api.Title'),
        ),
        migrations.CreateModel(
            name='Comments',
            fields=[
                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                ('text', models.TextField(max_length=2000)),
                ('pub_date', models.DateTimeField(auto_now_add=True, db_index=True)),
                ('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to=settings.AUTH_USER_MODEL)),
                ('review', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='comments', to='api.Review')),
            ],
            options={
                'verbose_name': 'Комментарий',
                'verbose_name_plural': 'Комментарии',
                'ordering': ['-pub_date'],
            },
        ),
        migrations.AddConstraint(
            model_name='title',
            constraint=models.CheckConstraint(check=models.Q(year__lte=2021), name='year_lte_current_year'),
        ),
    ]
Esempio n. 6
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("user_management", "0011_unique_fine_tuning"),
    ]

    operations = [
        migrations.CreateModel(
            name="Credentials",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("service_account", models.CharField(max_length=30)),
                ("project_id", models.CharField(max_length=30)),
                ("client_id", models.CharField(max_length=30)),
                ("client_email", models.CharField(max_length=100)),
                ("client_x509_cert_url", models.CharField(max_length=150)),
                (
                    "auth_uri",
                    models.CharField(
                        default="https://accounts.google.com/o/oauth2/auth",
                        max_length=100,
                    ),
                ),
                (
                    "token_uri",
                    models.CharField(
                        default="https://oauth2.googleapis.com/token",
                        max_length=100),
                ),
                (
                    "auth_provider_x509_cert_url",
                    models.CharField(
                        default="https://www.googleapis.com/oauth2/v1/certs",
                        max_length=100,
                    ),
                ),
                (
                    "private_key_id",
                    hexa.core.models.cryptography.EncryptedTextField(
                        max_length=50),
                ),
                ("private_key",
                 hexa.core.models.cryptography.EncryptedTextField()),
            ],
            options={
                "verbose_name": "GCS Credentials",
                "verbose_name_plural": "GCS Credentials",
                "ordering": ("service_account", ),
            },
        ),
        migrations.CreateModel(
            name="Bucket",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                ("auto_sync", models.BooleanField(default=True)),
                ("last_synced_at", models.DateTimeField(blank=True,
                                                        null=True)),
                ("name", models.CharField(max_length=200)),
                ("public", models.BooleanField(default=False)),
            ],
            options={
                "verbose_name": "GCS Bucket",
                "ordering": ("name", ),
            },
            bases=(hexa.catalog.models.IndexableMixin, models.Model),
        ),
        migrations.CreateModel(
            name="GCSBucketPermission",
            fields=[
                (
                    "id",
                    models.UUIDField(
                        default=uuid.uuid4,
                        editable=False,
                        primary_key=True,
                        serialize=False,
                    ),
                ),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "mode",
                    models.CharField(
                        choices=[
                            ("OWNER", "Owner"),
                            ("EDITOR", "Editor"),
                            ("VIEWER", "Viewer"),
                        ],
                        default="EDITOR",
                        max_length=200,
                    ),
                ),
                (
                    "bucket",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="connector_gcs.bucket",
                    ),
                ),
                (
                    "team",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="user_management.team",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.AddConstraint(
            model_name="gcsbucketpermission",
            constraint=models.UniqueConstraint(
                django.db.models.expressions.F("team"),
                django.db.models.expressions.F("bucket"),
                condition=models.Q(("team__isnull", False)),
                name="gcs_bucket_unique_team",
            ),
        ),
        migrations.AddConstraint(
            model_name="gcsbucketpermission",
            constraint=models.UniqueConstraint(
                django.db.models.expressions.F("user"),
                django.db.models.expressions.F("bucket"),
                condition=models.Q(("user__isnull", False)),
                name="gcs_bucket_unique_user",
            ),
        ),
        migrations.AddConstraint(
            model_name="gcsbucketpermission",
            constraint=models.CheckConstraint(
                check=models.Q(("team__isnull", False),
                               ("user__isnull", False),
                               _connector="OR"),
                name="gcs_bucket_permission_user_or_team_not_null",
            ),
        ),
        migrations.AlterModelOptions(
            name="gcsbucketpermission",
            options={"verbose_name": "Bucket Permission"},
        ),
    ]
Esempio n. 7
0
 class Meta:
     constraints = (models.CheckConstraint(check=models.Q(value__gt=0),
                                           name="value_positive"), )
Esempio n. 8
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('course', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='FixedAnswerQuestion',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('question_description', models.TextField()),
                ('answer_description', models.TextField()),
                ('hint', models.TextField(blank=True)),
                ('max_no_of_attempts', models.IntegerField()),
                ('marks', models.IntegerField(default=0)),
                ('gradable', models.BooleanField(default=False)),
                ('is_published', models.BooleanField(default=False)),
                ('created_on', models.DateTimeField(auto_now_add=True)),
                ('modified_on', models.DateTimeField(auto_now=True)),
                ('answer', models.TextField()),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='MultipleCorrectQuestion',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('question_description', models.TextField()),
                ('answer_description', models.TextField()),
                ('hint', models.TextField(blank=True)),
                ('max_no_of_attempts', models.IntegerField()),
                ('marks', models.IntegerField(default=0)),
                ('gradable', models.BooleanField(default=False)),
                ('is_published', models.BooleanField(default=False)),
                ('created_on', models.DateTimeField(auto_now_add=True)),
                ('modified_on', models.DateTimeField(auto_now=True)),
                ('options',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.TextField(), size=None)),
                ('correct_options',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.IntegerField(), size=None)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='QuestionModule',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title', models.CharField(max_length=100)),
                ('description', models.TextField(blank=True)),
                ('questions_sequence',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.IntegerField(),
                     blank=True,
                     null=True,
                     size=None)),
                ('created_on', models.DateTimeField(auto_now_add=True)),
                ('modified_on', models.DateTimeField(auto_now=True)),
            ],
        ),
        migrations.CreateModel(
            name='SingleCorrectQuestion',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('question_description', models.TextField()),
                ('answer_description', models.TextField()),
                ('hint', models.TextField(blank=True)),
                ('max_no_of_attempts', models.IntegerField()),
                ('marks', models.IntegerField(default=0)),
                ('gradable', models.BooleanField(default=False)),
                ('is_published', models.BooleanField(default=False)),
                ('created_on', models.DateTimeField(auto_now_add=True)),
                ('modified_on', models.DateTimeField(auto_now=True)),
                ('options',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.TextField(), size=None)),
                ('correct_option', models.IntegerField()),
                ('question_module',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='quiz.questionmodule')),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='SingleCorrectQuestionHistory',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('no_of_times_attempted', models.IntegerField(default=0)),
                ('marks_obtained', models.IntegerField(default=0)),
                ('hint_taken', models.BooleanField(default=False)),
                ('created_on', models.DateTimeField(auto_now_add=True)),
                ('modified_on', models.DateTimeField(auto_now=True)),
                ('option_selected', models.IntegerField()),
                ('question',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='quiz.singlecorrectquestion')),
                ('user',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Quiz',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('title', models.CharField(max_length=100)),
                ('description', models.TextField(blank=True)),
                ('question_module_sequence',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.IntegerField(),
                     blank=True,
                     null=True,
                     size=None)),
                ('created_on', models.DateTimeField(auto_now_add=True)),
                ('modified_on', models.DateTimeField(auto_now=True)),
                ('chapter',
                 models.ForeignKey(blank=True,
                                   null=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to='course.chapter')),
                ('section',
                 models.ForeignKey(blank=True,
                                   null=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to='course.section')),
            ],
        ),
        migrations.AddField(
            model_name='questionmodule',
            name='quiz',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE, to='quiz.quiz'),
        ),
        migrations.CreateModel(
            name='MultipleCorrectQuestionHistory',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('no_of_times_attempted', models.IntegerField(default=0)),
                ('marks_obtained', models.IntegerField(default=0)),
                ('hint_taken', models.BooleanField(default=False)),
                ('created_on', models.DateTimeField(auto_now_add=True)),
                ('modified_on', models.DateTimeField(auto_now=True)),
                ('options_selected',
                 django.contrib.postgres.fields.ArrayField(
                     base_field=models.IntegerField(), size=None)),
                ('question',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='quiz.multiplecorrectquestion')),
                ('user',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='multiplecorrectquestion',
            name='question_module',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='quiz.questionmodule'),
        ),
        migrations.CreateModel(
            name='FixedAnswerQuestionHistory',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('no_of_times_attempted', models.IntegerField(default=0)),
                ('marks_obtained', models.IntegerField(default=0)),
                ('hint_taken', models.BooleanField(default=False)),
                ('created_on', models.DateTimeField(auto_now_add=True)),
                ('modified_on', models.DateTimeField(auto_now=True)),
                ('answer_submitted', models.TextField()),
                ('question',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='quiz.fixedanswerquestion')),
                ('user',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.AddField(
            model_name='fixedanswerquestion',
            name='question_module',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='quiz.questionmodule'),
        ),
        migrations.AddConstraint(
            model_name='quiz',
            constraint=models.CheckConstraint(check=models.Q(
                ('chapter__isnull', False), ('section__isnull', False),
                _connector='OR'),
                                              name='both_not_null_in_quiz'),
        ),
    ]
Esempio n. 9
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="Car",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("name", models.CharField(max_length=50)),
            ],
        ),
        migrations.CreateModel(
            name="Manufacturer",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("name", models.CharField(max_length=50)),
            ],
        ),
        migrations.CreateModel(
            name="Rate",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("rating", models.IntegerField()),
                (
                    "car",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="app.car"),
                ),
            ],
        ),
        migrations.AddField(
            model_name="car",
            name="manufacturer",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to="app.manufacturer"),
        ),
        migrations.AddConstraint(
            model_name="rate",
            constraint=models.CheckConstraint(
                check=models.Q(("rating__gte", 1), ("rating__lte", 5)),
                name="Rating is between 1 and 5",
            ),
        ),
    ]
Esempio n. 10
0
 class Meta:
     constraints = [models.CheckConstraint(check=models.Q(id__gt=0), name='foo')]
     abstract = True
Esempio n. 11
0
 class Meta:
     constraints = [
         models.CheckConstraint(check=models.Q(id__gt=0), name='%(app_label)s_%(class)s_foo'),
     ]
     abstract = True
Esempio n. 12
0
 class Meta:
     constraints = [
         models.CheckConstraint(check=models.Q(id__gt=0), name='foo'),
         models.CheckConstraint(check=models.Q(id__lt=100), name='foo'),
     ]
Esempio n. 13
0
class OperationConstraints:
    class Operation:
        possible_types = [i[0] for i in OperationTypes.choices]
        is_abstract = True

    class PayInOperation:
        possible_types = (OperationTypes.PAY_IN, )
        constraints = (
            Q(type__in=possible_types, is_margin_call=False, payment__gt=0,
              instrument__isnull=True, quantity=0, commission=0, deal__isnull=True,
              dividend_tax=0, dividend_tax_date__isnull=True) & ~Q(_id='-1')
        )

    class PayOutOperation:
        possible_types = (OperationTypes.PAY_OUT, )
        constraints = (
            Q(type__in=possible_types, is_margin_call=False, payment__lt=0,
              instrument__isnull=True, quantity=0, commission=0, deal__isnull=True,
              dividend_tax=0, dividend_tax_date__isnull=True) & ~Q(_id='-1')
        )

    class PayOperation:
        possible_types = (OperationTypes.PAY_IN, OperationTypes.PAY_OUT)
        is_abstract = True

    class PurchaseOperation:
        possible_types = (OperationTypes.BUY, OperationTypes.BUY_CARD)
        is_abstract = True

    class CardPurchaseOperation:
        possible_types = (OperationTypes.BUY_CARD, )
        constraints = (
            Q(type__in=possible_types, payment__lt=0,
              instrument__isnull=False, quantity__gte=1,
              dividend_tax=0, dividend_tax_date__isnull=True) & ~Q(_id='-1')
        )

    class InvestmentAccountPurchaseOperation:
        possible_types = (OperationTypes.BUY, )
        constraints = (
            Q(type__in=possible_types, payment__lt=0,
              instrument__isnull=False, quantity__gte=1,
              dividend_tax=0, dividend_tax_date__isnull=True) & ~Q(_id='-1')
        )

    class SaleOperation:
        possible_types = (OperationTypes.SELL, )
        constraints = (
            Q(type__in=possible_types, payment__gt=0,
              instrument__isnull=False, quantity__gte=1,
              dividend_tax=0, dividend_tax_date__isnull=True) & ~Q(_id='-1')
        )

    class DividendOperation:
        possible_types = (OperationTypes.DIVIDEND, )
        constraints = (
            Q(type__in=possible_types, is_margin_call=False, payment__gt=0,
              instrument__isnull=False, quantity=0, commission=0,
              dividend_tax__lte=0) & ~Q(_id='-1')
        )

    class ServiceCommissionOperation:
        possible_types = (OperationTypes.SERVICE_COMMISSION, )
        constraints = (
            Q(type__in=possible_types, is_margin_call=False, payment__lt=0,
              instrument__isnull=True, quantity=0, commission=0, deal__isnull=True,
              dividend_tax=0, dividend_tax_date__isnull=True) & ~Q(_id='-1')
        )

    class MarginCommissionOperation:
        possible_types = (OperationTypes.MARGIN_COMMISSION, )
        constraints = (
            Q(type__in=possible_types, is_margin_call=False, payment__lt=0,
              instrument__isnull=True, quantity=0, commission=0, deal__isnull=True,
              dividend_tax=0, dividend_tax_date__isnull=True) & ~Q(_id='-1')
        )

    class TaxOperation:
        possible_types = (OperationTypes.TAX, )
        constraints = (
            Q(type__in=possible_types, is_margin_call=False, payment__lt=0,
              instrument__isnull=True, quantity=0, commission=0,
              deal__isnull=True, dividend_tax=0, dividend_tax_date__isnull=True) & ~Q(_id='-1')
        )

    class TaxBackOperation:
        possible_types = (OperationTypes.TAX_BACK, )
        constraints = (
            Q(type__in=possible_types, is_margin_call=False, payment__gt=0,
              instrument__isnull=True, quantity=0, commission=0,
              deal__isnull=True, dividend_tax=0, dividend_tax_date__isnull=True) & ~Q(_id='-1')
        )

    ALL_OPERATIONS = (
        PayInOperation, PayOutOperation, InvestmentAccountPurchaseOperation,
        CardPurchaseOperation, SaleOperation, DividendOperation,
        ServiceCommissionOperation, MarginCommissionOperation,
        TaxOperation, TaxBackOperation
    )
    ALL_PROXY_CONSTRAINTS = reduce(operator.or_, map(lambda x: getattr(x, 'constraints', Q()), ALL_OPERATIONS))
    ALL_PROXY_CONSTRAINTS |= Q(type=OperationTypes.UNKNOWN)
    ALL_CONSTRAINTS = [
        models.UniqueConstraint(fields=('investment_account', 'type', 'date'), name='unique_%(class)s'),
        models.UniqueConstraint(fields=('_id',), condition=~Q(_id=''), name='unique_id_$(class)s'),
        models.UniqueConstraint(fields=('investment_account', 'type', 'instrument', 'dividend_tax_date'),
                                condition=Q(dividend_tax_date__isnull=False), name='unique_div_tax_date'),
        models.CheckConstraint(
            name='%(class)s_restrict_property_set_by_type',
            check=ALL_PROXY_CONSTRAINTS
        )
    ]
Esempio n. 14
0
class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("opencodelists", "0007_auto_20210114_1139"),
        ("codelists", "0032_auto_20210423_1116"),
    ]

    operations = [
        migrations.CreateModel(
            name="Handle",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=255)),
                ("slug", models.SlugField()),
                ("is_current", models.BooleanField()),
                ("created_at", models.DateTimeField(auto_now_add=True)),
                ("updated_at", models.DateTimeField(auto_now=True)),
                (
                    "codelist",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="handles",
                        to="codelists.codelist",
                    ),
                ),
                (
                    "organisation",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="handles",
                        to="opencodelists.organisation",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="handles",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
        ),
        migrations.AddConstraint(
            model_name="handle",
            constraint=models.CheckConstraint(
                check=models.Q(
                    models.Q(("organisation_id__isnull", False),
                             ("user_id__isnull", True)),
                    models.Q(("organisation_id__isnull", True),
                             ("user_id__isnull", False)),
                    _connector="OR",
                ),
                name="codelists_handle_organisation_xor_user",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="handle",
            unique_together={
                ("user", "name", "slug"),
                ("organisation", "name", "slug"),
            },
        ),
    ]
class Migration(migrations.Migration):

    dependencies = [
        ("bookwyrm",
         "0111_merge_0107_auto_20211016_0639_0110_auto_20211015_1734"),
    ]

    operations = [
        migrations.RemoveConstraint(
            model_name="notification",
            name="notification_type_valid",
        ),
        migrations.AlterField(
            model_name="notification",
            name="notification_type",
            field=models.CharField(
                choices=[
                    ("FAVORITE", "Favorite"),
                    ("REPLY", "Reply"),
                    ("MENTION", "Mention"),
                    ("TAG", "Tag"),
                    ("FOLLOW", "Follow"),
                    ("FOLLOW_REQUEST", "Follow Request"),
                    ("BOOST", "Boost"),
                    ("IMPORT", "Import"),
                    ("ADD", "Add"),
                    ("REPORT", "Report"),
                    ("INVITE", "Invite"),
                    ("ACCEPT", "Accept"),
                    ("JOIN", "Join"),
                    ("LEAVE", "Leave"),
                    ("REMOVE", "Remove"),
                    ("GROUP_PRIVACY", "Group Privacy"),
                    ("GROUP_NAME", "Group Name"),
                    ("GROUP_DESCRIPTION", "Group Description"),
                ],
                max_length=255,
            ),
        ),
        migrations.AlterField(
            model_name="user",
            name="preferred_language",
            field=models.CharField(
                blank=True,
                choices=[
                    ("en-us", "English"),
                    ("de-de", "Deutsch (German)"),
                    ("es-es", "Español (Spanish)"),
                    ("fr-fr", "Français (French)"),
                    ("pt-br", "Português - Brasil (Brazilian Portuguese)"),
                    ("zh-hans", "简体中文 (Simplified Chinese)"),
                    ("zh-hant", "繁體中文 (Traditional Chinese)"),
                ],
                max_length=255,
                null=True,
            ),
        ),
        migrations.AddConstraint(
            model_name="notification",
            constraint=models.CheckConstraint(
                check=models.Q((
                    "notification_type__in",
                    [
                        "FAVORITE",
                        "REPLY",
                        "MENTION",
                        "TAG",
                        "FOLLOW",
                        "FOLLOW_REQUEST",
                        "BOOST",
                        "IMPORT",
                        "ADD",
                        "REPORT",
                        "INVITE",
                        "ACCEPT",
                        "JOIN",
                        "LEAVE",
                        "REMOVE",
                        "GROUP_PRIVACY",
                        "GROUP_NAME",
                        "GROUP_DESCRIPTION",
                    ],
                )),
                name="notification_type_valid",
            ),
        ),
    ]
Esempio n. 16
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('artworks', '0001_initial'),
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
    ]

    operations = [
        migrations.CreateModel(
            name='Review',
            fields=[
                (
                    'id',
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name='ID',
                    ),
                ),
                ('text', models.TextField()),
                ('score', models.IntegerField()),
                ('pub_date', models.DateTimeField(auto_now_add=True)),
                (
                    'author',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name='reviews',
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    'title',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name='reviews',
                        to='artworks.Title',
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name='Comment',
            fields=[
                (
                    'id',
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name='ID',
                    ),
                ),
                ('text', models.TextField()),
                ('pub_date', models.DateTimeField(auto_now_add=True)),
                (
                    'author',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name='comments',
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    'review',
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name='comments',
                        to='reviews.Review',
                    ),
                ),
            ],
        ),
        migrations.AddConstraint(
            model_name='review',
            constraint=models.CheckConstraint(
                check=models.Q(('score__gte', 1), ('score__lte', 10)),
                name='Score should be between 1 and 10',
            ),
        ),
        migrations.AddConstraint(
            model_name='review',
            constraint=models.UniqueConstraint(
                fields=('title', 'author'),
                name='Only one review allowed per title',
            ),
        ),
    ]
Esempio n. 17
0
class Migration(migrations.Migration):

    dependencies = [
        ("bookwyrm", "0048_merge_20210308_1754"),
    ]

    operations = [
        migrations.CreateModel(
            name="Report",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_date", models.DateTimeField(auto_now_add=True)),
                ("updated_date", models.DateTimeField(auto_now=True)),
                (
                    "remote_id",
                    bookwyrm.models.fields.RemoteIdField(
                        max_length=255,
                        null=True,
                        validators=[bookwyrm.models.fields.validate_remote_id],
                    ),
                ),
                ("note", models.TextField(blank=True, null=True)),
                ("resolved", models.BooleanField(default=False)),
                (
                    "reporter",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="reporter",
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
                (
                    "statuses",
                    models.ManyToManyField(blank=True,
                                           null=True,
                                           to="bookwyrm.Status"),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="ReportComment",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_date", models.DateTimeField(auto_now_add=True)),
                ("updated_date", models.DateTimeField(auto_now=True)),
                (
                    "remote_id",
                    bookwyrm.models.fields.RemoteIdField(
                        max_length=255,
                        null=True,
                        validators=[bookwyrm.models.fields.validate_remote_id],
                    ),
                ),
                ("note", models.TextField()),
                (
                    "report",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to="bookwyrm.Report",
                    ),
                ),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.AddConstraint(
            model_name="report",
            constraint=models.CheckConstraint(
                check=models.Q(
                    _negated=True,
                    reporter=django.db.models.expressions.F("user")),
                name="self_report",
            ),
        ),
    ]
Esempio n. 18
0
 class Meta:
     verbose_name_plural = 'Quizzes'
     constraints = [
         models.UniqueConstraint(fields=['name', 'difficulty', 'category'], name='unique quiz constraint'),
         models.CheckConstraint(check=models.Q(difficulty__in=['EASY','MEDIUM','HARD']), name="difficulty validity constraint"),
     ]
Esempio n. 19
0
 class Meta:
     ordering = ['price']
     constraints = [
         models.CheckConstraint(check=models.Q(price__gte=0),
                                name="price_not_negative")
     ]
Esempio n. 20
0
 class Meta:
     verbose_name_plural = 'Questions'
     constraints = [
         models.UniqueConstraint(fields=['index', 'quiz'], name='unique question constraint'),
         models.CheckConstraint(check=models.Q(answer__in=['A','B','C','D']), name="answer validity constraint"),
     ]
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ('experiment', '0001_initial'),
        ('s3', '0001_initial'),
        ('lib', '0001_initial'),
    ]

    operations = [
        migrations.AddField(
            model_name='well',
            name='compound',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='my_wells', to='lib.Compound'),
        ),
        migrations.AddField(
            model_name='well',
            name='compounds',
            field=models.ManyToManyField(blank=True, related_name='wells', to='lib.Compound'),
        ),
        migrations.AddField(
            model_name='well',
            name='plate',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='wells', to='experiment.Plate'),
        ),
        migrations.AddField(
            model_name='well',
            name='screen_ingredients',
            field=models.ManyToManyField(blank=True, related_name='wells', to='experiment.Ingredient'),
        ),
        migrations.AddField(
            model_name='subwell',
            name='compounds',
            field=models.ManyToManyField(blank=True, related_name='subwells', to='lib.Compound'),
        ),
        migrations.AddField(
            model_name='subwell',
            name='parentWell',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subwells', to='experiment.Well'),
        ),
        migrations.AddField(
            model_name='soak',
            name='dest',
            field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='soak', to='experiment.SubWell'),
        ),
        migrations.AddField(
            model_name='soak',
            name='experiment',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='soaks', to='experiment.Experiment'),
        ),
        migrations.AddField(
            model_name='soak',
            name='src',
            field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='soak', to='experiment.Well'),
        ),
        migrations.AddField(
            model_name='soak',
            name='storage',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='soaks', to='experiment.XtalContainer'),
        ),
        migrations.AddField(
            model_name='soak',
            name='transferCompound',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='soaks', to='lib.Compound'),
        ),
        migrations.AddField(
            model_name='project',
            name='collaborators',
            field=models.ManyToManyField(blank=True, related_name='collab_projects', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='project',
            name='editors',
            field=models.ManyToManyField(blank=True, related_name='editor_projects', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='project',
            name='owner',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='projects', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='plate',
            name='experiment',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='plates', to='experiment.Experiment'),
        ),
        migrations.AddField(
            model_name='plate',
            name='plateType',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='plates', to='experiment.PlateType'),
        ),
        migrations.AddField(
            model_name='experiment',
            name='destPlateType',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='experiments_dest', to='experiment.PlateType'),
        ),
        migrations.AddField(
            model_name='experiment',
            name='initData',
            field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='experiment', to='s3.PrivateFileJSON'),
        ),
        migrations.AddField(
            model_name='experiment',
            name='library',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='experiments', to='lib.Library'),
        ),
        migrations.AddField(
            model_name='experiment',
            name='owner',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='experiments', to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='experiment',
            name='picklist',
            field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='experiment', to='s3.PrivateFileCSV'),
        ),
        migrations.AddField(
            model_name='experiment',
            name='project',
            field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='experiments', to='experiment.Project'),
        ),
        migrations.AddField(
            model_name='experiment',
            name='srcPlateType',
            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='experiments_src', to='experiment.PlateType'),
        ),
        migrations.AddConstraint(
            model_name='well',
            constraint=models.UniqueConstraint(fields=('plate_id', 'name'), name='unique_well_name_in_plate'),
        ),
        migrations.AddConstraint(
            model_name='subwell',
            constraint=models.UniqueConstraint(fields=('parentWell_id', 'idx'), name='unique_subwell_in_well'),
        ),
        migrations.AlterUniqueTogether(
            name='subwell',
            unique_together={('parentWell', 'idx')},
        ),
        migrations.AddConstraint(
            model_name='plate',
            constraint=models.UniqueConstraint(fields=('plateIdxExp', 'isSource', 'experiment'), name='unique_src_dest_plate_idx'),
        ),
        migrations.AddConstraint(
            model_name='plate',
            constraint=models.CheckConstraint(check=models.Q(('isSource', False), ('isTemplate', True), _negated=True), name='source_can_only_be_template'),
        ),
        migrations.AddConstraint(
            model_name='plate',
            constraint=models.CheckConstraint(check=models.Q(('isSource', True), ('rockMakerId__isnull', False), _negated=True), name='dest_can_only_have_rockMakerId'),
        ),
        migrations.AddConstraint(
            model_name='experiment',
            constraint=models.UniqueConstraint(fields=('name', 'project'), name='unique_experiment_name_per_project'),
        ),
    ]
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("documenten", "0001_initial"),
        ("besluiten", "0001_initial"),
        ("catalogi", "0001_initial"),
        ("zaken", "0001_initial"),
    ]

    operations = [
        migrations.AddField(
            model_name="besluitinformatieobject",
            name="_informatieobject",
            field=models.ForeignKey(
                blank=True,
                help_text="URL-referentie naar het INFORMATIEOBJECT (in de Documenten API) waarin (een deel van) het besluit beschreven is.",
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to="documenten.EnkelvoudigInformatieObjectCanonical",
            ),
        ),
        migrations.AddField(
            model_name="besluitinformatieobject",
            name="besluit",
            field=models.ForeignKey(
                help_text="URL-referentie naar het BESLUIT.",
                on_delete=django.db.models.deletion.CASCADE,
                to="besluiten.Besluit",
            ),
        ),
        migrations.AddField(
            model_name="besluit",
            name="_besluittype",
            field=models.ForeignKey(
                blank=True,
                help_text="URL-referentie naar het BESLUITTYPE (in de Catalogi API).",
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to="catalogi.BesluitType",
            ),
        ),
        migrations.AddField(
            model_name="besluit",
            name="_zaak",
            field=models.ForeignKey(
                blank=True,
                help_text="URL-referentie naar de ZAAK (in de Zaken API) waarvan dit besluit uitkomst is.",
                null=True,
                on_delete=django.db.models.deletion.PROTECT,
                to="zaken.Zaak",
            ),
        ),
        migrations.AddConstraint(
            model_name="besluitinformatieobject",
            constraint=models.UniqueConstraint(
                condition=models.Q(_informatieobject_url="", _negated=True),
                fields=("besluit", "_informatieobject_url"),
                name="unique_besluit_and_external_document",
            ),
        ),
        migrations.AddConstraint(
            model_name="besluitinformatieobject",
            constraint=models.CheckConstraint(
                check=models.Q(
                    models.Q(
                        models.Q(_informatieobject__isnull=True, _negated=True),
                        ("_informatieobject_url", ""),
                    ),
                    models.Q(
                        ("_informatieobject__isnull", True),
                        models.Q(_informatieobject_url="", _negated=True),
                    ),
                    _connector="OR",
                ),
                name="_informatieobject_or__informatieobject_url_filled",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="besluitinformatieobject",
            unique_together={("besluit", "_informatieobject")},
        ),
        migrations.AddConstraint(
            model_name="besluit",
            constraint=models.CheckConstraint(
                check=models.Q(
                    models.Q(
                        models.Q(_besluittype__isnull=True, _negated=True),
                        ("_besluittype_url", ""),
                    ),
                    models.Q(
                        ("_besluittype__isnull", True),
                        models.Q(_besluittype_url="", _negated=True),
                    ),
                    _connector="OR",
                ),
                name="_besluittype_or__besluittype_url_filled",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="besluit",
            unique_together={("identificatie", "verantwoordelijke_organisatie")},
        ),
    ]
Esempio n. 23
0
class Migration(migrations.Migration):

    dependencies = [
        ("workstation_configs", "0004_workstationconfig_overlay_luts"),
    ]

    operations = [
        migrations.AddField(
            model_name="windowpreset",
            name="lower_percentile",
            field=models.PositiveSmallIntegerField(
                blank=True,
                null=True,
                validators=[
                    django.core.validators.MaxValueValidator(limit_value=100)
                ],
            ),
        ),
        migrations.AddField(
            model_name="windowpreset",
            name="upper_percentile",
            field=models.PositiveSmallIntegerField(
                blank=True,
                null=True,
                validators=[
                    django.core.validators.MaxValueValidator(limit_value=100)
                ],
            ),
        ),
        migrations.AlterField(
            model_name="windowpreset",
            name="center",
            field=models.IntegerField(blank=True, null=True),
        ),
        migrations.AlterField(
            model_name="windowpreset",
            name="width",
            field=models.PositiveIntegerField(
                blank=True,
                null=True,
                validators=[
                    django.core.validators.MinValueValidator(limit_value=1)
                ],
            ),
        ),
        migrations.AddConstraint(
            model_name="windowpreset",
            constraint=models.CheckConstraint(
                check=models.Q(
                    models.Q(
                        ("center__isnull", False),
                        ("lower_percentile__isnull", True),
                        ("upper_percentile__isnull", True),
                        ("width__isnull", False),
                    ),
                    models.Q(
                        ("center__isnull", True),
                        ("lower_percentile__isnull", False),
                        ("upper_percentile__isnull", False),
                        ("width__isnull", True),
                    ),
                    _connector="OR",
                ),
                name="workstation_configs_windowpreset_either_fixed_or_percentile",
            ),
        ),
        migrations.AddConstraint(
            model_name="windowpreset",
            constraint=models.CheckConstraint(
                check=models.Q(
                    upper_percentile__gt=django.db.models.expressions.F(
                        "lower_percentile"
                    )
                ),
                name="workstation_configs_windowpreset_upper_gt_lower_percentile",
            ),
        ),
        migrations.AddConstraint(
            model_name="windowpreset",
            constraint=models.CheckConstraint(
                check=models.Q(
                    ("width__gt", 0), ("width__isnull", True), _connector="OR"
                ),
                name="workstation_configs_windowpreset_width_gt_0",
            ),
        ),
    ]
Esempio n. 24
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('teams', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Location',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('external_id', models.IntegerField(unique=True)),
                ('city', models.CharField(max_length=255, null=True)),
                ('stadium', models.CharField(max_length=255, null=True)),
            ],
        ),
        migrations.CreateModel(
            name='Match',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('external_id', models.IntegerField(unique=True)),
                ('match_time_utc', models.DateTimeField(null=True)),
                ('last_update_utc', models.DateTimeField(null=True)),
                ('finished', models.BooleanField(default=False)),
                ('matchday', models.IntegerField(null=True)),
                ('location',
                 models.ForeignKey(null=True,
                                   on_delete=django.db.models.deletion.PROTECT,
                                   to='matches.Location')),
                ('team_1',
                 models.ForeignKey(on_delete=django.db.models.deletion.PROTECT,
                                   related_name='fk_team_1',
                                   to='teams.Team')),
                ('team_2',
                 models.ForeignKey(on_delete=django.db.models.deletion.PROTECT,
                                   related_name='fk_team_2',
                                   to='teams.Team')),
            ],
        ),
        migrations.CreateModel(
            name='MatchDayMetadata',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('matchday', models.IntegerField()),
                ('last_update', models.DateTimeField()),
            ],
            options={
                'db_table': 'matches_matchday_metadata',
            },
        ),
        migrations.CreateModel(
            name='Outcome',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('outcome_type', models.CharField(max_length=4)),
                ('match',
                 models.ForeignKey(on_delete=django.db.models.deletion.PROTECT,
                                   to='matches.Match')),
                ('team',
                 models.ForeignKey(on_delete=django.db.models.deletion.PROTECT,
                                   to='teams.Team')),
            ],
        ),
        migrations.CreateModel(
            name='Goal',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('external_id', models.IntegerField(unique=True)),
                ('goal_getter_name', models.CharField(max_length=255)),
                ('match_minute', models.IntegerField(null=True)),
                ('match',
                 models.ForeignKey(on_delete=django.db.models.deletion.PROTECT,
                                   to='matches.Match')),
                ('team',
                 models.ForeignKey(on_delete=django.db.models.deletion.PROTECT,
                                   to='teams.Team')),
            ],
        ),
        migrations.AddConstraint(
            model_name='outcome',
            constraint=models.CheckConstraint(
                check=models.Q(outcome_type__in=['win', 'loss', 'draw']),
                name='chk_outcome_type'),
        ),
        migrations.AddIndex(
            model_name='match',
            index=models.Index(fields=['team_1'],
                               name='matches_mat_team_1__dc1885_idx'),
        ),
        migrations.AddIndex(
            model_name='match',
            index=models.Index(fields=['team_2'],
                               name='matches_mat_team_2__3bedd0_idx'),
        ),
        migrations.AddIndex(
            model_name='goal',
            index=models.Index(fields=['match'],
                               name='matches_goa_match_i_e1b304_idx'),
        ),
    ]
Esempio n. 25
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('users', '0001_initial'),
    ]

    operations = [
        migrations.CreateModel(
            name='Request',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=150)),
                ('date_created', models.DateTimeField(auto_now_add=True)),
                ('deadline', models.DateTimeField()),
                ('owner',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='requests',
                                   to='users.customer')),
            ],
        ),
        migrations.CreateModel(
            name='Position',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=150)),
                ('okpd2', models.CharField(max_length=20)),
                ('okei', models.PositiveSmallIntegerField()),
                ('amount', models.PositiveIntegerField()),
                ('request',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='positions',
                                   to='market.request')),
            ],
        ),
        migrations.CreateModel(
            name='Payment',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('gmp', models.PositiveIntegerField()),
                ('date_created', models.DateTimeField(auto_now_add=True)),
                ('is_accepted', models.BooleanField(default=False)),
                ('executor',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='executors',
                                   to='users.executor')),
                ('position',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='positions',
                                   to='market.position')),
            ],
        ),
        migrations.CreateModel(
            name='ChangeHistory',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('stage',
                 models.CharField(choices=[
                     ('Created', 'Created'),
                     ('Assigned', 'Assigned to the executer'),
                     ('Paid', 'Payment issued'),
                     ('Returned', 'Returned to the executor'),
                     ('Canceled', 'executor removed from payment'),
                     ('Expired', 'Expired')
                 ],
                                  max_length=10)),
                ('date_created', models.DateTimeField(auto_now_add=True)),
                ('resolution', models.TextField()),
                ('executor',
                 models.OneToOneField(
                     on_delete=django.db.models.deletion.CASCADE,
                     to='users.executor')),
                ('position',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   related_name='changes',
                                   to='market.position')),
            ],
        ),
        migrations.AddConstraint(
            model_name='changehistory',
            constraint=models.CheckConstraint(
                check=models.Q(stage__in=[
                    'Created', 'Assigned', 'Paid', 'Returned', 'Canceled',
                    'Expired'
                ]),
                name='market_changehistory_stage_valid'),
        ),
    ]
Esempio n. 26
0
class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="Account",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("name", models.CharField(max_length=50, unique=True)),
                (
                    "balance",
                    models.DecimalField(
                        decimal_places=2,
                        max_digits=19,
                        validators=[
                            django.core.validators.MinValueValidator(
                                Decimal("0"))
                        ],
                    ),
                ),
                ("currency", wallet.models.CurrencyField()),
            ],
            options={
                "verbose_name": "account",
                "verbose_name_plural": "accounts"
            },
        ),
        migrations.CreateModel(
            name="Payment",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("created_datetime", models.DateTimeField(auto_now_add=True)),
                (
                    "amount",
                    models.DecimalField(
                        decimal_places=2,
                        max_digits=19,
                        validators=[
                            django.core.validators.MinValueValidator(
                                Decimal("0.01"))
                        ],
                    ),
                ),
                ("currency", wallet.models.CurrencyField()),
                (
                    "destination_account",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="incoming_payments",
                        to="wallet.Account",
                    ),
                ),
                (
                    "source_account",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.PROTECT,
                        related_name="outgoing_payments",
                        to="wallet.Account",
                    ),
                ),
            ],
            options={
                "verbose_name": "payment",
                "verbose_name_plural": "payments"
            },
        ),
        migrations.AddConstraint(
            model_name="account",
            constraint=models.CheckConstraint(check=models.Q(balance__gte=0),
                                              name="nonnegative_balance"),
        ),
        migrations.AddConstraint(
            model_name="payment",
            constraint=models.CheckConstraint(
                check=models.Q(
                    _negated=True,
                    source_account=django.db.models.expressions.F(
                        "destination_account"),
                ),
                name="source_destination_accounts_difference",
            ),
        ),
        migrations.AddConstraint(
            model_name="payment",
            constraint=models.CheckConstraint(check=models.Q(amount__gt=0),
                                              name="positive_amount"),
        ),
    ]
Esempio n. 27
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("core", "0001_initial"),
        ("sites", "0002_alter_domain_unique"),
    ]

    operations = [
        migrations.CreateModel(
            name="ChronosGlobalPermissions",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
            ],
            options={
                "default_permissions": (),
                "permissions": (
                    ("view_all_timetables", "Can view all timetables"),
                    ("view_timetable_overview", "Can view timetable overview"),
                    ("view_lessons_day", "Can view all lessons per day"),
                ),
                "managed":
                False,
            },
            managers=[
                ("objects",
                 django.contrib.sites.managers.CurrentSiteManager()),
            ],
        ),
        migrations.CreateModel(
            name="Break",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                (
                    "short_name",
                    models.CharField(max_length=255,
                                     verbose_name="Short name"),
                ),
                ("name",
                 models.CharField(max_length=255, verbose_name="Long name")),
            ],
            options={
                "verbose_name": "Break",
                "verbose_name_plural": "Breaks",
                "ordering": ["after_period"],
            },
            managers=[
                ("objects",
                 django.contrib.sites.managers.CurrentSiteManager()),
            ],
        ),
        migrations.CreateModel(
            name="Lesson",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                ("date_start",
                 models.DateField(null=True, verbose_name="Start date")),
                ("date_end",
                 models.DateField(null=True, verbose_name="End date")),
                (
                    "groups",
                    models.ManyToManyField(related_name="lessons",
                                           to="core.Group",
                                           verbose_name="Groups"),
                ),
            ],
            options={
                "verbose_name": "Lesson",
                "verbose_name_plural": "Lessons",
                "ordering": ["date_start", "subject"],
            },
            bases=(
                models.Model,
                aleksis.apps.chronos.managers.GroupPropertiesMixin,
                aleksis.apps.chronos.managers.TeacherPropertiesMixin,
            ),
            managers=[
                ("objects",
                 django.contrib.sites.managers.CurrentSiteManager()),
            ],
        ),
        migrations.CreateModel(
            name="LessonPeriod",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                (
                    "lesson",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="lesson_periods",
                        to="chronos.Lesson",
                        verbose_name="Lesson",
                    ),
                ),
            ],
            options={
                "verbose_name":
                "Lesson period",
                "verbose_name_plural":
                "Lesson periods",
                "ordering": [
                    "lesson__date_start",
                    "period__weekday",
                    "period__period",
                    "lesson__subject",
                ],
            },
        ),
        migrations.CreateModel(
            name="Supervision",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
            ],
            options={
                "verbose_name": "Supervision",
                "verbose_name_plural": "Supervisions",
                "ordering": ["area", "break_item"],
            },
        ),
        migrations.CreateModel(
            name="TimetableWidget",
            fields=[],
            options={
                "verbose_name": "Timetable widget",
                "verbose_name_plural": "Timetable widgets",
                "proxy": True,
                "indexes": [],
                "constraints": [],
            },
            bases=("core.dashboardwidget", ),
        ),
        migrations.CreateModel(
            name="TimePeriod",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                (
                    "weekday",
                    models.PositiveSmallIntegerField(
                        choices=[
                            (0, "Monday"),
                            (1, "Tuesday"),
                            (2, "Wednesday"),
                            (3, "Thursday"),
                            (4, "Friday"),
                            (5, "Saturday"),
                            (6, "Sunday"),
                        ],
                        verbose_name="Week day",
                    ),
                ),
                (
                    "period",
                    models.PositiveSmallIntegerField(
                        verbose_name="Number of period"),
                ),
                ("time_start", models.TimeField(verbose_name="Start time")),
                ("time_end", models.TimeField(verbose_name="End time")),
                (
                    "site",
                    models.ForeignKey(
                        default=1,
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="sites.Site",
                    ),
                ),
            ],
            options={
                "verbose_name": "Time period",
                "verbose_name_plural": "Time periods",
                "ordering": ["weekday", "period"],
            },
            managers=[
                ("objects",
                 django.contrib.sites.managers.CurrentSiteManager()),
            ],
        ),
        migrations.CreateModel(
            name="SupervisionSubstitution",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                ("date", models.DateField(verbose_name="Date")),
                (
                    "site",
                    models.ForeignKey(
                        default=1,
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="sites.Site",
                    ),
                ),
                (
                    "supervision",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="substitutions",
                        to="chronos.Supervision",
                        verbose_name="Supervision",
                    ),
                ),
                (
                    "teacher",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="substituted_supervisions",
                        to="core.Person",
                        verbose_name="Teacher",
                    ),
                ),
            ],
            options={
                "verbose_name": "Supervision substitution",
                "verbose_name_plural": "Supervision substitutions",
                "ordering": ["date", "supervision"],
            },
            managers=[],
        ),
        migrations.CreateModel(
            name="SupervisionArea",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                (
                    "short_name",
                    models.CharField(max_length=255,
                                     verbose_name="Short name"),
                ),
                ("name",
                 models.CharField(max_length=255, verbose_name="Long name")),
                (
                    "colour_fg",
                    colorfield.fields.ColorField(default="#000000",
                                                 max_length=18),
                ),
                (
                    "colour_bg",
                    colorfield.fields.ColorField(default="#FFFFFF",
                                                 max_length=18),
                ),
                (
                    "site",
                    models.ForeignKey(
                        default=1,
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="sites.Site",
                    ),
                ),
            ],
            options={
                "verbose_name": "Supervision area",
                "verbose_name_plural": "Supervision areas",
                "ordering": ["name"],
            },
            managers=[
                ("objects",
                 django.contrib.sites.managers.CurrentSiteManager()),
            ],
        ),
        migrations.AddField(
            model_name="supervision",
            name="area",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="supervisions",
                to="chronos.SupervisionArea",
                verbose_name="Supervision area",
            ),
        ),
        migrations.AddField(
            model_name="supervision",
            name="break_item",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="supervisions",
                to="chronos.Break",
                verbose_name="Break",
            ),
        ),
        migrations.AddField(
            model_name="supervision",
            name="site",
            field=models.ForeignKey(
                default=1,
                editable=False,
                on_delete=django.db.models.deletion.CASCADE,
                to="sites.Site",
            ),
        ),
        migrations.AddField(
            model_name="supervision",
            name="teacher",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="supervisions",
                to="core.Person",
                verbose_name="Teacher",
            ),
        ),
        migrations.CreateModel(
            name="Subject",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                (
                    "short_name",
                    models.CharField(max_length=255,
                                     unique=True,
                                     verbose_name="Short name"),
                ),
                (
                    "name",
                    models.CharField(max_length=255,
                                     unique=True,
                                     verbose_name="Long name"),
                ),
                (
                    "colour_fg",
                    colorfield.fields.ColorField(
                        blank=True,
                        default="",
                        max_length=18,
                        verbose_name="Foreground colour",
                    ),
                ),
                (
                    "colour_bg",
                    colorfield.fields.ColorField(
                        blank=True,
                        default="",
                        max_length=18,
                        verbose_name="Background colour",
                    ),
                ),
                (
                    "site",
                    models.ForeignKey(
                        default=1,
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="sites.Site",
                    ),
                ),
            ],
            options={
                "verbose_name": "Subject",
                "verbose_name_plural": "Subjects",
                "ordering": ["name", "short_name"],
            },
            managers=[
                ("objects",
                 django.contrib.sites.managers.CurrentSiteManager()),
            ],
        ),
        migrations.CreateModel(
            name="Room",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                (
                    "short_name",
                    models.CharField(max_length=255,
                                     unique=True,
                                     verbose_name="Short name"),
                ),
                ("name",
                 models.CharField(max_length=255, verbose_name="Long name")),
                (
                    "site",
                    models.ForeignKey(
                        default=1,
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="sites.Site",
                    ),
                ),
            ],
            options={
                "verbose_name": "Room",
                "verbose_name_plural": "Rooms",
                "ordering": ["name", "short_name"],
            },
            managers=[
                ("objects",
                 django.contrib.sites.managers.CurrentSiteManager()),
            ],
        ),
        migrations.CreateModel(
            name="LessonSubstitution",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                (
                    "week",
                    models.IntegerField(
                        default=calendarweek.calendarweek.CalendarWeek.
                        current_week,
                        verbose_name="Week",
                    ),
                ),
                (
                    "cancelled",
                    models.BooleanField(default=False,
                                        verbose_name="Cancelled?"),
                ),
                (
                    "cancelled_for_teachers",
                    models.BooleanField(
                        default=False, verbose_name="Cancelled for teachers?"),
                ),
                (
                    "comment",
                    models.TextField(blank=True,
                                     null=True,
                                     verbose_name="Comment"),
                ),
                (
                    "lesson_period",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="substitutions",
                        to="chronos.LessonPeriod",
                        verbose_name="Lesson period",
                    ),
                ),
                (
                    "room",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="chronos.Room",
                        verbose_name="Room",
                    ),
                ),
                (
                    "site",
                    models.ForeignKey(
                        default=1,
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="sites.Site",
                    ),
                ),
                (
                    "subject",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="lesson_substitutions",
                        to="chronos.Subject",
                        verbose_name="Subject",
                    ),
                ),
                (
                    "teachers",
                    models.ManyToManyField(
                        blank=True,
                        related_name="lesson_substitutions",
                        to="core.Person",
                        verbose_name="Teachers",
                    ),
                ),
            ],
            options={
                "verbose_name":
                "Lesson substitution",
                "verbose_name_plural":
                "Lesson substitutions",
                "ordering": [
                    "lesson_period__lesson__date_start",
                    "week",
                    "lesson_period__period__weekday",
                    "lesson_period__period__period",
                ],
            },
        ),
        migrations.AddField(
            model_name="lessonperiod",
            name="period",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="lesson_periods",
                to="chronos.TimePeriod",
                verbose_name="Time period",
            ),
        ),
        migrations.AddField(
            model_name="lessonperiod",
            name="room",
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="lesson_periods",
                to="chronos.Room",
                verbose_name="Room",
            ),
        ),
        migrations.AddField(
            model_name="lessonperiod",
            name="site",
            field=models.ForeignKey(
                default=1,
                editable=False,
                on_delete=django.db.models.deletion.CASCADE,
                to="sites.Site",
            ),
        ),
        migrations.AddField(
            model_name="lesson",
            name="periods",
            field=models.ManyToManyField(
                related_name="lessons",
                through="chronos.LessonPeriod",
                to="chronos.TimePeriod",
                verbose_name="Periods",
            ),
        ),
        migrations.AddField(
            model_name="lesson",
            name="site",
            field=models.ForeignKey(
                default=1,
                editable=False,
                on_delete=django.db.models.deletion.CASCADE,
                to="sites.Site",
            ),
        ),
        migrations.AddField(
            model_name="lesson",
            name="subject",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                related_name="lessons",
                to="chronos.Subject",
                verbose_name="Subject",
            ),
        ),
        migrations.AddField(
            model_name="lesson",
            name="teachers",
            field=models.ManyToManyField(
                related_name="lessons_as_teacher",
                to="core.Person",
                verbose_name="Teachers",
            ),
        ),
        migrations.CreateModel(
            name="Holiday",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                ("title", models.CharField(max_length=255,
                                           verbose_name="Title")),
                ("date_start",
                 models.DateField(null=True, verbose_name="Start date")),
                ("date_end",
                 models.DateField(null=True, verbose_name="End date")),
                (
                    "comments",
                    models.TextField(blank=True,
                                     null=True,
                                     verbose_name="Comments"),
                ),
                (
                    "site",
                    models.ForeignKey(
                        default=1,
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="sites.Site",
                    ),
                ),
            ],
            options={
                "verbose_name": "Holiday",
                "verbose_name_plural": "Holidays",
                "ordering": ["date_start"],
            },
        ),
        migrations.CreateModel(
            name="ExtraLesson",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                (
                    "week",
                    models.IntegerField(
                        default=calendarweek.calendarweek.CalendarWeek.
                        current_week,
                        verbose_name="Week",
                    ),
                ),
                (
                    "comment",
                    models.CharField(blank=True,
                                     max_length=255,
                                     null=True,
                                     verbose_name="Comment"),
                ),
                (
                    "groups",
                    models.ManyToManyField(
                        related_name="extra_lessons",
                        to="core.Group",
                        verbose_name="Groups",
                    ),
                ),
                (
                    "period",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="extra_lessons",
                        to="chronos.TimePeriod",
                        verbose_name="Time period",
                    ),
                ),
                (
                    "room",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="extra_lessons",
                        to="chronos.Room",
                        verbose_name="Room",
                    ),
                ),
                (
                    "site",
                    models.ForeignKey(
                        default=1,
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="sites.Site",
                    ),
                ),
                (
                    "subject",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="extra_lessons",
                        to="chronos.Subject",
                        verbose_name="Subject",
                    ),
                ),
                (
                    "teachers",
                    models.ManyToManyField(
                        related_name="extra_lessons_as_teacher",
                        to="core.Person",
                        verbose_name="Teachers",
                    ),
                ),
            ],
            options={
                "verbose_name": "Extra lesson",
                "verbose_name_plural": "Extra lessons",
            },
            bases=(models.Model,
                   aleksis.apps.chronos.managers.GroupPropertiesMixin),
        ),
        migrations.CreateModel(
            name="Exam",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                ("date",
                 models.DateField(null=True, verbose_name="Date of exam")),
                ("title", models.CharField(max_length=255,
                                           verbose_name="Title")),
                (
                    "comment",
                    models.TextField(blank=True,
                                     null=True,
                                     verbose_name="Comment"),
                ),
                (
                    "lesson",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="exams",
                        to="chronos.Lesson",
                        verbose_name="Lesson",
                    ),
                ),
                (
                    "period_from",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="chronos.TimePeriod",
                        verbose_name="Start period",
                    ),
                ),
                (
                    "period_to",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="chronos.TimePeriod",
                        verbose_name="End period",
                    ),
                ),
                (
                    "site",
                    models.ForeignKey(
                        default=1,
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="sites.Site",
                    ),
                ),
            ],
            options={
                "verbose_name": "Exam",
                "verbose_name_plural": "Exams",
                "ordering": ["date"],
            },
            managers=[
                ("objects",
                 django.contrib.sites.managers.CurrentSiteManager()),
            ],
        ),
        migrations.CreateModel(
            name="Event",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                (
                    "title",
                    models.CharField(blank=True,
                                     max_length=255,
                                     null=True,
                                     verbose_name="Title"),
                ),
                ("date_start",
                 models.DateField(null=True, verbose_name="Start date")),
                ("date_end",
                 models.DateField(null=True, verbose_name="End date")),
                (
                    "groups",
                    models.ManyToManyField(related_name="events",
                                           to="core.Group",
                                           verbose_name="Groups"),
                ),
                (
                    "period_from",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="chronos.TimePeriod",
                        verbose_name="Start time period",
                    ),
                ),
                (
                    "period_to",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="chronos.TimePeriod",
                        verbose_name="End time period",
                    ),
                ),
                (
                    "rooms",
                    models.ManyToManyField(related_name="events",
                                           to="chronos.Room",
                                           verbose_name="Rooms"),
                ),
                (
                    "site",
                    models.ForeignKey(
                        default=1,
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="sites.Site",
                    ),
                ),
                (
                    "teachers",
                    models.ManyToManyField(related_name="events",
                                           to="core.Person",
                                           verbose_name="Teachers"),
                ),
            ],
            options={
                "verbose_name": "Event",
                "verbose_name_plural": "Events",
                "ordering": ["date_start"],
            },
            bases=(
                models.Model,
                aleksis.apps.chronos.managers.GroupPropertiesMixin,
                aleksis.apps.chronos.managers.TeacherPropertiesMixin,
            ),
        ),
        migrations.AddField(
            model_name="break",
            name="after_period",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="break_after",
                to="chronos.TimePeriod",
                verbose_name="Time period after break starts",
            ),
        ),
        migrations.AddField(
            model_name="break",
            name="before_period",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="break_before",
                to="chronos.TimePeriod",
                verbose_name="Time period before break ends",
            ),
        ),
        migrations.AddField(
            model_name="break",
            name="site",
            field=models.ForeignKey(
                default=1,
                editable=False,
                on_delete=django.db.models.deletion.CASCADE,
                to="sites.Site",
            ),
        ),
        migrations.CreateModel(
            name="AbsenceReason",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                (
                    "short_name",
                    models.CharField(max_length=255,
                                     verbose_name="Short name"),
                ),
                (
                    "name",
                    models.CharField(blank=True,
                                     max_length=255,
                                     null=True,
                                     verbose_name="Name"),
                ),
                (
                    "site",
                    models.ForeignKey(
                        default=1,
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="sites.Site",
                    ),
                ),
            ],
            options={
                "verbose_name": "Absence reason",
                "verbose_name_plural": "Absence reasons",
            },
            managers=[
                ("objects",
                 django.contrib.sites.managers.CurrentSiteManager()),
            ],
        ),
        migrations.CreateModel(
            name="Absence",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "extended_data",
                    models.JSONField(default=dict, editable=False),
                ),
                ("date_start",
                 models.DateField(null=True, verbose_name="Start date")),
                ("date_end",
                 models.DateField(null=True, verbose_name="End date")),
                (
                    "comment",
                    models.TextField(blank=True,
                                     null=True,
                                     verbose_name="Comment"),
                ),
                (
                    "group",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="absences",
                        to="core.Group",
                        verbose_name="Group",
                    ),
                ),
                (
                    "period_from",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="chronos.TimePeriod",
                        verbose_name="Start period",
                    ),
                ),
                (
                    "period_to",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="+",
                        to="chronos.TimePeriod",
                        verbose_name="End period",
                    ),
                ),
                (
                    "reason",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        related_name="absences",
                        to="chronos.AbsenceReason",
                        verbose_name="Absence reason",
                    ),
                ),
                (
                    "room",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="absences",
                        to="chronos.Room",
                        verbose_name="Room",
                    ),
                ),
                (
                    "site",
                    models.ForeignKey(
                        default=1,
                        editable=False,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="sites.Site",
                    ),
                ),
                (
                    "teacher",
                    models.ForeignKey(
                        blank=True,
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        related_name="absences",
                        to="core.Person",
                        verbose_name="Teacher",
                    ),
                ),
            ],
            options={
                "verbose_name": "Absence",
                "verbose_name_plural": "Absences",
                "ordering": ["date_start"],
            },
        ),
        migrations.AddIndex(
            model_name="timeperiod",
            index=models.Index(fields=["time_start", "time_end"],
                               name="chronos_tim_time_st_491e4c_idx"),
        ),
        migrations.AlterUniqueTogether(
            name="timeperiod",
            unique_together={("weekday", "period")},
        ),
        migrations.AddConstraint(
            model_name="lessonsubstitution",
            constraint=models.CheckConstraint(
                check=models.Q(("cancelled", True), ("subject__isnull", False),
                               _negated=True),
                name="either_substituted_or_cancelled",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="lessonsubstitution",
            unique_together={("lesson_period", "week")},
        ),
        migrations.AddIndex(
            model_name="lessonperiod",
            index=models.Index(fields=["lesson", "period"],
                               name="chronos_les_lesson__05250e_idx"),
        ),
        migrations.AddIndex(
            model_name="lesson",
            index=models.Index(fields=["date_start", "date_end"],
                               name="chronos_les_date_st_5ecc62_idx"),
        ),
        migrations.AddIndex(
            model_name="holiday",
            index=models.Index(fields=["date_start", "date_end"],
                               name="chronos_hol_date_st_a47004_idx"),
        ),
        migrations.AddIndex(
            model_name="exam",
            index=models.Index(fields=["date"],
                               name="chronos_exa_date_5ba442_idx"),
        ),
        migrations.AddIndex(
            model_name="event",
            index=models.Index(
                fields=["period_from", "period_to", "date_start", "date_end"],
                name="chronos_eve_period__c7ec33_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="break",
            index=models.Index(
                fields=["after_period", "before_period"],
                name="chronos_bre_after_p_0f28d3_idx",
            ),
        ),
        migrations.AddIndex(
            model_name="absence",
            index=models.Index(fields=["date_start", "date_end"],
                               name="chronos_abs_date_st_337ff5_idx"),
        ),
    ]
Esempio n. 28
0
 class Meta:
     verbose_name = verbose_name_plural = "评价依据模版"
     constraints = [
         models.CheckConstraint(check=models.Q(full_marks__gte=0), name='full_marks_gte_0'),
     ]
class Migration(migrations.Migration):

    dependencies = [
        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
        ("data", "0014_adjust_fields"),
    ]

    operations = [
        migrations.CreateModel(
            name="BaseLocation",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "id_string",
                    models.CharField(blank=True,
                                     max_length=32,
                                     unique=True,
                                     verbose_name="unique id"),
                ),
                (
                    "type",
                    models.CharField(
                        choices=[("GASTRO", "Gastro"),
                                 ("SHOPPING", "Shopping")],
                        editable=False,
                        max_length=8,
                    ),
                ),
                (
                    "created",
                    models.DateTimeField(auto_now_add=True,
                                         verbose_name="created"),
                ),
                (
                    "updated",
                    models.DateTimeField(auto_now=True,
                                         verbose_name="updated"),
                ),
                (
                    "name",
                    models.CharField(max_length=100,
                                     verbose_name="Name of location"),
                ),
                (
                    "street",
                    models.CharField(max_length=100,
                                     verbose_name="Street / No"),
                ),
                (
                    "postal_code",
                    models.CharField(max_length=5, verbose_name="Postal code"),
                ),
                (
                    "city",
                    models.CharField(default="Berlin",
                                     max_length=20,
                                     verbose_name="City"),
                ),
                ("latitude", models.FloatField(verbose_name="latitude")),
                ("longitude", models.FloatField(verbose_name="longitude")),
                (
                    "telephone",
                    models.CharField(blank=True,
                                     max_length=25,
                                     null=True,
                                     verbose_name="Telephone"),
                ),
                (
                    "website",
                    models.URLField(blank=True,
                                    null=True,
                                    verbose_name="Website"),
                ),
                (
                    "email",
                    models.EmailField(blank=True,
                                      max_length=254,
                                      null=True,
                                      verbose_name="E-mail"),
                ),
                (
                    "vegan",
                    models.IntegerField(
                        choices=[
                            (2, "Ominvore (vegan labeled)"),
                            (4, "Vegetarian (vegan labeled)"),
                            (5, "Vegan"),
                        ],
                        verbose_name="Vegan friendly",
                    ),
                ),
                (
                    "comment",
                    models.TextField(blank=True,
                                     default="",
                                     verbose_name="Comment in German"),
                ),
                (
                    "comment_english",
                    models.TextField(blank=True,
                                     default="",
                                     verbose_name="Comment in English"),
                ),
                (
                    "comment_opening_hours",
                    models.TextField(blank=True,
                                     default="",
                                     verbose_name="Comment opening hours"),
                ),
                (
                    "review_link",
                    models.URLField(
                        blank=True,
                        default="",
                        max_length=255,
                        verbose_name="review link",
                    ),
                ),
                (
                    "closed",
                    models.DateField(default=None,
                                     null=True,
                                     verbose_name="closed"),
                ),
                (
                    "text_intern",
                    models.TextField(blank=True,
                                     default="",
                                     verbose_name="text intern"),
                ),
                (
                    "has_sticker",
                    models.BooleanField(default=False, verbose_name="Sticker"),
                ),
                (
                    "is_submission",
                    models.BooleanField(default=True,
                                        verbose_name="Submission"),
                ),
                (
                    "submit_email",
                    models.EmailField(
                        blank=True,
                        max_length=254,
                        null=True,
                        verbose_name="Submitter e-mail",
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="BooleanAttribute",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "name",
                    models.CharField(
                        choices=[
                            ("organic", "Organic"),
                            ("delivery", "Delivery"),
                            ("handicapped_accessible",
                             "Handicapped Accessible"),
                            ("webshop", "Webshop"),
                        ],
                        max_length=22,
                    ),
                ),
                (
                    "state",
                    models.BooleanField(
                        choices=[(None, "unknown"), (True, "yes"),
                                 (False, "no")],
                        null=True,
                    ),
                ),
            ],
        ),
        migrations.CreateModel(
            name="OpeningHours",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "weekday",
                    models.CharField(
                        choices=[
                            ("MONDAY", "Monday"),
                            ("TUESDAY", "Tuesday"),
                            ("WEDNESDAY", "Wednesday"),
                            ("THURSDAY", "Thursday"),
                            ("FRIDAY", "Friday"),
                            ("SATURDAY", "Saturday"),
                            ("SUNDAY", "Sunday"),
                        ],
                        max_length=9,
                    ),
                ),
                ("opening", models.TimeField(blank=True, null=True)),
                ("closing", models.TimeField(blank=True, null=True)),
            ],
        ),
        migrations.CreateModel(
            name="Tag",
            fields=[
                (
                    "id",
                    models.AutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                (
                    "tag",
                    models.CharField(
                        choices=[
                            ("foods", "Foods"),
                            ("clothing", "Clothing"),
                            ("toiletries", "Toiletries"),
                            ("supermarket", "Supermarket"),
                            ("hairdressers", "Hairdressers"),
                            ("sports", "Sports"),
                            ("tattoostudio", "Tattoostudio"),
                            ("accommodation", "accommodation"),
                            ("bar", "Bar"),
                            ("cafe", "Cafe"),
                            ("ice cream parlor", "Ice Cream Parlor"),
                            ("snack bar", "Snack Bar"),
                            ("restaurant", "Restaurant"),
                        ],
                        max_length=16,
                        unique=True,
                    ),
                ),
            ],
        ),
        migrations.AddConstraint(
            model_name="tag",
            constraint=models.CheckConstraint(
                check=models.Q((
                    "tag__in",
                    [
                        "foods",
                        "clothing",
                        "toiletries",
                        "supermarket",
                        "hairdressers",
                        "sports",
                        "tattoostudio",
                        "accommodation",
                        "bar",
                        "cafe",
                        "ice cream parlor",
                        "snack bar",
                        "restaurant",
                    ],
                )),
                name="data_tag_tag_valid",
            ),
        ),
        migrations.AddField(
            model_name="openinghours",
            name="location",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to="data.baselocation"),
        ),
        migrations.AddConstraint(
            model_name="booleanattribute",
            constraint=models.CheckConstraint(
                check=models.Q((
                    "name__in",
                    [
                        "organic", "delivery", "handicapped_accessible",
                        "webshop"
                    ],
                )),
                name="data_booleanattribute_name_valid",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="booleanattribute",
            unique_together={("name", "state")},
        ),
        migrations.AddField(
            model_name="baselocation",
            name="boolean_attributes",
            field=models.ManyToManyField(to="data.BooleanAttribute"),
        ),
        migrations.AddField(
            model_name="baselocation",
            name="last_editor",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.SET_NULL,
                to=settings.AUTH_USER_MODEL,
                verbose_name="last editor",
            ),
        ),
        migrations.AddField(
            model_name="baselocation",
            name="tags",
            field=models.ManyToManyField(to="data.Tag"),
        ),
        migrations.AddConstraint(
            model_name="openinghours",
            constraint=models.CheckConstraint(
                check=models.Q((
                    "weekday__in",
                    [
                        "MONDAY",
                        "TUESDAY",
                        "WEDNESDAY",
                        "THURSDAY",
                        "FRIDAY",
                        "SATURDAY",
                        "SUNDAY",
                    ],
                )),
                name="data_openinghours_weekday_valid",
            ),
        ),
        migrations.AlterUniqueTogether(
            name="openinghours",
            unique_together={("weekday", "location")},
        ),
        migrations.AddConstraint(
            model_name="baselocation",
            constraint=models.CheckConstraint(
                check=models.Q(("type__in", ["GASTRO", "SHOPPING"])),
                name="data_baselocation_type_valid",
            ),
        ),
    ]
Esempio n. 30
0
 class Meta:
     constraints = [models.CheckConstraint(check=models.Q(age__gte=18), name='is_adult')]