Add required tag filtering functionality for rules, allowing complex compound relationships
This commit is contained in:
parent
6d22b489ac
commit
36c034e2ba
@ -38,7 +38,7 @@ class TagAdmin(admin.ModelAdmin):
|
||||
|
||||
@admin.register(TaggingRule)
|
||||
class TaggingRuleAdmin(admin.ModelAdmin):
|
||||
list_display = ['name', 'tag', 'title_regex', 'description_regex', 'id']
|
||||
list_display = ['name', 'tag', 'title_regex', 'description_regex', 'required_tag', 'id']
|
||||
search_fields = ['name', 'tag']
|
||||
ordering = ['tag', 'name']
|
||||
list_filter = ['tag']
|
||||
list_filter = ['tag', 'required_tag']
|
||||
|
@ -23,6 +23,8 @@ class Command(BaseCommand):
|
||||
continue
|
||||
if taggingrule.description_regex and not re.match(taggingrule.description_regex, release.name):
|
||||
continue
|
||||
if taggingrule.required_tag and not taggingrule.required_tag in release.tags.all():
|
||||
continue
|
||||
if taggingrule.tag in release.tags.all():
|
||||
ignores += 1
|
||||
continue
|
||||
|
19
odyseescraper/migrations/0016_taggingrule_required_tag.py
Normal file
19
odyseescraper/migrations/0016_taggingrule_required_tag.py
Normal file
@ -0,0 +1,19 @@
|
||||
# Generated by Django 5.1.5 on 2025-01-24 22:39
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('odyseescraper', '0015_alter_taggingrule_tag'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='taggingrule',
|
||||
name='required_tag',
|
||||
field=models.ForeignKey(blank=True, help_text='A taga 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'),
|
||||
),
|
||||
]
|
@ -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 iss ignored.")
|
||||
required_tag = models.ForeignKey(Tag, related_name="requiredtag", on_delete=models.CASCADE, null=True, blank=True, help_text="A taga 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")
|
||||
|
||||
def __str__(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user