mirror of
https://github.com/ae-utbm/sith.git
synced 2025-07-09 19:40:19 +00:00
Remove ajax_select from core
This commit is contained in:
@ -18,7 +18,6 @@ from urllib.parse import quote, urljoin
|
||||
# This file contains all the views that concern the page model
|
||||
from wsgiref.util import FileWrapper
|
||||
|
||||
from ajax_select import make_ajax_field
|
||||
from django import forms
|
||||
from django.conf import settings
|
||||
from django.core.exceptions import PermissionDenied
|
||||
@ -39,6 +38,11 @@ from core.views import (
|
||||
CanViewMixin,
|
||||
can_view,
|
||||
)
|
||||
from core.views.widgets.select import (
|
||||
AutoCompleteSelectMultipleGroup,
|
||||
AutoCompleteSelectSithFile,
|
||||
AutoCompleteSelectUser,
|
||||
)
|
||||
from counter.utils import is_logged_in_counter
|
||||
|
||||
|
||||
@ -217,14 +221,13 @@ class FileEditPropForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = SithFile
|
||||
fields = ["parent", "owner", "edit_groups", "view_groups"]
|
||||
widgets = {
|
||||
"parent": AutoCompleteSelectSithFile,
|
||||
"owner": AutoCompleteSelectUser,
|
||||
"edit_groups": AutoCompleteSelectMultipleGroup,
|
||||
"view_groups": AutoCompleteSelectMultipleGroup,
|
||||
}
|
||||
|
||||
parent = make_ajax_field(SithFile, "parent", "files", help_text="")
|
||||
edit_groups = make_ajax_field(
|
||||
SithFile, "edit_groups", "groups", help_text="", label=_("edit group")
|
||||
)
|
||||
view_groups = make_ajax_field(
|
||||
SithFile, "view_groups", "groups", help_text="", label=_("view group")
|
||||
)
|
||||
recursive = forms.BooleanField(label=_("Apply rights recursively"), required=False)
|
||||
|
||||
|
||||
|
@ -3,8 +3,8 @@ from django.db.models import Model
|
||||
from django.forms import Select, SelectMultiple
|
||||
from ninja import ModelSchema
|
||||
|
||||
from core.models import Group, User
|
||||
from core.schemas import GroupSchema, UserProfileSchema
|
||||
from core.models import Group, SithFile, User
|
||||
from core.schemas import GroupSchema, SithFileSchema, UserProfileSchema
|
||||
|
||||
|
||||
class AutoCompleteSelectMixin:
|
||||
@ -91,3 +91,15 @@ class AutoCompleteSelectMultipleGroup(AutoCompleteSelectMixin, SelectMultiple):
|
||||
component_name = "group-ajax-select"
|
||||
model = Group
|
||||
schema = GroupSchema
|
||||
|
||||
|
||||
class AutoCompleteSelectSithFile(AutoCompleteSelectMixin, Select):
|
||||
component_name = "sith-file-ajax-select"
|
||||
model = SithFile
|
||||
schema = SithFileSchema
|
||||
|
||||
|
||||
class AutoCompleteSelectMultipleSithFile(AutoCompleteSelectMixin, SelectMultiple):
|
||||
component_name = "sith-file-ajax-select"
|
||||
model = SithFile
|
||||
schema = SithFileSchema
|
||||
|
Reference in New Issue
Block a user