mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-21 09:58:23 +02:00
Invite people
This commit is contained in:
@ -2,10 +2,13 @@
|
||||
# SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
from django import forms
|
||||
from activity.models import Activity
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from member.models import Club
|
||||
from note.models import NoteUser
|
||||
from note_kfet.inputs import DateTimePickerInput, AutocompleteModelSelect
|
||||
|
||||
from .models import Activity, Guest
|
||||
|
||||
|
||||
class ActivityForm(forms.ModelForm):
|
||||
class Meta:
|
||||
@ -23,3 +26,28 @@ class ActivityForm(forms.ModelForm):
|
||||
"date_start": DateTimePickerInput(),
|
||||
"date_end": DateTimePickerInput(),
|
||||
}
|
||||
|
||||
|
||||
class GuestForm(forms.ModelForm):
|
||||
def clean(self, **kwargs):
|
||||
cleaned_data = super().clean()
|
||||
|
||||
self.instance.activity = cleaned_data["activity"] = Activity.objects.get(pk=1)
|
||||
|
||||
return cleaned_data
|
||||
|
||||
class Meta:
|
||||
model = Guest
|
||||
fields = ('last_name', 'first_name', 'inviter', )
|
||||
widgets = {
|
||||
"inviter": AutocompleteModelSelect(
|
||||
NoteUser,
|
||||
attrs={
|
||||
'api_url': '/api/note/note/',
|
||||
# We don't evaluate the content type at launch because the DB might be not initialized
|
||||
'api_url_suffix':
|
||||
lambda value: '&polymorphic_ctype=' + str(ContentType.objects.get_for_model(NoteUser).pk),
|
||||
'placeholder': 'Note ...',
|
||||
},
|
||||
),
|
||||
}
|
||||
|
Reference in New Issue
Block a user