Skip to content

Commit

Permalink
Use tomselect
Browse files Browse the repository at this point in the history
  • Loading branch information
frcroth committed Nov 9, 2023
1 parent d478325 commit 1bfce28
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 50 deletions.
15 changes: 4 additions & 11 deletions myhpi/core/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.db import models
from django.db.models import BooleanField, CharField, DateField, ForeignKey, Model, Q
from django.http import HttpResponseRedirect
from django_select2 import forms as s2forms
from django_tomselect.widgets import TomSelectWidget, TomSelectTabularWidget, TomSelectMultipleWidget
from modelcluster.contrib.taggit import ClusterTaggableManager
from modelcluster.fields import ParentalKey, ParentalManyToManyField
from taggit.models import ItemBase, TagBase
Expand Down Expand Up @@ -170,13 +170,6 @@ def get_last_minutes(self):
return existing_minutes.last().specific


class UserSelectWidget(s2forms.ModelSelect2MultipleWidget):
search_fields = [
"username__icontains",
"email__icontains",
]


class Minutes(BasePage):
date = DateField()
moderator = ForeignKey(
Expand All @@ -193,9 +186,9 @@ class Minutes(BasePage):

content_panels = Page.content_panels + [
FieldPanel("date"),
FieldPanel("moderator"),
FieldPanel("author"),
FieldPanel("participants", widget=UserSelectWidget),
FieldPanel("moderator", widget=TomSelectWidget(label_field="username")),
FieldPanel("author", widget=TomSelectWidget(label_field="username")),
FieldPanel("participants", widget=TomSelectMultipleWidget(label_field="username")),
FieldPanel("labels"),
FieldPanel("body"),
FieldPanel("guests"),
Expand Down
2 changes: 1 addition & 1 deletion myhpi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"django.contrib.staticfiles",
"django.contrib.messages",
"django_bootstrap_icons",
"django_select2",
"django_tomselect",
"modelcluster",
"mozilla_django_oidc",
"taggit",
Expand Down
3 changes: 2 additions & 1 deletion myhpi/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from django.contrib.auth import views as auth_views
from django.urls import include, path, reverse_lazy
from django.views.generic import RedirectView
from django_tomselect.views import AutocompleteView
from wagtail.admin import urls as wagtailadmin_urls
from wagtail.core import urls as wagtail_urls
from wagtail.documents import urls as wagtaildocs_urls
Expand All @@ -25,7 +26,7 @@
),
name="login",
),
path("select2/", include("django_select2.urls")),
path("autocomplete/", AutocompleteView.as_view(), name="autocomplete"),
path("__debug__/", include("debug_toolbar.urls")),
path(
".well-known/security.txt",
Expand Down
52 changes: 16 additions & 36 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ django-environ = "^0.10.0"
wagtail-localize = "^1.4"
mozilla-django-oidc = "^3.0.0"
django-bootstrap-icons = "^0.8.3"
django-select2 = "^8.1.2"
django-static-precompiler = {extras = ["libsass"], version = "^2.4"}
django-debug-toolbar = "^4.2.0"
django-permissionedforms = "^0.1"
tenca = "^0.0.2"
html2text = "^2020.1.16"
wagtail-markdown = "^0.10.0"
autoflake = "^2.2.1"
django-tomselect = "^0.4.4"

[tool.poetry.group.dev.dependencies]
pylint = "^2.17.5"
Expand Down

0 comments on commit 1bfce28

Please sign in to comment.