Skip to content

Commit

Permalink
rework Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
pvyParts committed Oct 12, 2024
1 parent 8a7c23e commit 3a8a967
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -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'),
),
]
18 changes: 14 additions & 4 deletions aadiscordbot/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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'
Expand All @@ -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

0 comments on commit 3a8a967

Please sign in to comment.