unique rules migration
This commit is contained in:
parent
0fe1633beb
commit
3acb172432
@ -248,7 +248,7 @@ class Subscription_ListView(generics.ListCreateAPIView):
|
|||||||
|
|
||||||
filter_backends = [filters.SearchFilter, rest_filters.DjangoFilterBackend, filters.OrderingFilter]
|
filter_backends = [filters.SearchFilter, rest_filters.DjangoFilterBackend, filters.OrderingFilter]
|
||||||
filterset_fields = [
|
filterset_fields = [
|
||||||
"id", "name", "url", "guild_id", "creation_datetime", "extra_notes", "filters",
|
"id", "name", "url", "guild_id", "creation_datetime", "extra_notes", "filters", "unique_content_rules",
|
||||||
"article_title_mutators", "article_desc_mutators", "embed_colour", "published_threshold", "active"
|
"article_title_mutators", "article_desc_mutators", "embed_colour", "published_threshold", "active"
|
||||||
]
|
]
|
||||||
search_fields = ["name", "url", "extra_notes"]
|
search_fields = ["name", "url", "extra_notes"]
|
||||||
|
25
apps/home/migrations/0025_set_uniquerules.py
Normal file
25
apps/home/migrations/0025_set_uniquerules.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Generated by Django 5.0.4 on 2024-09-15 13:40
|
||||||
|
|
||||||
|
from django.db import migrations
|
||||||
|
|
||||||
|
def set_rules_to_ruleless_subs(apps, scheme_editor):
|
||||||
|
Subs = apps.get_model("home", "Subscription")
|
||||||
|
Rules = apps.get_model("home", "UniqueContentRule")
|
||||||
|
no_rule_subs = Subs.objects.filter(unique_content_rules=None)
|
||||||
|
|
||||||
|
guid_rule = Rules.objects.get(value="GUID")
|
||||||
|
id_rule = Rules.objects.get(value="ID")
|
||||||
|
|
||||||
|
for sub in no_rule_subs:
|
||||||
|
sub.unique_content_rules.set([guid_rule.pk, id_rule.pk])
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('home', '0024_initial_uniquecontentrule_data'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.RunPython(set_rules_to_ruleless_subs)
|
||||||
|
]
|
Loading…
x
Reference in New Issue
Block a user