channel name to subchannels
This commit is contained in:
parent
eae1a682fa
commit
5623e06a0b
19
apps/home/migrations/0018_subchannel_channel_name.py
Normal file
19
apps/home/migrations/0018_subchannel_channel_name.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.0.4 on 2024-07-20 18:14
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0017_trackedcontent_message_id'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='subchannel',
|
||||
name='channel_name',
|
||||
field=models.CharField(default='placeholder-channel-name', help_text='Name of the represented Channel.', max_length=256, verbose_name='channel name'),
|
||||
preserve_default=False,
|
||||
),
|
||||
]
|
@ -94,6 +94,12 @@ class SubChannel(models.Model):
|
||||
help_text=_("Discord snowflake ID for the represented Channel.")
|
||||
)
|
||||
|
||||
channel_name = models.CharField(
|
||||
verbose_name=_("channel name"),
|
||||
max_length=256,
|
||||
help_text=_("Name of the represented Channel.")
|
||||
)
|
||||
|
||||
subscription = models.ForeignKey(
|
||||
to="home.Subscription",
|
||||
on_delete=models.CASCADE,
|
||||
|
@ -249,7 +249,7 @@ $("#subForm").on("submit", async function(event) {
|
||||
url = $("#subUrl").val();
|
||||
guildId = getCurrentlyActiveServer().guild_id;
|
||||
extraNotes = $("#subExtraNotes").val();
|
||||
subChannels = $("#subChannels option:selected").toArray().map(channel => channel.value);
|
||||
subChannels = Object.fromEntries($("#subChannels option:selected").toArray().map(channel => [channel.value, $(channel).data("name")]));
|
||||
subFilters = $("#subFilters option:selected").toArray().map(filter => parseInt(filter.value));
|
||||
subMutators = {
|
||||
title: $("#subTitleMutators option:selected").toArray().map(mutator => parseInt(mutator.value)),
|
||||
@ -267,6 +267,7 @@ $("#subForm").on("submit", async function(event) {
|
||||
return
|
||||
}
|
||||
|
||||
// continue here, channel name
|
||||
await deleteSubChannels(subPrimaryKey);
|
||||
subChannels.forEach(async channelId => {
|
||||
await saveSubChannel(channelId, subPrimaryKey);
|
||||
@ -511,7 +512,7 @@ async function loadChannelOptions(guildId) {
|
||||
if (channel.type !== 0)
|
||||
return;
|
||||
|
||||
let channelObj = {text: `#${channel.name}`, value: channel.id}
|
||||
let channelObj = {text: `#${channel.name}`, value: channel.id, "data-name": channel.name}
|
||||
$("#subChannels").append($("<option>", channelObj));
|
||||
discordChannels.push(channelObj);
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user