2023-04-06 11:08:42 +00:00
|
|
|
# -*- coding:utf-8 -*-
|
2019-06-18 19:41:11 +00:00
|
|
|
#
|
2023-04-06 11:08:42 +00:00
|
|
|
# Copyright 2023 © AE UTBM
|
|
|
|
# ae@utbm.fr / ae.info@utbm.fr
|
|
|
|
# All contributors are listed in the CONTRIBUTORS file.
|
2019-06-18 19:41:11 +00:00
|
|
|
#
|
2023-04-06 11:08:42 +00:00
|
|
|
# This file is part of the website of the UTBM Student Association (AE UTBM),
|
|
|
|
# https://ae.utbm.fr.
|
2019-06-18 19:41:11 +00:00
|
|
|
#
|
2023-04-06 11:08:42 +00:00
|
|
|
# You can find the whole source code at https://github.com/ae-utbm/sith3
|
2019-06-18 19:41:11 +00:00
|
|
|
#
|
2023-04-06 11:08:42 +00:00
|
|
|
# LICENSED UNDER THE GNU GENERAL PUBLIC LICENSE VERSION 3 (GPLv3)
|
|
|
|
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE
|
|
|
|
# OR WITHIN THE LOCAL FILE "LICENSE"
|
2019-06-18 19:41:11 +00:00
|
|
|
#
|
2023-04-06 11:08:42 +00:00
|
|
|
# PREVIOUSLY LICENSED UNDER THE MIT LICENSE,
|
|
|
|
# SEE : https://raw.githubusercontent.com/ae-utbm/sith3/master/LICENSE.old
|
|
|
|
# OR WITHIN THE LOCAL FILE "LICENSE.old"
|
2019-06-18 19:41:11 +00:00
|
|
|
#
|
|
|
|
|
|
|
|
from django.db import models
|
|
|
|
from haystack import indexes, signals
|
|
|
|
|
|
|
|
from core.search_indexes import BigCharFieldIndex
|
|
|
|
from pedagogy.models import UV
|
|
|
|
|
|
|
|
|
|
|
|
class IndexSignalProcessor(signals.BaseSignalProcessor):
|
|
|
|
"""
|
|
|
|
Auto update index on CRUD operations
|
|
|
|
"""
|
|
|
|
|
|
|
|
def setup(self):
|
|
|
|
# Listen only to the ``UV`` model.
|
|
|
|
models.signals.post_save.connect(self.handle_save, sender=UV)
|
|
|
|
models.signals.post_delete.connect(self.handle_delete, sender=UV)
|
|
|
|
|
|
|
|
def teardown(self):
|
|
|
|
# Disconnect only to the ``UV`` model.
|
|
|
|
models.signals.post_save.disconnect(self.handle_save, sender=UV)
|
|
|
|
models.signals.post_delete.disconnect(self.handle_delete, sender=UV)
|
|
|
|
|
|
|
|
|
|
|
|
class UVIndex(indexes.SearchIndex, indexes.Indexable):
|
|
|
|
"""
|
|
|
|
Indexer class for UVs
|
|
|
|
"""
|
|
|
|
|
|
|
|
text = BigCharFieldIndex(document=True, use_template=True)
|
|
|
|
auto = indexes.EdgeNgramField(use_template=True)
|
|
|
|
|
|
|
|
def get_model(self):
|
|
|
|
return UV
|