From eb84f201ce714fe98a1d006ac0d85f6de7b8707c Mon Sep 17 00:00:00 2001 From: Kivou-2000607 Date: Sat, 14 Dec 2019 14:30:22 +0100 Subject: [PATCH] bot commun faction role --- bot/admin.py | 2 +- bot/functions.py | 8 ++++---- bot/migrations/0012_auto_20191214_1326.py | 23 +++++++++++++++++++++++ bot/models.py | 3 ++- 4 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 bot/migrations/0012_auto_20191214_1326.py diff --git a/bot/admin.py b/bot/admin.py index 3e4ba00df..1df205e65 100644 --- a/bot/admin.py +++ b/bot/admin.py @@ -13,7 +13,7 @@ class DiscordAppAdmin(admin.ModelAdmin): class GuildAdmin(admin.ModelAdmin): list_display = ['__str__'] - raw_id_fields = ("verifyKeys", "verifyFactions") + raw_id_fields = ("masterKeys", "verifyFactions") admin.site.register(Guild, GuildAdmin) diff --git a/bot/functions.py b/bot/functions.py index a9c3dccc6..f98b58a69 100644 --- a/bot/functions.py +++ b/bot/functions.py @@ -63,13 +63,13 @@ def saveBotsConfigs(): var[guild.guildId]["verify"] = {"active": True} if guild.verifyForce: var[guild.guildId]["verify"]["force"] = True - - # loop over yata users to get their keys + if guild.verifyFacsRole: + var[guild.guildId]["verify"]["commun"] = guild.verifyFacsRole var[guild.guildId]["factions"] = dict({f.tId: f.name for f in guild.verifyFactions.all()}) # loop over yata users to get their keys - if len(guild.verifyKeys.all()): - var[guild.guildId]["keys"] = dict({p.tId: p.key for p in guild.verifyKeys.all()}) + if len(guild.masterKeys.all()): + var[guild.guildId]["keys"] = dict({p.tId: p.key for p in guild.masterKeys.all()}) bot.variables = json.dumps(var) bot.save() diff --git a/bot/migrations/0012_auto_20191214_1326.py b/bot/migrations/0012_auto_20191214_1326.py new file mode 100644 index 000000000..7998a6f48 --- /dev/null +++ b/bot/migrations/0012_auto_20191214_1326.py @@ -0,0 +1,23 @@ +# Generated by Django 2.2.7 on 2019-12-14 13:26 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('bot', '0011_auto_20191212_0002'), + ] + + operations = [ + migrations.RenameField( + model_name='guild', + old_name='verifyKeys', + new_name='masterKeys', + ), + migrations.AddField( + model_name='guild', + name='verifyFacsRole', + field=models.CharField(blank=True, default='', max_length=16), + ), + ] diff --git a/bot/models.py b/bot/models.py index 306863b1f..6e41452cd 100644 --- a/bot/models.py +++ b/bot/models.py @@ -23,6 +23,7 @@ class Guild(models.Model): # general options manageChannels = models.BooleanField(default=False) + masterKeys = models.ManyToManyField(Player, blank=True) # stock module stockModule = models.BooleanField(default=False) @@ -40,8 +41,8 @@ class Guild(models.Model): # verify module verifyModule = models.BooleanField(default=False) verifyForce = models.BooleanField(default=False) - verifyKeys = models.ManyToManyField(Player, blank=True) verifyFactions = models.ManyToManyField(Faction, blank=True) + verifyFacsRole = models.CharField(default="", blank=True, max_length=16) # verify repository repoModule = models.BooleanField(default=False)