update discordchannel model

This commit is contained in:
Corban-Lee Jones 2024-10-02 23:32:30 +01:00
parent da8ed90686
commit 6127233c0f
6 changed files with 98 additions and 4 deletions

View File

@ -62,7 +62,9 @@ class MessageStyleAdmin(admin.ModelAdmin):
class DiscordChannelAdmin(admin.ModelAdmin):
list_display = [
"id",
"channel_id"
"server",
"name",
"is_nsfw"
]

View File

@ -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,
),
]

View File

@ -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,
),
]

View File

@ -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),
),
]

View File

@ -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,
),
]

View File

@ -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