Add channel regex field to rules, fix untagged channels being impossible to create

This commit is contained in:
Salt 2025-01-24 17:38:02 -06:00
parent 57e7f84c64
commit cfd7d96385
3 changed files with 25 additions and 2 deletions

View File

@ -36,7 +36,7 @@ class Command(BaseCommand):
if taggingrule.tag in release.tags.all():
ignores += 1
continue
self.stdout.write(f'Release "{str(release)}" matched rule "{str(taggingrule)}" for tag "{str(taggingrule.tag)}"')
self.stdout.write(f'{str(release.channel)} - {str(release)} - matched rule "{str(taggingrule)}" for tag "{str(taggingrule.tag)}"')
if not options['dry_run']:
release.tags.add(taggingrule.tag)
updates += 1

View File

@ -0,0 +1,23 @@
# Generated by Django 5.1.5 on 2025-01-24 23:37
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('odyseescraper', '0017_taggingrule_channel_regex_and_more'),
]
operations = [
migrations.AlterField(
model_name='odyseechannel',
name='tags',
field=models.ManyToManyField(blank=True, help_text='A list of tags associated with this channel. When queried, any release from this channel will inherit its tags.', related_name='channels', to='odyseescraper.tag'),
),
migrations.AlterField(
model_name='taggingrule',
name='channel_regex',
field=models.CharField(blank=True, help_text='A regular expression to match against the channel HANDLE of a release. If it matches, the tag is applied. If this value is blank, it is ignored.', max_length=512),
),
]

View File

@ -37,7 +37,7 @@ class OdyseeChannel(models.Model):
description = models.TextField(help_text="A user-facing description of the channel, its owners, and its content. May also contain links to related resources and websites.")
handle = models.CharField(max_length=1024, help_text="The @tag of the user. May be a short tag (@someuser) or qualified with claimid (@someuser:4ab8)")
tags = models.ManyToManyField(Tag, related_name="channels", help_text="A list of tags associated with this channel. When queried, any release from this channel will inherit its tags.")
tags = models.ManyToManyField(Tag, related_name="channels", blank=True, help_text="A list of tags associated with this channel. When queried, any release from this channel will inherit its tags.")
def __str__(self):
return self.name