Ejemplo n.º 1
0
class Migration(migrations.Migration):

    initial = True

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

    operations = [
        migrations.CreateModel(
            name='UserProfile',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('password',
                 models.CharField(max_length=128, verbose_name='password')),
                ('last_login',
                 models.DateTimeField(default=django.utils.timezone.now,
                                      verbose_name='last login')),
                ('is_superuser',
                 models.BooleanField(
                     default=False,
                     help_text=
                     'Designates that this user has all permissions without explicitly assigning them.',
                     verbose_name='superuser status')),
                ('email',
                 models.EmailField(db_index=True, max_length=75, unique=True)),
                ('is_staff', models.BooleanField(default=False)),
                ('is_active', models.BooleanField(default=True)),
                ('is_bot', models.BooleanField(default=False)),
                ('date_joined',
                 models.DateTimeField(default=django.utils.timezone.now)),
                ('is_mirror_dummy', models.BooleanField(default=False)),
                ('full_name', models.CharField(max_length=100)),
                ('short_name', models.CharField(max_length=100)),
                ('pointer', models.IntegerField()),
                ('last_pointer_updater', models.CharField(max_length=64)),
                ('api_key', models.CharField(max_length=32)),
                ('enable_stream_desktop_notifications',
                 models.BooleanField(default=True)),
                ('enable_stream_sounds', models.BooleanField(default=True)),
                ('enable_desktop_notifications',
                 models.BooleanField(default=True)),
                ('enable_sounds', models.BooleanField(default=True)),
                ('enable_offline_email_notifications',
                 models.BooleanField(default=True)),
                ('enable_offline_push_notifications',
                 models.BooleanField(default=True)),
                ('enable_digest_emails', models.BooleanField(default=True)),
                ('default_desktop_notifications',
                 models.BooleanField(default=True)),
                ('last_reminder',
                 models.DateTimeField(default=django.utils.timezone.now,
                                      null=True)),
                ('rate_limits', models.CharField(default='', max_length=100)),
                ('default_all_public_streams',
                 models.BooleanField(default=False)),
                ('enter_sends', models.NullBooleanField(default=True)),
                ('autoscroll_forever', models.BooleanField(default=False)),
                ('twenty_four_hour_time', models.BooleanField(default=False)),
                ('avatar_source',
                 models.CharField(choices=[('G', 'Hosted by Gravatar'),
                                           ('U', 'Uploaded by user'),
                                           ('S', 'System generated')],
                                  default='G',
                                  max_length=1)),
                ('tutorial_status',
                 models.CharField(choices=[('W', 'Waiting'), ('S', 'Started'),
                                           ('F', 'Finished')],
                                  default='W',
                                  max_length=1)),
                ('onboarding_steps', models.TextField(default='[]')),
                ('invites_granted', models.IntegerField(default=0)),
                ('invites_used', models.IntegerField(default=0)),
                ('alert_words', models.TextField(default='[]')),
                ('muted_topics', models.TextField(default='[]')),
                ('bot_owner',
                 models.ForeignKey(
                     null=True,
                     on_delete=django.db.models.deletion.SET_NULL,
                     to=settings.AUTH_USER_MODEL)),
            ],
            options={
                'abstract': False,
            },
        ),
        migrations.CreateModel(
            name='Client',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name',
                 models.CharField(db_index=True, max_length=30, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='DefaultStream',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
            ],
        ),
        migrations.CreateModel(
            name='Huddle',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('huddle_hash',
                 models.CharField(db_index=True, max_length=40, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name='Message',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('subject', models.CharField(db_index=True, max_length=60)),
                ('content', models.TextField()),
                ('rendered_content', models.TextField(null=True)),
                ('rendered_content_version', models.IntegerField(null=True)),
                ('pub_date',
                 models.DateTimeField(db_index=True,
                                      verbose_name='date published')),
                ('last_edit_time', models.DateTimeField(null=True)),
                ('edit_history', models.TextField(null=True)),
                ('has_attachment',
                 models.BooleanField(db_index=True, default=False)),
                ('has_image', models.BooleanField(db_index=True,
                                                  default=False)),
                ('has_link', models.BooleanField(db_index=True,
                                                 default=False)),
            ],
        ),
        migrations.CreateModel(
            name='PreregistrationUser',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('email', models.EmailField(max_length=75)),
                ('invited_at', models.DateTimeField(auto_now=True)),
                ('status', models.IntegerField(default=0)),
            ],
        ),
        migrations.CreateModel(
            name='PushDeviceToken',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('kind',
                 models.PositiveSmallIntegerField(
                     choices=[(1, 'apns'), (2, 'gcm')])),
                ('token', models.CharField(max_length=4096, unique=True)),
                ('last_updated',
                 models.DateTimeField(auto_now=True,
                                      default=django.utils.timezone.now)),
                ('ios_app_id', models.TextField(null=True)),
                ('user',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='Realm',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('domain',
                 models.CharField(db_index=True, max_length=40, unique=True)),
                ('name', models.CharField(max_length=40, null=True)),
                ('restricted_to_domain', models.BooleanField(default=True)),
                ('invite_required', models.BooleanField(default=False)),
                ('invite_by_admins_only', models.BooleanField(default=False)),
                ('mandatory_topics', models.BooleanField(default=False)),
                ('show_digest_email', models.BooleanField(default=True)),
                ('name_changes_disabled', models.BooleanField(default=False)),
                ('date_created',
                 models.DateTimeField(default=django.utils.timezone.now)),
                ('deactivated', models.BooleanField(default=False)),
            ],
            options={
                'permissions': (('administer', 'Administer a realm'), ),
            },
        ),
        migrations.CreateModel(
            name='RealmAlias',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('domain',
                 models.CharField(db_index=True, max_length=80, unique=True)),
                ('realm',
                 models.ForeignKey(null=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to='zerver.Realm')),
            ],
        ),
        migrations.CreateModel(
            name='RealmEmoji',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.TextField()),
                ('img_url', models.TextField()),
                ('realm',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='zerver.Realm')),
            ],
        ),
        migrations.CreateModel(
            name='RealmFilter',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('pattern', models.TextField()),
                ('url_format_string', models.TextField()),
                ('realm',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='zerver.Realm')),
            ],
        ),
        migrations.CreateModel(
            name='Recipient',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('type_id', models.IntegerField(db_index=True)),
                ('type', models.PositiveSmallIntegerField(db_index=True)),
            ],
        ),
        migrations.CreateModel(
            name='Referral',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('email', models.EmailField(max_length=75)),
                ('timestamp', models.DateTimeField(auto_now_add=True)),
                ('user_profile',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='ScheduledJob',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('scheduled_timestamp', models.DateTimeField()),
                ('type', models.PositiveSmallIntegerField()),
                ('data', models.TextField()),
                ('filter_id', models.IntegerField(null=True)),
                ('filter_string', models.CharField(max_length=100)),
            ],
        ),
        migrations.CreateModel(
            name='Stream',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(db_index=True, max_length=60)),
                ('invite_only', models.NullBooleanField(default=False)),
                ('email_token',
                 models.CharField(
                     default=zerver.models.generate_email_token_for_stream,
                     max_length=32)),
                ('description', models.CharField(default='', max_length=1024)),
                ('date_created',
                 models.DateTimeField(default=django.utils.timezone.now)),
                ('deactivated', models.BooleanField(default=False)),
                ('realm',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='zerver.Realm')),
            ],
        ),
        migrations.CreateModel(
            name='Subscription',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('active', models.BooleanField(default=True)),
                ('in_home_view', models.NullBooleanField(default=True)),
                ('color', models.CharField(default='#c2c2c2', max_length=10)),
                ('desktop_notifications', models.BooleanField(default=True)),
                ('audible_notifications', models.BooleanField(default=True)),
                ('notifications', models.BooleanField(default=False)),
                ('recipient',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='zerver.Recipient')),
                ('user_profile',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='UserActivity',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('query', models.CharField(db_index=True, max_length=50)),
                ('count', models.IntegerField()),
                ('last_visit',
                 models.DateTimeField(verbose_name='last visit')),
                ('client',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='zerver.Client')),
                ('user_profile',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='UserActivityInterval',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('start',
                 models.DateTimeField(db_index=True,
                                      verbose_name='start time')),
                ('end',
                 models.DateTimeField(db_index=True, verbose_name='end time')),
                ('user_profile',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='UserMessage',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('flags',
                 bitfield.models.BitField([
                     'read', 'starred', 'collapsed', 'mentioned',
                     'wildcard_mentioned', 'summarize_in_home',
                     'summarize_in_stream', 'force_expand', 'force_collapse',
                     'has_alert_word', 'historical', 'is_me_message'
                 ],
                                          default=0)),
                ('message',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='zerver.Message')),
                ('user_profile',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='UserPresence',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('timestamp',
                 models.DateTimeField(verbose_name='presence changed')),
                ('status', models.PositiveSmallIntegerField(default=1)),
                ('client',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to='zerver.Client')),
                ('user_profile',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.AlterUniqueTogether(
            name='userpresence',
            unique_together=set([('user_profile', 'client')]),
        ),
        migrations.AlterUniqueTogether(
            name='usermessage',
            unique_together=set([('user_profile', 'message')]),
        ),
        migrations.AlterUniqueTogether(
            name='useractivity',
            unique_together=set([('user_profile', 'client', 'query')]),
        ),
        migrations.AlterUniqueTogether(
            name='subscription',
            unique_together=set([('user_profile', 'recipient')]),
        ),
        migrations.AlterUniqueTogether(
            name='stream',
            unique_together=set([('name', 'realm')]),
        ),
        migrations.AlterUniqueTogether(
            name='recipient',
            unique_together=set([('type', 'type_id')]),
        ),
        migrations.AlterUniqueTogether(
            name='realmfilter',
            unique_together=set([('realm', 'pattern')]),
        ),
        migrations.AlterUniqueTogether(
            name='realmemoji',
            unique_together=set([('realm', 'name')]),
        ),
        migrations.AddField(
            model_name='realm',
            name='notifications_stream',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='+',
                to='zerver.Stream'),
        ),
        migrations.AddField(
            model_name='preregistrationuser',
            name='realm',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='zerver.Realm'),
        ),
        migrations.AddField(
            model_name='preregistrationuser',
            name='referred_by',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='preregistrationuser',
            name='streams',
            field=models.ManyToManyField(null=True, to='zerver.Stream'),
        ),
        migrations.AddField(
            model_name='message',
            name='recipient',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='zerver.Recipient'),
        ),
        migrations.AddField(
            model_name='message',
            name='sender',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name='message',
            name='sending_client',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='zerver.Client'),
        ),
        migrations.AddField(
            model_name='defaultstream',
            name='realm',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='zerver.Realm'),
        ),
        migrations.AddField(
            model_name='defaultstream',
            name='stream',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='zerver.Stream'),
        ),
        migrations.AlterUniqueTogether(
            name='defaultstream',
            unique_together=set([('realm', 'stream')]),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='default_events_register_stream',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='+',
                to='zerver.Stream'),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='default_sending_stream',
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name='+',
                to='zerver.Stream'),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='groups',
            field=models.ManyToManyField(
                blank=True,
                help_text=
                'The groups this user belongs to. A user will get all permissions granted to each of their groups.',
                related_name='user_set',
                related_query_name='user',
                to='auth.Group',
                verbose_name='groups'),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='realm',
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to='zerver.Realm'),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='user_permissions',
            field=models.ManyToManyField(
                blank=True,
                help_text='Specific permissions for this user.',
                related_name='user_set',
                related_query_name='user',
                to='auth.Permission',
                verbose_name='user permissions'),
        ),
        migrations.RunSQL(
            sql=
            '\nCREATE TEXT SEARCH DICTIONARY english_us_hunspell\n  (template = ispell, DictFile = en_us, AffFile = en_us, StopWords = zulip_english);\nCREATE TEXT SEARCH CONFIGURATION zulip.english_us_search (COPY=pg_catalog.english);\nALTER TEXT SEARCH CONFIGURATION zulip.english_us_search\n  ALTER MAPPING FOR asciiword, asciihword, hword_asciipart, word, hword, hword_part\n  WITH english_us_hunspell, english_stem;\n\nCREATE FUNCTION escape_html(text) RETURNS text IMMUTABLE LANGUAGE \'sql\' AS $$\n  SELECT replace(replace(replace(replace(replace($1, \'&\', \'&amp;\'), \'<\', \'&lt;\'),\n                                 \'>\', \'&gt;\'), \'"\', \'&quot;\'), \'\'\'\', \'&#39;\');\n$$ ;\n\nALTER TABLE zerver_message ADD COLUMN search_tsvector tsvector;\nCREATE INDEX zerver_message_search_tsvector ON zerver_message USING gin(search_tsvector);\nALTER INDEX zerver_message_search_tsvector SET (fastupdate = OFF);\n\nCREATE TABLE fts_update_log (id SERIAL PRIMARY KEY, message_id INTEGER NOT NULL);\nCREATE FUNCTION do_notify_fts_update_log() RETURNS trigger LANGUAGE plpgsql AS\n  $$ BEGIN NOTIFY fts_update_log; RETURN NEW; END $$;\nCREATE TRIGGER fts_update_log_notify AFTER INSERT ON fts_update_log\n  FOR EACH STATEMENT EXECUTE PROCEDURE do_notify_fts_update_log();\nCREATE FUNCTION append_to_fts_update_log() RETURNS trigger LANGUAGE plpgsql AS\n  $$ BEGIN INSERT INTO fts_update_log (message_id) VALUES (NEW.id); RETURN NEW; END $$;\nCREATE TRIGGER zerver_message_update_search_tsvector_async\n  BEFORE INSERT OR UPDATE OF subject, rendered_content ON zerver_message\n  FOR EACH ROW EXECUTE PROCEDURE append_to_fts_update_log();\n',
        ),
        migrations.AlterModelManagers(
            name='userprofile',
            managers=[
                ('objects', django.contrib.auth.models.UserManager()),
            ],
        ),
        migrations.AlterField(
            model_name='preregistrationuser',
            name='email',
            field=models.EmailField(max_length=254),
        ),
        migrations.AlterField(
            model_name='preregistrationuser',
            name='streams',
            field=models.ManyToManyField(to='zerver.Stream'),
        ),
        migrations.AlterField(
            model_name='pushdevicetoken',
            name='last_updated',
            field=models.DateTimeField(auto_now=True),
        ),
        migrations.AlterField(
            model_name='referral',
            name='email',
            field=models.EmailField(max_length=254),
        ),
        migrations.AlterField(
            model_name='userprofile',
            name='email',
            field=models.EmailField(db_index=True, max_length=254,
                                    unique=True),
        ),
        migrations.AlterField(
            model_name='userprofile',
            name='last_login',
            field=models.DateTimeField(blank=True,
                                       null=True,
                                       verbose_name='last login'),
        ),
        migrations.RunSQL(
            sql=
            'CREATE INDEX upper_subject_idx ON zerver_message ((upper(subject)));',
            reverse_sql='DROP INDEX upper_subject_idx;',
        ),
        migrations.RunSQL(
            sql=
            'CREATE INDEX upper_stream_name_idx ON zerver_stream ((upper(name)));',
            reverse_sql='DROP INDEX upper_stream_name_idx;',
        ),
        migrations.AddField(
            model_name='userprofile',
            name='left_side_userlist',
            field=models.BooleanField(default=False),
        ),
        migrations.AlterModelOptions(
            name='realm',
            options={
                'permissions':
                (('administer', 'Administer a realm'),
                 ('api_super_user',
                  'Can send messages as other users for mirroring'))
            },
        ),
        migrations.RunSQL(
            sql=
            'CREATE INDEX upper_userprofile_email_idx ON zerver_userprofile ((upper(email)));',
            reverse_sql='DROP INDEX upper_userprofile_email_idx;',
        ),
        migrations.AlterField(
            model_name='userprofile',
            name='is_active',
            field=models.BooleanField(db_index=True, default=True),
        ),
        migrations.AlterField(
            model_name='userprofile',
            name='is_bot',
            field=models.BooleanField(db_index=True, default=False),
        ),
        migrations.RunSQL(
            sql=
            'CREATE INDEX upper_preregistration_email_idx ON zerver_preregistrationuser ((upper(email)));',
            reverse_sql='DROP INDEX upper_preregistration_email_idx;',
        ),
        migrations.AlterField(
            model_name='userprofile',
            name='enable_stream_desktop_notifications',
            field=models.BooleanField(default=False),
        ),
        migrations.AlterField(
            model_name='userprofile',
            name='enable_stream_sounds',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='is_api_super_user',
            field=models.BooleanField(db_index=True, default=False),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='is_realm_admin',
            field=models.BooleanField(db_index=True, default=False),
        ),
        migrations.AlterField(
            model_name='realmemoji',
            name='img_url',
            field=models.URLField(),
        ),
        migrations.AlterField(
            model_name='realmemoji',
            name='name',
            field=models.TextField(validators=[
                django.core.validators.MinLengthValidator(1),
                django.core.validators.RegexValidator(
                    regex='^[0-9a-zA-Z.\\-_]+(?<![.\\-_])$')
            ]),
        ),
        migrations.AlterField(
            model_name='realmemoji',
            name='img_url',
            field=models.URLField(max_length=1000),
        ),
        migrations.CreateModel(
            name='Attachment',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('file_name', models.CharField(db_index=True, max_length=100)),
                ('path_id', models.TextField(db_index=True)),
                ('create_time',
                 models.DateTimeField(db_index=True,
                                      default=django.utils.timezone.now)),
                ('messages', models.ManyToManyField(to='zerver.Message')),
                ('owner',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL)),
                ('is_realm_public', models.BooleanField(default=False)),
            ],
        ),
        migrations.AddField(
            model_name='realm',
            name='create_stream_by_admins_only',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='bot_type',
            field=models.PositiveSmallIntegerField(db_index=True, null=True),
        ),
        migrations.AlterField(
            model_name='realmemoji',
            name='name',
            field=models.TextField(validators=[
                django.core.validators.MinLengthValidator(1),
                django.core.validators.RegexValidator(
                    message='Invalid characters in emoji name',
                    regex='^[0-9a-zA-Z.\\-_]+(?<![.\\-_])$')
            ]),
        ),
        migrations.AddField(
            model_name='preregistrationuser',
            name='realm_creation',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='attachment',
            name='realm',
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to='zerver.Realm'),
        ),
        migrations.RunPython(code=migrate_existing_attachment_data, ),
        migrations.AddField(
            model_name='subscription',
            name='pin_to_top',
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='default_language',
            field=models.CharField(default='en', max_length=50),
        ),
        migrations.AddField(
            model_name='realm',
            name='allow_message_editing',
            field=models.BooleanField(default=True),
        ),
        migrations.AddField(
            model_name='realm',
            name='message_content_edit_limit_seconds',
            field=models.IntegerField(default=600),
        ),
        migrations.AddField(
            model_name='realm',
            name='default_language',
            field=models.CharField(default='en', max_length=50),
        ),
        migrations.AddField(
            model_name='userprofile',
            name='tos_version',
            field=models.CharField(max_length=10, null=True),
        ),
    ]
