Filter model keywords attr
This commit is contained in:
parent
62c308a720
commit
8025a2d384
36
apps/home/migrations/0006_filter_and_more.py
Normal file
36
apps/home/migrations/0006_filter_and_more.py
Normal file
@ -0,0 +1,36 @@
|
||||
# Generated by Django 5.0.1 on 2024-04-30 08:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0005_alter_subchannel_options_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Filter',
|
||||
fields=[
|
||||
('id', models.AutoField(primary_key=True, serialize=False)),
|
||||
('name', models.CharField(max_length=32)),
|
||||
('keywords', models.CharField(blank=True, max_length=128, null=True)),
|
||||
('regex', models.CharField(blank=True, max_length=128, null=True)),
|
||||
('guild_id', models.CharField(max_length=128)),
|
||||
],
|
||||
options={
|
||||
'verbose_name': 'filter',
|
||||
'verbose_name_plural': 'filters',
|
||||
'get_latest_by': 'id',
|
||||
},
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='filter',
|
||||
constraint=models.CheckConstraint(check=models.Q(models.Q(('keywords__isnull', False), ('regex__isnull', True)), models.Q(('keywords__isnull', True), ('regex__isnull', False)), _connector='OR'), name='either keywords or regex null, other not null'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='filter',
|
||||
constraint=models.UniqueConstraint(fields=('name', 'guild_id'), name='unique name & guild id pair'),
|
||||
),
|
||||
]
|
@ -0,0 +1,21 @@
|
||||
# Generated by Django 5.0.1 on 2024-04-30 08:42
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0006_filter_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveConstraint(
|
||||
model_name='filter',
|
||||
name='either keywords or regex null, other not null',
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='filter',
|
||||
constraint=models.CheckConstraint(check=models.Q(models.Q(('keywords__isnull', False), ('regex__isnull', False), _connector='OR'), models.Q(('keywords__isnull', True), ('regex__isnull', True), _connector='OR')), name='either keywords or regex null, other not null'),
|
||||
),
|
||||
]
|
@ -0,0 +1,25 @@
|
||||
# Generated by Django 5.0.1 on 2024-04-30 08:54
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0007_remove_filter_either_keywords_or_regex_null_other_not_null_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveConstraint(
|
||||
model_name='filter',
|
||||
name='either keywords or regex null, other not null',
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='filter',
|
||||
constraint=models.CheckConstraint(check=models.Q(('keywords__isnull', False), ('regex__isnull', False), _connector='OR'), name='keywords not null or regex not null'),
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='filter',
|
||||
constraint=models.CheckConstraint(check=models.Q(('keywords__isnull', True), ('regex__isnull', True), _connector='OR'), name='keywords null or regex null'),
|
||||
),
|
||||
]
|
@ -0,0 +1,21 @@
|
||||
# Generated by Django 5.0.1 on 2024-04-30 08:56
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0008_remove_filter_either_keywords_or_regex_null_other_not_null_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveConstraint(
|
||||
model_name='filter',
|
||||
name='keywords not null or regex not null',
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='filter',
|
||||
constraint=models.CheckConstraint(check=models.Q(models.Q(('keywords__isnull', False), _negated=True), models.Q(('regex__isnull', False), _negated=True), _connector='OR'), name='keywords not null or regex not null'),
|
||||
),
|
||||
]
|
@ -0,0 +1,17 @@
|
||||
# Generated by Django 5.0.1 on 2024-04-30 08:57
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0009_remove_filter_keywords_not_null_or_regex_not_null_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveConstraint(
|
||||
model_name='filter',
|
||||
name='keywords not null or regex not null',
|
||||
),
|
||||
]
|
@ -0,0 +1,21 @@
|
||||
# Generated by Django 5.0.1 on 2024-04-30 09:09
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0010_remove_filter_keywords_not_null_or_regex_not_null'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveConstraint(
|
||||
model_name='filter',
|
||||
name='keywords null or regex null',
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='filter',
|
||||
constraint=models.CheckConstraint(check=models.Q(('keywords__isnull', True), ('regex__isnull', True), _connector='OR', _negated=True), name='keywords null or regex null'),
|
||||
),
|
||||
]
|
@ -0,0 +1,21 @@
|
||||
# Generated by Django 5.0.1 on 2024-04-30 09:10
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0011_remove_filter_keywords_null_or_regex_null_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveConstraint(
|
||||
model_name='filter',
|
||||
name='keywords null or regex null',
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='filter',
|
||||
constraint=models.CheckConstraint(check=models.Q(('keywords__isnull', False), ('regex__isnull', False), _connector='OR', _negated=True), name='keywords null or regex null'),
|
||||
),
|
||||
]
|
@ -0,0 +1,21 @@
|
||||
# Generated by Django 5.0.1 on 2024-04-30 09:21
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0012_remove_filter_keywords_null_or_regex_null_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveConstraint(
|
||||
model_name='filter',
|
||||
name='keywords null or regex null',
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='filter',
|
||||
constraint=models.CheckConstraint(check=models.Q(('keywords__isnull', True), ('regex__isnull', True), _negated=True), name='keywords null or regex null'),
|
||||
),
|
||||
]
|
@ -0,0 +1,21 @@
|
||||
# Generated by Django 5.0.1 on 2024-04-30 09:24
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0013_remove_filter_keywords_null_or_regex_null_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveConstraint(
|
||||
model_name='filter',
|
||||
name='keywords null or regex null',
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='filter',
|
||||
constraint=models.CheckConstraint(check=models.Q(('keywords__isnull', False), ('regex__isnull', False), _connector='OR'), name='keywords null or regex null'),
|
||||
),
|
||||
]
|
@ -0,0 +1,17 @@
|
||||
# Generated by Django 5.0.1 on 2024-04-30 09:29
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0014_remove_filter_keywords_null_or_regex_null_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveConstraint(
|
||||
model_name='filter',
|
||||
name='keywords null or regex null',
|
||||
),
|
||||
]
|
17
apps/home/migrations/0016_filter_keywords_is_not_null.py
Normal file
17
apps/home/migrations/0016_filter_keywords_is_not_null.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Generated by Django 5.0.1 on 2024-04-30 09:36
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0015_remove_filter_keywords_null_or_regex_null'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddConstraint(
|
||||
model_name='filter',
|
||||
constraint=models.CheckConstraint(check=models.Q(('keywords__isnull', False)), name='keywords is not null'),
|
||||
),
|
||||
]
|
@ -0,0 +1,21 @@
|
||||
# Generated by Django 5.0.1 on 2024-04-30 09:37
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0016_filter_keywords_is_not_null'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveConstraint(
|
||||
model_name='filter',
|
||||
name='keywords is not null',
|
||||
),
|
||||
migrations.AddConstraint(
|
||||
model_name='filter',
|
||||
constraint=models.CheckConstraint(check=models.Q(('keywords__isnull', True)), name='keywords is not null'),
|
||||
),
|
||||
]
|
@ -0,0 +1,17 @@
|
||||
# Generated by Django 5.0.1 on 2024-05-01 09:31
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('home', '0017_remove_filter_keywords_is_not_null_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RemoveConstraint(
|
||||
model_name='filter',
|
||||
name='keywords is not null',
|
||||
),
|
||||
]
|
@ -10,6 +10,7 @@ from django.utils import timezone
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from django.core.files.storage import FileSystemStorage
|
||||
from django.utils.deconstruct import deconstructible
|
||||
from django.core.exceptions import ValidationError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -152,7 +153,7 @@ class Filter(models.Model):
|
||||
)
|
||||
|
||||
keywords = models.CharField(
|
||||
maxlength=128,
|
||||
max_length=128,
|
||||
null=True,
|
||||
blank=True
|
||||
)
|
||||
@ -178,18 +179,11 @@ class Filter(models.Model):
|
||||
verbose_name = "filter"
|
||||
verbose_name_plural = "filters"
|
||||
get_latest_by = "id"
|
||||
constaints = [
|
||||
models.CheckConstraint(
|
||||
check=(
|
||||
(Q(keywords__isnull=False) & Q(regex__isnull=True)) |
|
||||
(Q(keywords__isnull=True) & Q(regex__isnull=False))
|
||||
),
|
||||
name="either keywords or regex null, other not null"
|
||||
),
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["name", "guild_id"],
|
||||
name="unique name & server pair")
|
||||
|
||||
name="unique name & guild id pair"
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user