diff --git a/aadiscordbot/migrations/0016_authbotconfiguration_admin_user_ids_and_more.py b/aadiscordbot/migrations/0016_authbotconfiguration_admin_user_ids_and_more.py new file mode 100644 index 0000000..2b19bab --- /dev/null +++ b/aadiscordbot/migrations/0016_authbotconfiguration_admin_user_ids_and_more.py @@ -0,0 +1,24 @@ +# Generated by Django 4.2.16 on 2024-10-12 07:35 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('aadiscordbot', '0015_ticketgroups_ticket_channels'), + ] + + operations = [ + migrations.AddField( + model_name='authbotconfiguration', + name='admin_user_ids', + field=models.TextField(blank=True, default=None, null=True), + ), + migrations.AlterField( + model_name='ticketgroups', + name='ticket_channel', + field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to='aadiscordbot.channels'), + ), + ] diff --git a/aadiscordbot/models.py b/aadiscordbot/models.py index c69dc08..4943c2c 100644 --- a/aadiscordbot/models.py +++ b/aadiscordbot/models.py @@ -91,6 +91,17 @@ class AuthBotConfiguration(models.Model): admin_users = models.ManyToManyField(DiscordUser, blank=True) + admin_user_ids = models.TextField(default=None, null=True, blank=True) + + def get_non_model_admin_ids(self): + try: + ids = self.admin_user_ids.split(",") + return [ + int(id) for id in ids + ] + except Exception: + return [] + def __str__(self): return "AuthBot Configuration" @@ -155,13 +166,13 @@ class TicketGroups(SingletonModel): Group, blank=True, help_text="Pingable groups for ticketing") ticket_channel = models.ForeignKey( Channels, on_delete=models.SET_NULL, null=True, default=None, blank=True) - + ticket_channels = models.TextField( default=None, null=True, blank=True, help_text="JSON dictionary {server_id:channel_id}") - + class Meta: default_permissions = () verbose_name = 'Ticket Cog Configuration' @@ -175,9 +186,8 @@ def get_channel_for_server(self, server_id): channels = json.loads(self.ticket_channels) channel_id = channels.get(str(server_id), 0) return channel_id if channel_id else None - except json.JSONDecodeError as e: + except json.JSONDecodeError: if self.ticket_channel: return self.ticket_channel.channel else: return None -