Ejemplo n.º 2
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("auth", "0001_initial"),
    ]

    if settings.POSTGRESQL_MISSING_DICTIONARIES:
        fts_sql = """
CREATE TEXT SEARCH CONFIGURATION zulip.english_us_search (COPY=pg_catalog.english);
"""
    else:
        fts_sql = """
CREATE TEXT SEARCH DICTIONARY english_us_hunspell
  (template = ispell, DictFile = en_us, AffFile = en_us, StopWords = zulip_english);
CREATE TEXT SEARCH CONFIGURATION zulip.english_us_search (COPY=pg_catalog.english);
ALTER TEXT SEARCH CONFIGURATION zulip.english_us_search
  ALTER MAPPING FOR asciiword, asciihword, hword_asciipart, word, hword, hword_part
  WITH english_us_hunspell, english_stem;
"""

    fts_sql += """

CREATE FUNCTION escape_html(text) RETURNS text IMMUTABLE LANGUAGE 'sql' AS $$
  SELECT replace(replace(replace(replace(replace($1, '&', '&amp;'), '<', '&lt;'),
                                 '>', '&gt;'), '"', '&quot;'), '''', '&#39;');
$$ ;

ALTER TABLE zerver_message ADD COLUMN search_tsvector tsvector;
CREATE INDEX zerver_message_search_tsvector ON zerver_message USING gin(search_tsvector);
ALTER INDEX zerver_message_search_tsvector SET (fastupdate = OFF);

CREATE TABLE fts_update_log (id SERIAL PRIMARY KEY, message_id INTEGER NOT NULL);
CREATE FUNCTION do_notify_fts_update_log() RETURNS trigger LANGUAGE plpgsql AS
  $$ BEGIN NOTIFY fts_update_log; RETURN NEW; END $$;
CREATE TRIGGER fts_update_log_notify AFTER INSERT ON fts_update_log
  FOR EACH STATEMENT EXECUTE PROCEDURE do_notify_fts_update_log();
CREATE FUNCTION append_to_fts_update_log() RETURNS trigger LANGUAGE plpgsql AS
  $$ BEGIN INSERT INTO fts_update_log (message_id) VALUES (NEW.id); RETURN NEW; END $$;
CREATE TRIGGER zerver_message_update_search_tsvector_async
  BEFORE INSERT OR UPDATE OF subject, rendered_content ON zerver_message
  FOR EACH ROW EXECUTE PROCEDURE append_to_fts_update_log();
"""
    operations = [
        migrations.CreateModel(
            name="UserProfile",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("password",
                 models.CharField(max_length=128, verbose_name="password")),
                (
                    "last_login",
                    models.DateTimeField(default=django.utils.timezone.now,
                                         verbose_name="last login"),
                ),
                (
                    "is_superuser",
                    models.BooleanField(
                        default=False,
                        help_text=
                        "Designates that this user has all permissions without explicitly assigning them.",
                        verbose_name="superuser status",
                    ),
                ),
                ("email",
                 models.EmailField(db_index=True, max_length=75, unique=True)),
                ("is_staff", models.BooleanField(default=False)),
                ("is_active", models.BooleanField(default=True)),
                ("is_bot", models.BooleanField(default=False)),
                ("date_joined",
                 models.DateTimeField(default=django.utils.timezone.now)),
                ("is_mirror_dummy", models.BooleanField(default=False)),
                ("full_name", models.CharField(max_length=100)),
                ("short_name", models.CharField(max_length=100)),
                ("pointer", models.IntegerField()),
                ("last_pointer_updater", models.CharField(max_length=64)),
                ("api_key", models.CharField(max_length=32)),
                ("enable_stream_desktop_notifications",
                 models.BooleanField(default=True)),
                ("enable_stream_sounds", models.BooleanField(default=True)),
                ("enable_desktop_notifications",
                 models.BooleanField(default=True)),
                ("enable_sounds", models.BooleanField(default=True)),
                ("enable_offline_email_notifications",
                 models.BooleanField(default=True)),
                ("enable_offline_push_notifications",
                 models.BooleanField(default=True)),
                ("enable_digest_emails", models.BooleanField(default=True)),
                ("default_desktop_notifications",
                 models.BooleanField(default=True)),
                (
                    "last_reminder",
                    models.DateTimeField(default=django.utils.timezone.now,
                                         null=True),
                ),
                ("rate_limits", models.CharField(default="", max_length=100)),
                ("default_all_public_streams",
                 models.BooleanField(default=False)),
                ("enter_sends", models.NullBooleanField(default=True)),
                ("autoscroll_forever", models.BooleanField(default=False)),
                ("twenty_four_hour_time", models.BooleanField(default=False)),
                (
                    "avatar_source",
                    models.CharField(
                        choices=[
                            ("G", "Hosted by Gravatar"),
                            ("U", "Uploaded by user"),
                            ("S", "System generated"),
                        ],
                        default="G",
                        max_length=1,
                    ),
                ),
                (
                    "tutorial_status",
                    models.CharField(
                        choices=[("W", "Waiting"), ("S", "Started"),
                                 ("F", "Finished")],
                        default="W",
                        max_length=1,
                    ),
                ),
                ("onboarding_steps", models.TextField(default="[]")),
                ("invites_granted", models.IntegerField(default=0)),
                ("invites_used", models.IntegerField(default=0)),
                ("alert_words", models.TextField(default="[]")),
                ("muted_topics", models.TextField(default="[]")),
                (
                    "bot_owner",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.SET_NULL,
                        to=settings.AUTH_USER_MODEL,
                    ),
                ),
            ],
            options={
                "abstract": False,
            },
        ),
        migrations.CreateModel(
            name="Client",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("name",
                 models.CharField(db_index=True, max_length=30, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name="DefaultStream",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Huddle",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("huddle_hash",
                 models.CharField(db_index=True, max_length=40, unique=True)),
            ],
        ),
        migrations.CreateModel(
            name="Message",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("subject", models.CharField(db_index=True, max_length=60)),
                ("content", models.TextField()),
                ("rendered_content", models.TextField(null=True)),
                ("rendered_content_version", models.IntegerField(null=True)),
                ("pub_date",
                 models.DateTimeField(db_index=True,
                                      verbose_name="date published")),
                ("last_edit_time", models.DateTimeField(null=True)),
                ("edit_history", models.TextField(null=True)),
                ("has_attachment",
                 models.BooleanField(db_index=True, default=False)),
                ("has_image", models.BooleanField(db_index=True,
                                                  default=False)),
                ("has_link", models.BooleanField(db_index=True,
                                                 default=False)),
            ],
        ),
        migrations.CreateModel(
            name="PreregistrationUser",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("email", models.EmailField(max_length=75)),
                ("invited_at", models.DateTimeField(auto_now=True)),
                ("status", models.IntegerField(default=0)),
            ],
        ),
        migrations.CreateModel(
            name="PushDeviceToken",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("kind",
                 models.PositiveSmallIntegerField(
                     choices=[(1, "apns"), (2, "gcm")])),
                ("token", models.CharField(max_length=4096, unique=True)),
                (
                    "last_updated",
                    models.DateTimeField(auto_now=True,
                                         default=django.utils.timezone.now),
                ),
                ("ios_app_id", models.TextField(null=True)),
                (
                    "user",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Realm",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("domain",
                 models.CharField(db_index=True, max_length=40, unique=True)),
                ("name", models.CharField(max_length=40, null=True)),
                ("restricted_to_domain", models.BooleanField(default=True)),
                ("invite_required", models.BooleanField(default=False)),
                ("invite_by_admins_only", models.BooleanField(default=False)),
                ("mandatory_topics", models.BooleanField(default=False)),
                ("show_digest_email", models.BooleanField(default=True)),
                ("name_changes_disabled", models.BooleanField(default=False)),
                ("date_created",
                 models.DateTimeField(default=django.utils.timezone.now)),
                ("deactivated", models.BooleanField(default=False)),
            ],
            options={
                "permissions": (("administer", "Administer a realm"), ),
            },
        ),
        migrations.CreateModel(
            name="RealmAlias",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("domain",
                 models.CharField(db_index=True, max_length=80, unique=True)),
                (
                    "realm",
                    models.ForeignKey(
                        null=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        to="zerver.Realm"),
                ),
            ],
        ),
        migrations.CreateModel(
            name="RealmEmoji",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("name", models.TextField()),
                ("img_url", models.TextField()),
                (
                    "realm",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="zerver.Realm"),
                ),
            ],
        ),
        migrations.CreateModel(
            name="RealmFilter",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("pattern", models.TextField()),
                ("url_format_string", models.TextField()),
                (
                    "realm",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="zerver.Realm"),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Recipient",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("type_id", models.IntegerField(db_index=True)),
                ("type", models.PositiveSmallIntegerField(db_index=True)),
            ],
        ),
        migrations.CreateModel(
            name="Referral",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("email", models.EmailField(max_length=75)),
                ("timestamp", models.DateTimeField(auto_now_add=True)),
                (
                    "user_profile",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL),
                ),
            ],
        ),
        migrations.CreateModel(
            name="ScheduledJob",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("scheduled_timestamp", models.DateTimeField()),
                ("type", models.PositiveSmallIntegerField()),
                ("data", models.TextField()),
                ("filter_id", models.IntegerField(null=True)),
                ("filter_string", models.CharField(max_length=100)),
            ],
        ),
        migrations.CreateModel(
            name="Stream",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("name", models.CharField(db_index=True, max_length=60)),
                ("invite_only", models.NullBooleanField(default=False)),
                (
                    "email_token",
                    models.CharField(default=generate_email_token_for_stream,
                                     max_length=32),
                ),
                ("description", models.CharField(default="", max_length=1024)),
                ("date_created",
                 models.DateTimeField(default=django.utils.timezone.now)),
                ("deactivated", models.BooleanField(default=False)),
                (
                    "realm",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="zerver.Realm"),
                ),
            ],
        ),
        migrations.CreateModel(
            name="Subscription",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("active", models.BooleanField(default=True)),
                ("in_home_view", models.NullBooleanField(default=True)),
                ("color", models.CharField(default="#c2c2c2", max_length=10)),
                ("desktop_notifications", models.BooleanField(default=True)),
                ("audible_notifications", models.BooleanField(default=True)),
                ("notifications", models.BooleanField(default=False)),
                (
                    "recipient",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="zerver.Recipient"),
                ),
                (
                    "user_profile",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL),
                ),
            ],
        ),
        migrations.CreateModel(
            name="UserActivity",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("query", models.CharField(db_index=True, max_length=50)),
                ("count", models.IntegerField()),
                ("last_visit",
                 models.DateTimeField(verbose_name="last visit")),
                (
                    "client",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="zerver.Client"),
                ),
                (
                    "user_profile",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL),
                ),
            ],
        ),
        migrations.CreateModel(
            name="UserActivityInterval",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("start",
                 models.DateTimeField(db_index=True,
                                      verbose_name="start time")),
                ("end",
                 models.DateTimeField(db_index=True, verbose_name="end time")),
                (
                    "user_profile",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL),
                ),
            ],
        ),
        migrations.CreateModel(
            name="UserMessage",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                (
                    "flags",
                    bitfield.models.BitField(
                        [
                            "read",
                            "starred",
                            "collapsed",
                            "mentioned",
                            "wildcard_mentioned",
                            "summarize_in_home",
                            "summarize_in_stream",
                            "force_expand",
                            "force_collapse",
                            "has_alert_word",
                            "historical",
                            "is_me_message",
                        ],
                        default=0,
                    ),
                ),
                (
                    "message",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="zerver.Message"),
                ),
                (
                    "user_profile",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL),
                ),
            ],
        ),
        migrations.CreateModel(
            name="UserPresence",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("timestamp",
                 models.DateTimeField(verbose_name="presence changed")),
                ("status", models.PositiveSmallIntegerField(default=1)),
                (
                    "client",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="zerver.Client"),
                ),
                (
                    "user_profile",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL),
                ),
            ],
        ),
        migrations.AlterUniqueTogether(
            name="userpresence",
            unique_together={("user_profile", "client")},
        ),
        migrations.AlterUniqueTogether(
            name="usermessage",
            unique_together={("user_profile", "message")},
        ),
        migrations.AlterUniqueTogether(
            name="useractivity",
            unique_together={("user_profile", "client", "query")},
        ),
        migrations.AlterUniqueTogether(
            name="subscription",
            unique_together={("user_profile", "recipient")},
        ),
        migrations.AlterUniqueTogether(
            name="stream",
            unique_together={("name", "realm")},
        ),
        migrations.AlterUniqueTogether(
            name="recipient",
            unique_together={("type", "type_id")},
        ),
        migrations.AlterUniqueTogether(
            name="realmfilter",
            unique_together={("realm", "pattern")},
        ),
        migrations.AlterUniqueTogether(
            name="realmemoji",
            unique_together={("realm", "name")},
        ),
        migrations.AddField(
            model_name="realm",
            name="notifications_stream",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="+",
                to="zerver.Stream",
            ),
        ),
        migrations.AddField(
            model_name="preregistrationuser",
            name="realm",
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to="zerver.Realm"),
        ),
        migrations.AddField(
            model_name="preregistrationuser",
            name="referred_by",
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name="preregistrationuser",
            name="streams",
            field=models.ManyToManyField(null=True, to="zerver.Stream"),
        ),
        migrations.AddField(
            model_name="message",
            name="recipient",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to="zerver.Recipient"),
        ),
        migrations.AddField(
            model_name="message",
            name="sender",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to=settings.AUTH_USER_MODEL),
        ),
        migrations.AddField(
            model_name="message",
            name="sending_client",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to="zerver.Client"),
        ),
        migrations.AddField(
            model_name="defaultstream",
            name="realm",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to="zerver.Realm"),
        ),
        migrations.AddField(
            model_name="defaultstream",
            name="stream",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to="zerver.Stream"),
        ),
        migrations.AlterUniqueTogether(
            name="defaultstream",
            unique_together={("realm", "stream")},
        ),
        migrations.AddField(
            model_name="userprofile",
            name="default_events_register_stream",
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="+",
                to="zerver.Stream",
            ),
        ),
        migrations.AddField(
            model_name="userprofile",
            name="default_sending_stream",
            field=models.ForeignKey(
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                related_name="+",
                to="zerver.Stream",
            ),
        ),
        migrations.AddField(
            model_name="userprofile",
            name="groups",
            field=models.ManyToManyField(
                blank=True,
                help_text=
                "The groups this user belongs to. A user will get all permissions granted to each of their groups.",
                related_name="user_set",
                related_query_name="user",
                to="auth.Group",
                verbose_name="groups",
            ),
        ),
        migrations.AddField(
            model_name="userprofile",
            name="realm",
            field=models.ForeignKey(
                on_delete=django.db.models.deletion.CASCADE,
                to="zerver.Realm"),
        ),
        migrations.AddField(
            model_name="userprofile",
            name="user_permissions",
            field=models.ManyToManyField(
                blank=True,
                help_text="Specific permissions for this user.",
                related_name="user_set",
                related_query_name="user",
                to="auth.Permission",
                verbose_name="user permissions",
            ),
        ),
        migrations.RunSQL(sql=fts_sql, ),
        migrations.AlterModelManagers(
            name="userprofile",
            managers=[
                ("objects", django.contrib.auth.models.UserManager()),
            ],
        ),
        migrations.AlterField(
            model_name="preregistrationuser",
            name="email",
            field=models.EmailField(max_length=254),
        ),
        migrations.AlterField(
            model_name="preregistrationuser",
            name="streams",
            field=models.ManyToManyField(to="zerver.Stream"),
        ),
        migrations.AlterField(
            model_name="pushdevicetoken",
            name="last_updated",
            field=models.DateTimeField(auto_now=True),
        ),
        migrations.AlterField(
            model_name="referral",
            name="email",
            field=models.EmailField(max_length=254),
        ),
        migrations.AlterField(
            model_name="userprofile",
            name="email",
            field=models.EmailField(db_index=True, max_length=254,
                                    unique=True),
        ),
        migrations.AlterField(
            model_name="userprofile",
            name="last_login",
            field=models.DateTimeField(blank=True,
                                       null=True,
                                       verbose_name="last login"),
        ),
        migrations.RunSQL(
            sql=
            "CREATE INDEX upper_subject_idx ON zerver_message ((upper(subject)));",
            reverse_sql="DROP INDEX upper_subject_idx;",
        ),
        migrations.RunSQL(
            sql=
            "CREATE INDEX upper_stream_name_idx ON zerver_stream ((upper(name)));",
            reverse_sql="DROP INDEX upper_stream_name_idx;",
        ),
        migrations.AddField(
            model_name="userprofile",
            name="left_side_userlist",
            field=models.BooleanField(default=False),
        ),
        migrations.AlterModelOptions(
            name="realm",
            options={
                "permissions": (
                    ("administer", "Administer a realm"),
                    ("api_super_user",
                     "Can send messages as other users for mirroring"),
                )
            },
        ),
        migrations.RunSQL(
            sql=
            "CREATE INDEX upper_userprofile_email_idx ON zerver_userprofile ((upper(email)));",
            reverse_sql="DROP INDEX upper_userprofile_email_idx;",
        ),
        migrations.AlterField(
            model_name="userprofile",
            name="is_active",
            field=models.BooleanField(db_index=True, default=True),
        ),
        migrations.AlterField(
            model_name="userprofile",
            name="is_bot",
            field=models.BooleanField(db_index=True, default=False),
        ),
        migrations.RunSQL(
            sql=
            "CREATE INDEX upper_preregistration_email_idx ON zerver_preregistrationuser ((upper(email)));",
            reverse_sql="DROP INDEX upper_preregistration_email_idx;",
        ),
        migrations.AlterField(
            model_name="userprofile",
            name="enable_stream_desktop_notifications",
            field=models.BooleanField(default=False),
        ),
        migrations.AlterField(
            model_name="userprofile",
            name="enable_stream_sounds",
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name="userprofile",
            name="is_api_super_user",
            field=models.BooleanField(db_index=True, default=False),
        ),
        migrations.AddField(
            model_name="userprofile",
            name="is_realm_admin",
            field=models.BooleanField(db_index=True, default=False),
        ),
        migrations.AlterField(
            model_name="realmemoji",
            name="img_url",
            field=models.URLField(),
        ),
        migrations.AlterField(
            model_name="realmemoji",
            name="name",
            field=models.TextField(validators=[
                django.core.validators.MinLengthValidator(1),
                django.core.validators.RegexValidator(
                    regex="^[0-9a-zA-Z.\\-_]+(?<![.\\-_])$"),
            ]),
        ),
        migrations.AlterField(
            model_name="realmemoji",
            name="img_url",
            field=models.URLField(max_length=1000),
        ),
        migrations.CreateModel(
            name="Attachment",
            fields=[
                (
                    "id",
                    models.AutoField(auto_created=True,
                                     primary_key=True,
                                     serialize=False,
                                     verbose_name="ID"),
                ),
                ("file_name", models.CharField(db_index=True, max_length=100)),
                ("path_id", models.TextField(db_index=True)),
                (
                    "create_time",
                    models.DateTimeField(db_index=True,
                                         default=django.utils.timezone.now),
                ),
                ("messages", models.ManyToManyField(to="zerver.Message")),
                (
                    "owner",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to=settings.AUTH_USER_MODEL),
                ),
                ("is_realm_public", models.BooleanField(default=False)),
            ],
        ),
        migrations.AddField(
            model_name="realm",
            name="create_stream_by_admins_only",
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name="userprofile",
            name="bot_type",
            field=models.PositiveSmallIntegerField(db_index=True, null=True),
        ),
        migrations.AlterField(
            model_name="realmemoji",
            name="name",
            field=models.TextField(validators=[
                django.core.validators.MinLengthValidator(1),
                django.core.validators.RegexValidator(
                    message="Invalid characters in emoji name",
                    regex="^[0-9a-zA-Z.\\-_]+(?<![.\\-_])$",
                ),
            ]),
        ),
        migrations.AddField(
            model_name="preregistrationuser",
            name="realm_creation",
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name="attachment",
            name="realm",
            field=models.ForeignKey(
                blank=True,
                null=True,
                on_delete=django.db.models.deletion.CASCADE,
                to="zerver.Realm",
            ),
        ),
        migrations.RunPython(
            code=migrate_existing_attachment_data,
            elidable=True,
        ),
        migrations.AddField(
            model_name="subscription",
            name="pin_to_top",
            field=models.BooleanField(default=False),
        ),
        migrations.AddField(
            model_name="userprofile",
            name="default_language",
            field=models.CharField(default="en", max_length=50),
        ),
        migrations.AddField(
            model_name="realm",
            name="allow_message_editing",
            field=models.BooleanField(default=True),
        ),
        migrations.AddField(
            model_name="realm",
            name="message_content_edit_limit_seconds",
            field=models.IntegerField(default=600),
        ),
        migrations.AddField(
            model_name="realm",
            name="default_language",
            field=models.CharField(default="en", max_length=50),
        ),
        migrations.AddField(
            model_name="userprofile",
            name="tos_version",
            field=models.CharField(max_length=10, null=True),
        ),
    ]
