diff --git a/apps/participation/models.py b/apps/participation/models.py index 034abbc..c3f3e4e 100644 --- a/apps/participation/models.py +++ b/apps/participation/models.py @@ -1,12 +1,11 @@ import re -from django.urls import reverse_lazy - from corres2math.lists import get_sympa_client from django.core.exceptions import ObjectDoesNotExist from django.core.validators import RegexValidator from django.db import models from django.db.models import Index +from django.urls import reverse_lazy from django.utils.crypto import get_random_string from django.utils.text import format_lazy from django.utils.translation import gettext_lazy as _ @@ -121,7 +120,7 @@ class Participation(models.Model): ) def get_absolute_url(self): - return reverse_lazy("participation:team_detail", args=(self.pk,)) + return reverse_lazy("participation:participation_detail", args=(self.pk,)) def __str__(self): return _("Participation of the team {name} ({trigram})").format(name=self.team.name, trigram=self.team.trigram) diff --git a/apps/participation/search_indexes.py b/apps/participation/search_indexes.py index cbe54ed..2a6f88a 100644 --- a/apps/participation/search_indexes.py +++ b/apps/participation/search_indexes.py @@ -4,15 +4,15 @@ from .models import Participation, Team, Video class TeamIndex(indexes.SearchIndex, indexes.Indexable): - text = indexes.CharField(document=True, model_attr="name") - trigram = indexes.CharField(model_attr="trigram") + text = indexes.EdgeNgramField(document=True, model_attr="name") + trigram = indexes.EdgeNgramField(model_attr="trigram") def get_model(self): return Team class ParticipationIndex(indexes.SearchIndex, indexes.Indexable): - text = indexes.CharField(document=True, model_attr="team__trigram") + text = indexes.EdgeNgramField(document=True, model_attr="team__name") def get_model(self): return Participation diff --git a/apps/registration/models.py b/apps/registration/models.py index c1540db..71c890d 100644 --- a/apps/registration/models.py +++ b/apps/registration/models.py @@ -2,6 +2,7 @@ from corres2math.tokens import email_validation_token from django.contrib.sites.models import Site from django.db import models from django.template import loader +from django.urls import reverse_lazy from django.utils.crypto import get_random_string from django.utils.encoding import force_bytes from django.utils.http import urlsafe_base64_encode @@ -63,6 +64,9 @@ class Registration(PolymorphicModel): def is_admin(self): return isinstance(self, AdminRegistration) or self.user.is_superuser + def get_absolute_url(self): + return reverse_lazy("registration:user_detail", args=(self.user_id,)) + def __str__(self): return f"{self.user.first_name} {self.user.last_name}" diff --git a/apps/registration/search_indexes.py b/apps/registration/search_indexes.py index 73c048c..07614ed 100644 --- a/apps/registration/search_indexes.py +++ b/apps/registration/search_indexes.py @@ -4,10 +4,10 @@ from .models import Registration class RegistrationIndex(indexes.SearchIndex, indexes.Indexable): - text = indexes.CharField(document=True, model_attr="user__username") - last_name = indexes.CharField(model_attr="user__last_name") - first_name = indexes.CharField(model_attr="user__first_name") - email = indexes.CharField(model_attr="user__email") + text = indexes.EdgeNgramField(document=True, model_attr="user__username") + last_name = indexes.EdgeNgramField(model_attr="user__last_name") + first_name = indexes.EdgeNgramField(model_attr="user__first_name") + email = indexes.EdgeNgramField(model_attr="user__email") def get_model(self): return Registration diff --git a/corres2math/urls.py b/corres2math/urls.py index 45b3392..2d2cfa5 100644 --- a/corres2math/urls.py +++ b/corres2math/urls.py @@ -13,7 +13,6 @@ Including another URLconf 1. Import the include() function: from django.urls import include, path 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) """ -from django.conf.urls.static import static from django.contrib import admin from django.urls import path, include from django.views.defaults import bad_request, permission_denied, page_not_found, server_error