diff --git a/apps/home/admin.py b/apps/home/admin.py index 2558c40..344c54b 100644 --- a/apps/home/admin.py +++ b/apps/home/admin.py @@ -62,7 +62,9 @@ class MessageStyleAdmin(admin.ModelAdmin): class DiscordChannelAdmin(admin.ModelAdmin): list_display = [ "id", - "channel_id" + "server", + "name", + "is_nsfw" ] diff --git a/apps/home/migrations/0007_discordchannel_server.py b/apps/home/migrations/0007_discordchannel_server.py new file mode 100644 index 0000000..9a3b265 --- /dev/null +++ b/apps/home/migrations/0007_discordchannel_server.py @@ -0,0 +1,20 @@ +# Generated by Django 5.0.4 on 2024-10-02 20:01 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0006_remove_discordchannel_name_messagestyle_auto_created'), + ] + + operations = [ + migrations.AddField( + model_name='discordchannel', + name='server', + field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='home.server'), + preserve_default=False, + ), + ] diff --git a/apps/home/migrations/0008_discordchannel_name.py b/apps/home/migrations/0008_discordchannel_name.py new file mode 100644 index 0000000..9059fa8 --- /dev/null +++ b/apps/home/migrations/0008_discordchannel_name.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.4 on 2024-10-02 20:53 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0007_discordchannel_server'), + ] + + operations = [ + migrations.AddField( + model_name='discordchannel', + name='name', + field=models.CharField(default='placeholder name', max_length=128), + preserve_default=False, + ), + ] diff --git a/apps/home/migrations/0009_remove_discordchannel_channel_id_and_more.py b/apps/home/migrations/0009_remove_discordchannel_channel_id_and_more.py new file mode 100644 index 0000000..7e047e7 --- /dev/null +++ b/apps/home/migrations/0009_remove_discordchannel_channel_id_and_more.py @@ -0,0 +1,32 @@ +# Generated by Django 5.0.4 on 2024-10-02 21:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0008_discordchannel_name'), + ] + + operations = [ + migrations.RemoveField( + model_name='discordchannel', + name='channel_id', + ), + migrations.RemoveField( + model_name='discordchannel', + name='name', + ), + migrations.AddField( + model_name='discordchannel', + name='is_nsfw', + field=models.BooleanField(default=False), + preserve_default=False, + ), + migrations.AlterField( + model_name='discordchannel', + name='id', + field=models.PositiveIntegerField(primary_key=True, serialize=False), + ), + ] diff --git a/apps/home/migrations/0010_discordchannel_name.py b/apps/home/migrations/0010_discordchannel_name.py new file mode 100644 index 0000000..833119a --- /dev/null +++ b/apps/home/migrations/0010_discordchannel_name.py @@ -0,0 +1,19 @@ +# Generated by Django 5.0.4 on 2024-10-02 21:05 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0009_remove_discordchannel_channel_id_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='discordchannel', + name='name', + field=models.CharField(default='placeholder', max_length=128), + preserve_default=False, + ), + ] diff --git a/apps/home/models.py b/apps/home/models.py index c76b930..df1cf21 100644 --- a/apps/home/models.py +++ b/apps/home/models.py @@ -203,11 +203,13 @@ class DiscordChannel(models.Model): is handled internally, when Subscriptions are modified. """ - id = models.AutoField(primary_key=True) - channel_id = models.BigIntegerField() + id = models.PositiveIntegerField(primary_key=True) + server = models.ForeignKey(to=Server, on_delete=models.CASCADE, blank=False) + name = models.CharField(max_length=128) + is_nsfw = models.BooleanField() def __str__(self): - return str(self.channel_id) + return f"#{self.name}" # region Subscription