Ejemplo n.º 3
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ('auth', '0009_alter_user_last_name_max_length'),
    ]

    operations = [
        migrations.CreateModel(
            name='User',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('password',
                 models.CharField(max_length=128, verbose_name='password')),
                ('last_login',
                 models.DateTimeField(blank=True,
                                      null=True,
                                      verbose_name='last login')),
                ('is_superuser',
                 models.BooleanField(
                     default=False,
                     help_text=
                     'Designates that this user has all permissions without explicitly assigning them.',
                     verbose_name='superuser status')),
                ('username',
                 models.CharField(
                     error_messages={
                         'unique': 'A user with that username already exists.'
                     },
                     help_text=
                     'Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.',
                     max_length=150,
                     unique=True,
                     validators=[
                         django.contrib.auth.validators.
                         UnicodeUsernameValidator()
                     ],
                     verbose_name='username')),
                ('first_name',
                 models.CharField(blank=True,
                                  max_length=30,
                                  verbose_name='first name')),
                ('last_name',
                 models.CharField(blank=True,
                                  max_length=150,
                                  verbose_name='last name')),
                ('email',
                 models.EmailField(blank=True,
                                   max_length=254,
                                   verbose_name='email address')),
                ('is_staff',
                 models.BooleanField(
                     default=False,
                     help_text=
                     'Designates whether the user can log into this admin site.',
                     verbose_name='staff status')),
                ('is_active',
                 models.BooleanField(
                     default=True,
                     help_text=
                     'Designates whether this user should be treated as active. Unselect this instead of deleting accounts.',
                     verbose_name='active')),
                ('date_joined',
                 models.DateTimeField(default=django.utils.timezone.now,
                                      verbose_name='date joined')),
                ('account_number',
                 models.CharField(max_length=64,
                                  verbose_name='Account Number')),
                ('phone_number',
                 models.CharField(blank=True,
                                  max_length=32,
                                  verbose_name='Phone Number')),
                ('automatic_user',
                 models.BooleanField(default=False,
                                     verbose_name='Automatically Created')),
                ('notification_preference',
                 models.CharField(choices=[('S', 'sms'), ('E', 'email')],
                                  default='S',
                                  max_length=1,
                                  verbose_name='Notification Preference')),
                ('groups',
                 models.ManyToManyField(
                     blank=True,
                     help_text=
                     'The groups this user belongs to. A user will get all permissions granted to each of their groups.',
                     related_name='user_set',
                     related_query_name='user',
                     to='auth.Group',
                     verbose_name='groups')),
                ('user_permissions',
                 models.ManyToManyField(
                     blank=True,
                     help_text='Specific permissions for this user.',
                     related_name='user_set',
                     related_query_name='user',
                     to='auth.Permission',
                     verbose_name='user permissions')),
            ],
            managers=[
                ('objects', django.contrib.auth.models.UserManager()),
            ],
        ),
        migrations.CreateModel(
            name='Clerk',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('salary',
                 models.PositiveIntegerField(default=0,
                                             verbose_name='Salary')),
                ('is_employee',
                 models.BooleanField(default=True,
                                     verbose_name='is Employee')),
                ('user',
                 models.OneToOneField(
                     on_delete=django.db.models.deletion.CASCADE,
                     to=settings.AUTH_USER_MODEL,
                     verbose_name='User')),
            ],
        ),
        migrations.CreateModel(
            name='Company',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('user',
                 models.OneToOneField(
                     on_delete=django.db.models.deletion.CASCADE,
                     to=settings.AUTH_USER_MODEL)),
            ],
        ),
        migrations.CreateModel(
            name='PaymentGroup',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=255,
                                          verbose_name='Name')),
            ],
        ),
        migrations.CreateModel(
            name='PaymentType',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('name', models.CharField(max_length=255,
                                          verbose_name='Name')),
                ('description',
                 models.TextField(blank=True, verbose_name='Description')),
                ('min_amount',
                 dollarial.fields.PriceField(default=1,
                                             null=True,
                                             verbose_name='Minimum Amount')),
                ('max_amount',
                 dollarial.fields.PriceField(default=1000000,
                                             null=True,
                                             verbose_name='Maximum Amount')),
                ('price',
                 dollarial.fields.PriceField(default=0,
                                             null=True,
                                             verbose_name='Fixed Price')),
                ('wage_percentage',
                 models.PositiveSmallIntegerField(
                     default=9,
                     validators=[
                         django.core.validators.MaxValueValidator(100)
                     ],
                     verbose_name='Wage Percentage')),
                ('currency',
                 dollarial.fields.CurrencyField(choices=[('D', '$'),
                                                         ('R', '﷼'),
                                                         ('E', '€')],
                                                default='R',
                                                max_length=1,
                                                verbose_name='Currency')),
                ('fixed_price',
                 models.BooleanField(default=True,
                                     verbose_name='Fixed Price')),
                ('is_active',
                 models.BooleanField(default=True, verbose_name='Active')),
                ('required_fields',
                 bitfield.models.BitField(('general_info', 'personal_info',
                                           'exam_info', 'university_info'),
                                          default=None)),
                ('transaction_group',
                 models.ForeignKey(blank=True,
                                   null=True,
                                   on_delete=django.db.models.deletion.CASCADE,
                                   to='dollarial.PaymentGroup',
                                   verbose_name='Group')),
            ],
        ),
        migrations.CreateModel(
            name='Wallet',
            fields=[
                ('id',
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name='ID')),
                ('credit',
                 dollarial.fields.PriceField(default=0,
                                             verbose_name='Credit')),
                ('currency',
                 dollarial.fields.CurrencyField(choices=[('D', '$'),
                                                         ('R', '﷼'),
                                                         ('E', '€')],
                                                default='R',
                                                max_length=1,
                                                verbose_name='Currency')),
                ('user',
                 models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
                                   to=settings.AUTH_USER_MODEL,
                                   verbose_name='User')),
            ],
        ),
        migrations.AlterUniqueTogether(
            name='wallet',
            unique_together={('user', 'currency')},
        ),
        migrations.AlterUniqueTogether(
            name='user',
            unique_together={('automatic_user', 'account_number')},
        ),
    ]
