Newer
Older
__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"
from django import forms
from common.forms import HTMXDynSelWidget
from .models import Funder, Grant
from organizations.models import Organization
from .models import Funder, Grant
class FunderRegistrySearchForm(forms.Form):
name = forms.CharField(max_length=128)
class FunderForm(forms.ModelForm):
class Meta:
model = Funder
fields = ["name", "acronym", "identifier"]
class FunderSelectForm(forms.Form):
funder = forms.ModelChoiceField(
queryset=Funder.objects.all(),
url="/funders/funder-autocomplete", attrs={"data-html": True}
),
class FunderOrganizationSelectForm(forms.ModelForm):
widget=autocomplete.ModelSelect2(
url="/organizations/organization-autocomplete", attrs={"data-html": True}
),
class Meta:
model = Funder
fields = []
class GrantForm(HttpRefererFormMixin, forms.ModelForm):
class Meta:
model = Grant
fields = ["funder", "number", "recipient_name", "recipient", "further_details"]
self.fields["funder"] = forms.ModelChoiceField(
queryset=Funder.objects.all(),
widget=HTMXDynSelWidget(url="/funders/funder-autocomplete"),
)
self.fields["recipient"] = forms.ModelChoiceField(
queryset=Contributor.objects.select_related("user").order_by(
"user__last_name"
),
required=False,
class GrantSelectForm(forms.Form):
grant = forms.ModelChoiceField(
queryset=Grant.objects.all(),
widget=HTMXDynSelWidget(url="/funders/grant-autocomplete"),