Remove ajax_select from subscriptions

This commit is contained in:
Antoine Bartuccio 2024-10-20 22:36:55 +02:00
parent b6a480ff61
commit a21460a1b8

View File

@ -15,7 +15,6 @@
import random import random
from ajax_select.fields import AutoCompleteSelectField
from django import forms from django import forms
from django.conf import settings from django.conf import settings
from django.core.exceptions import PermissionDenied, ValidationError from django.core.exceptions import PermissionDenied, ValidationError
@ -25,6 +24,7 @@ from django.views.generic.edit import CreateView, FormView
from core.models import User from core.models import User
from core.views.forms import SelectDate, SelectDateTime from core.views.forms import SelectDate, SelectDateTime
from core.views.widgets.select import AutoCompleteSelectUser
from subscription.models import Subscription from subscription.models import Subscription
@ -43,11 +43,11 @@ class SubscriptionForm(forms.ModelForm):
class Meta: class Meta:
model = Subscription model = Subscription
fields = ["member", "subscription_type", "payment_method", "location"] fields = ["member", "subscription_type", "payment_method", "location"]
widgets = {"member": AutoCompleteSelectUser}
member = AutoCompleteSelectField("users", required=False, help_text=None)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self.fields["member"].required = False
self.fields |= forms.fields_for_model( self.fields |= forms.fields_for_model(
User, User,
fields=["first_name", "last_name", "email", "date_of_birth"], fields=["first_name", "last_name", "email", "date_of_birth"],