mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-25 19:11:09 +00:00
Replace deprecated CICharField with custom collation for case-insensitivity
This commit is contained in:
parent
2896219e88
commit
051dab77bb
3 changed files with 46 additions and 5 deletions
|
@ -0,0 +1,39 @@
|
||||||
|
# Generated by Django 4.2.11 on 2024-04-01 21:09
|
||||||
|
|
||||||
|
import bookwyrm.models.fields
|
||||||
|
from django.db import migrations, models
|
||||||
|
from django.contrib.postgres.operations import CreateCollation
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
("bookwyrm", "0200_alter_user_preferred_timezone"),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
CreateCollation(
|
||||||
|
"case_insensitive",
|
||||||
|
provider="icu",
|
||||||
|
locale="und-u-ks-level2",
|
||||||
|
deterministic=False,
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="hashtag",
|
||||||
|
name="name",
|
||||||
|
field=bookwyrm.models.fields.CharField(
|
||||||
|
db_collation="case_insensitive", max_length=256
|
||||||
|
),
|
||||||
|
),
|
||||||
|
migrations.AlterField(
|
||||||
|
model_name="user",
|
||||||
|
name="localname",
|
||||||
|
field=models.CharField(
|
||||||
|
db_collation="case_insensitive",
|
||||||
|
max_length=255,
|
||||||
|
null=True,
|
||||||
|
unique=True,
|
||||||
|
validators=[bookwyrm.models.fields.validate_localname],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -2,18 +2,19 @@
|
||||||
from bookwyrm import activitypub
|
from bookwyrm import activitypub
|
||||||
from .activitypub_mixin import ActivitypubMixin
|
from .activitypub_mixin import ActivitypubMixin
|
||||||
from .base_model import BookWyrmModel
|
from .base_model import BookWyrmModel
|
||||||
from .fields import CICharField
|
from .fields import CharField
|
||||||
|
|
||||||
|
|
||||||
class Hashtag(ActivitypubMixin, BookWyrmModel):
|
class Hashtag(ActivitypubMixin, BookWyrmModel):
|
||||||
"a hashtag which can be used in statuses"
|
"a hashtag which can be used in statuses"
|
||||||
|
|
||||||
name = CICharField(
|
name = CharField(
|
||||||
max_length=256,
|
max_length=256,
|
||||||
blank=False,
|
blank=False,
|
||||||
null=False,
|
null=False,
|
||||||
activitypub_field="name",
|
activitypub_field="name",
|
||||||
deduplication_field=True,
|
deduplication_field=True,
|
||||||
|
db_collation="case_insensitive",
|
||||||
)
|
)
|
||||||
|
|
||||||
name_field = "name"
|
name_field = "name"
|
||||||
|
|
|
@ -7,7 +7,7 @@ from uuid import uuid4
|
||||||
|
|
||||||
from django.apps import apps
|
from django.apps import apps
|
||||||
from django.contrib.auth.models import AbstractUser
|
from django.contrib.auth.models import AbstractUser
|
||||||
from django.contrib.postgres.fields import ArrayField, CICharField
|
from django.contrib.postgres.fields import ArrayField as DjangoArrayField
|
||||||
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
|
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
|
||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.db import models, transaction, IntegrityError
|
from django.db import models, transaction, IntegrityError
|
||||||
|
@ -76,11 +76,12 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
summary = fields.HtmlField(null=True, blank=True)
|
summary = fields.HtmlField(null=True, blank=True)
|
||||||
local = models.BooleanField(default=False)
|
local = models.BooleanField(default=False)
|
||||||
bookwyrm_user = fields.BooleanField(default=True)
|
bookwyrm_user = fields.BooleanField(default=True)
|
||||||
localname = CICharField(
|
localname = models.CharField(
|
||||||
max_length=255,
|
max_length=255,
|
||||||
null=True,
|
null=True,
|
||||||
unique=True,
|
unique=True,
|
||||||
validators=[fields.validate_localname],
|
validators=[fields.validate_localname],
|
||||||
|
db_collation="case_insensitive",
|
||||||
)
|
)
|
||||||
# name is your display name, which you can change at will
|
# name is your display name, which you can change at will
|
||||||
name = fields.CharField(max_length=100, null=True, blank=True)
|
name = fields.CharField(max_length=100, null=True, blank=True)
|
||||||
|
@ -157,7 +158,7 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
||||||
show_guided_tour = models.BooleanField(default=True)
|
show_guided_tour = models.BooleanField(default=True)
|
||||||
|
|
||||||
# feed options
|
# feed options
|
||||||
feed_status_types = ArrayField(
|
feed_status_types = DjangoArrayField(
|
||||||
models.CharField(max_length=10, blank=False, choices=FeedFilterChoices),
|
models.CharField(max_length=10, blank=False, choices=FeedFilterChoices),
|
||||||
size=8,
|
size=8,
|
||||||
default=get_feed_filter_choices,
|
default=get_feed_filter_choices,
|
||||||
|
|
Loading…
Reference in a new issue