2023-09-01 20:48:21 +00:00
|
|
|
from django.conf import settings
|
2021-09-04 20:31:04 +00:00
|
|
|
from django.contrib.auth import user_logged_in
|
2023-08-27 13:41:23 +00:00
|
|
|
from django.db.backends.signals import connection_created
|
2021-09-04 20:31:04 +00:00
|
|
|
from django.dispatch import receiver
|
2023-08-27 13:41:23 +00:00
|
|
|
|
2021-09-04 20:31:04 +00:00
|
|
|
from bookmarks.services import tasks
|
|
|
|
|
|
|
|
|
|
|
|
@receiver(user_logged_in)
|
|
|
|
def user_logged_in(sender, request, user, **kwargs):
|
2022-05-14 07:46:51 +00:00
|
|
|
tasks.schedule_bookmarks_without_snapshots(user)
|
2023-08-27 13:41:23 +00:00
|
|
|
|
|
|
|
|
|
|
|
@receiver(connection_created)
|
|
|
|
def extend_sqlite(connection=None, **kwargs):
|
|
|
|
# Load ICU extension into Sqlite connection to support case-insensitive
|
|
|
|
# comparisons with unicode characters
|
2024-01-27 10:29:16 +00:00
|
|
|
if connection.vendor == "sqlite" and settings.USE_SQLITE_ICU_EXTENSION:
|
2023-08-27 13:41:23 +00:00
|
|
|
connection.connection.enable_load_extension(True)
|
2024-01-27 10:29:16 +00:00
|
|
|
connection.connection.load_extension(
|
|
|
|
settings.SQLITE_ICU_EXTENSION_PATH.rstrip(".so")
|
|
|
|
)
|
2023-08-27 13:41:23 +00:00
|
|
|
|
|
|
|
with connection.cursor() as cursor:
|
|
|
|
# Load an ICU collation for case-insensitive ordering.
|
|
|
|
# The first param can be a specific locale, it seems that not
|
|
|
|
# providing one will use a default collation from the ICU project
|
|
|
|
# that works reasonably for multiple languages
|
|
|
|
cursor.execute("SELECT icu_load_collation('', 'ICU');")
|