Ejemplo n.º 4
0
class Migration(migrations.Migration):

    initial = True

    dependencies = [
        ("auth", "0011_update_proxy_permissions"),
        ("groupapp", "0001_initial"),
    ]

    operations = [
        migrations.CreateModel(
            name="BaseAccount",
            fields=[
                ("id",
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name="ID")),
                ("password",
                 models.CharField(max_length=128, verbose_name="password")),
                ("last_login",
                 models.DateTimeField(blank=True,
                                      null=True,
                                      verbose_name="last login")),
                (
                    "is_superuser",
                    models.BooleanField(
                        default=False,
                        help_text=
                        "Designates that this user has all permissions without explicitly assigning them.",
                        verbose_name="superuser status",
                    ),
                ),
                (
                    "username",
                    models.CharField(
                        max_length=127,
                        unique=True,
                        validators=[
                            django.core.validators.RegexValidator(
                                "^\\w{1,127}$")
                        ],
                        verbose_name="profile username",
                    ),
                ),
                ("fio", models.CharField(max_length=256, verbose_name="fio")),
                ("birth_day",
                 models.DateField(auto_now_add=True,
                                  verbose_name="birth day")),
                ("is_active",
                 models.BooleanField(default=True, verbose_name="Is active")),
                ("is_admin", models.BooleanField(default=False)),
                (
                    "telephone",
                    models.CharField(
                        blank=True,
                        null=True,
                        default=None,
                        max_length=16,
                        validators=[
                            django.core.validators.RegexValidator(
                                "^(\\+[7893]\\d{10,11})?$")
                        ],
                        verbose_name="Telephone",
                    ),
                ),
                (
                    "groups",
                    models.ManyToManyField(
                        blank=True,
                        help_text=
                        ("The groups this user belongs to. A user will get all permissions "
                         "granted to each of their groups."),
                        related_name="user_set",
                        related_query_name="user",
                        to="auth.Group",
                        verbose_name="groups",
                    ),
                ),
                (
                    "user_permissions",
                    models.ManyToManyField(
                        blank=True,
                        help_text="Specific permissions for this user.",
                        related_name="user_set",
                        related_query_name="user",
                        to="auth.Permission",
                        verbose_name="user permissions",
                    ),
                ),
            ],
            options={
                "db_table": "base_accounts",
                "ordering": ("username", ),
            },
        ),
        migrations.CreateModel(
            name="UserProfile",
            fields=[
                (
                    "baseaccount_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="profiles.BaseAccount",
                    ),
                ),
                (
                    "avatar",
                    models.ImageField(blank=True,
                                      default=None,
                                      null=True,
                                      upload_to="user/avatar",
                                      verbose_name="Avatar"),
                ),
                ("email",
                 models.EmailField(blank=True, default="", max_length=254)),
                (
                    "flags",
                    bitfield.models.BitField(
                        (
                            ("notify_task", "Notification about tasks"),
                            ("notify_msg", "Notification about messages"),
                            ("notify_mon", "Notification from monitoring"),
                        ),
                        default=0,
                        verbose_name="Settings flags",
                    ),
                ),
                (
                    "responsibility_groups",
                    models.ManyToManyField(
                        blank=True,
                        to="groupapp.Group",
                        verbose_name="Responsibility groups"),
                ),
            ],
            options={
                "verbose_name": "Staff account profile",
                "verbose_name_plural": "Staff account profiles",
                "ordering": ("fio", ),
            },
            bases=("profiles.baseaccount", ),
        ),
        migrations.CreateModel(
            name="UserProfileLog",
            fields=[
                ("id",
                 models.AutoField(auto_created=True,
                                  primary_key=True,
                                  serialize=False,
                                  verbose_name="ID")),
                (
                    "do_type",
                    models.PositiveSmallIntegerField(
                        choices=[
                            (0, "Undefined"),
                            (1, "Create user"),
                            (2, "Delete user"),
                            (3, "Create device"),
                            (4, "Delete device"),
                            (5, "Create NAS"),
                            (6, "Delete NAS"),
                            (7, "Create service"),
                            (8, "Delete service"),
                        ],
                        default=0,
                        verbose_name="Action type",
                    ),
                ),
                (
                    "additional_text",
                    models.CharField(blank=True,
                                     max_length=512,
                                     null=True,
                                     verbose_name="Additional info"),
                ),
                ("action_date",
                 models.DateTimeField(auto_now_add=True,
                                      verbose_name="Action date")),
                (
                    "account",
                    models.ForeignKey(
                        on_delete=django.db.models.deletion.CASCADE,
                        to="profiles.UserProfile",
                        verbose_name="Author"),
                ),
            ],
            options={
                "verbose_name": "User profile log",
                "verbose_name_plural": "User profile logs",
                "ordering": ("-action_date", ),
            },
        ),
    ]