Add support for tagging rules by channel

This commit is contained in:
Salt 2025-01-24 16:54:06 -06:00
parent 813d4c31de
commit 055011441a
3 changed files with 31 additions and 1 deletions

View File

@ -38,7 +38,7 @@ class TagAdmin(admin.ModelAdmin):
@admin.register(TaggingRule)
class TaggingRuleAdmin(admin.ModelAdmin):
list_display = ['name', 'tag', 'title_regex', 'description_regex', 'required_tag', 'id']
list_display = ['name', 'tag', 'channel_regex', 'title_regex', 'description_regex', 'required_tag', 'id']
search_fields = ['name', 'tag']
ordering = ['name']
list_filter = ['tag', 'required_tag']

View File

@ -0,0 +1,29 @@
# Generated by Django 5.1.5 on 2025-01-24 22:52
import django.db.models.deletion
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('odyseescraper', '0016_taggingrule_required_tag'),
]
operations = [
migrations.AddField(
model_name='taggingrule',
name='channel_regex',
field=models.CharField(blank=True, help_text='A regular expression to match against the channel of a release. If it matches, the tag is applied. If this value is blank, it is ignored.', max_length=512),
),
migrations.AlterField(
model_name='taggingrule',
name='description_regex',
field=models.CharField(blank=True, help_text='A regular expression to match against the description of a release. If it matches, the tag is applied. If this value is blank, it is ignored.', max_length=512),
),
migrations.AlterField(
model_name='taggingrule',
name='required_tag',
field=models.ForeignKey(blank=True, help_text='A tag to match against a release. If this value is blank, it is ignored.', null=True, on_delete=django.db.models.deletion.CASCADE, related_name='requiredtag', to='odyseescraper.tag'),
),
]

View File

@ -21,6 +21,7 @@ class TaggingRule(models.Model):
name = models.CharField(max_length=1024, help_text="A non-user-facing name for the rule")
title_regex = models.CharField(max_length=512, blank=True, help_text="A regular expression to match against the title of a release. If the release's title matches, the tag is applied. If this value is blank, it is ignored.")
description_regex = models.CharField(max_length=512, blank=True, help_text="A regular expression to match against the description of a release. If it matches, the tag is applied. If this value is blank, it is ignored.")
channel_regex = models.CharField(max_length=512, 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.")
required_tag = models.ForeignKey(Tag, related_name="requiredtag", on_delete=models.CASCADE, null=True, blank=True, help_text="A tag to match against a release. If this value is blank, it is ignored.")
tag = models.ForeignKey(Tag, related_name="targettag", on_delete=models.CASCADE, db_index=True, help_text="The tag to assign a release with")