-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into mbaruh/channel-activity
- Loading branch information
Showing
9 changed files
with
435 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
pydis_site/apps/api/migrations/0068_split_nomination_tables.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Generated by Django 3.0.11 on 2021-02-21 15:32 | ||
|
||
from django.apps.registry import Apps | ||
from django.db import backends, migrations, models | ||
from django.db.backends.base.schema import BaseDatabaseSchemaEditor | ||
import django.db.models.deletion | ||
import pydis_site.apps.api.models.mixins | ||
|
||
|
||
def migrate_nominations(apps: Apps, schema_editor: BaseDatabaseSchemaEditor) -> None: | ||
Nomination = apps.get_model("api", "Nomination") | ||
NominationEntry = apps.get_model("api", "NominationEntry") | ||
|
||
for nomination in Nomination.objects.all(): | ||
nomination_entry = NominationEntry( | ||
nomination=nomination, | ||
actor=nomination.actor, | ||
reason=nomination.reason, | ||
inserted_at=nomination.inserted_at | ||
) | ||
nomination_entry.save() | ||
|
||
|
||
def unmigrate_nominations(apps: Apps, schema_editor: BaseDatabaseSchemaEditor) -> None: | ||
Nomination = apps.get_model("api", "Nomination") | ||
NominationEntry = apps.get_model("api", "NominationEntry") | ||
|
||
for entry in NominationEntry.objects.all(): | ||
nomination = Nomination.objects.get(pk=entry.nomination.id) | ||
nomination.actor = entry.actor | ||
nomination.reason = entry.reason | ||
nomination.inserted_at = entry.inserted_at | ||
|
||
nomination.save() | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('api', '0067_add_voice_ban_infraction_type'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='NominationEntry', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('reason', models.TextField(blank=True, help_text='Why the actor nominated this user.', default="")), | ||
('inserted_at', | ||
models.DateTimeField(auto_now_add=True, help_text='The creation date of this nomination entry.')), | ||
('actor', models.ForeignKey(help_text='The staff member that nominated this user.', | ||
on_delete=django.db.models.deletion.CASCADE, related_name='nomination_set', | ||
to='api.User')), | ||
('nomination', models.ForeignKey(help_text='The nomination this entry belongs to.', | ||
on_delete=django.db.models.deletion.CASCADE, to='api.Nomination', | ||
related_name='entries')), | ||
], | ||
bases=(pydis_site.apps.api.models.mixins.ModelReprMixin, models.Model), | ||
options={'ordering': ('-inserted_at',), 'verbose_name_plural': 'nomination entries'} | ||
), | ||
migrations.RunPython(migrate_nominations, unmigrate_nominations), | ||
migrations.RemoveField( | ||
model_name='nomination', | ||
name='actor', | ||
), | ||
migrations.RemoveField( | ||
model_name='nomination', | ||
name='reason', | ||
), | ||
migrations.AddField( | ||
model_name='nomination', | ||
name='reviewed', | ||
field=models.BooleanField(default=False, help_text='Whether a review was made.'), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.