Plug into autocomplete and urls

This commit is contained in:
Ludovic Stephan 2020-07-21 14:50:00 +02:00
parent 5e5b224f89
commit ee1d158f2d
3 changed files with 18 additions and 5 deletions

View file

@ -1,5 +1,8 @@
from urllib.parse import urlencode
from django.contrib.auth import get_user_model from django.contrib.auth import get_user_model
from django.db.models import Q from django.db.models import Q
from django.urls import reverse
from django.utils.translation import gettext_lazy as _ from django.utils.translation import gettext_lazy as _
from shared import autocomplete from shared import autocomplete
@ -21,7 +24,7 @@ class BDSMemberSearch(autocomplete.ModelSearch):
return user.username return user.username
def result_link(self, user): def result_link(self, user):
return "#TODO" return reverse("bds:user.update", args=(user.pk,))
class BDSOthersSearch(autocomplete.ModelSearch): class BDSOthersSearch(autocomplete.ModelSearch):
@ -38,12 +41,16 @@ class BDSOthersSearch(autocomplete.ModelSearch):
return user.username return user.username
def result_link(self, user): def result_link(self, user):
return "#TODO" return reverse("bds:user.update", args=(user.pk,))
class BDSLDAPSearch(autocomplete.LDAPSearch): class BDSLDAPSearch(autocomplete.LDAPSearch):
def result_link(self, clipper): def result_link(self, clipper):
return "#TODO" print(clipper.fullname)
url = reverse("bds:user.create.fromclipper", args=(clipper.clipper,))
get = {"fullname": clipper.fullname}
return "{}?{}".format(url, urlencode(get))
class BDSSearch(autocomplete.Compose): class BDSSearch(autocomplete.Compose):

View file

@ -62,6 +62,8 @@ class BDSProfile(models.Model):
null=True, null=True,
) )
is_member = models.BooleanField(_("adhérent⋅e du BDS"), default=False)
mails_bds = models.BooleanField(_("recevoir les mails du BDS"), default=False) mails_bds = models.BooleanField(_("recevoir les mails du BDS"), default=False)
has_certificate = models.BooleanField(_("certificat médical"), default=False) has_certificate = models.BooleanField(_("certificat médical"), default=False)
@ -77,8 +79,6 @@ class BDSProfile(models.Model):
FFSU_number = models.CharField( FFSU_number = models.CharField(
_("numéro FFSU"), max_length=50, blank=True, null=True _("numéro FFSU"), max_length=50, blank=True, null=True
) )
is_member = models.BooleanField(_("adhérent⋅e du BDS"), default=False)
cotisation_period = models.CharField( cotisation_period = models.CharField(
_("inscription"), default="NO", choices=COTIZ_DURATION_CHOICES, max_length=3 _("inscription"), default="NO", choices=COTIZ_DURATION_CHOICES, max_length=3
) )

View file

@ -7,4 +7,10 @@ urlpatterns = [
path("", views.Home.as_view(), name="home"), path("", views.Home.as_view(), name="home"),
path("autocomplete", views.BDSAutocompleteView.as_view(), name="autocomplete"), path("autocomplete", views.BDSAutocompleteView.as_view(), name="autocomplete"),
path("user/update/<int:pk>", views.UserUpdateView.as_view(), name="user.update"), path("user/update/<int:pk>", views.UserUpdateView.as_view(), name="user.update"),
path("user/create/", views.UserCreateView.as_view(), name="user.create"),
path(
"user/create/<slug:clipper>",
views.UserCreateView.as_view(),
name="user.create.fromclipper",
),
] ]