2018-11-26 21:09:04 +00:00
|
|
|
"""passbook Core Application forms"""
|
|
|
|
from django import forms
|
2019-02-21 15:06:57 +00:00
|
|
|
from django.utils.translation import gettext_lazy as _
|
2018-11-26 21:09:04 +00:00
|
|
|
|
2018-12-09 22:05:55 +00:00
|
|
|
from passbook.core.models import Application, Provider
|
2020-07-05 20:58:52 +00:00
|
|
|
from passbook.lib.widgets import GroupedModelChoiceField
|
2018-11-26 21:09:04 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ApplicationForm(forms.ModelForm):
|
|
|
|
"""Application Form"""
|
|
|
|
|
2020-09-02 22:04:12 +00:00
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
self.fields["provider"].queryset = (
|
|
|
|
Provider.objects.all().order_by("pk").select_subclasses()
|
|
|
|
)
|
2018-12-09 22:05:55 +00:00
|
|
|
|
2018-11-26 21:09:04 +00:00
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = Application
|
2019-12-31 11:51:16 +00:00
|
|
|
fields = [
|
|
|
|
"name",
|
|
|
|
"slug",
|
|
|
|
"provider",
|
2020-02-20 12:45:22 +00:00
|
|
|
"meta_launch_url",
|
|
|
|
"meta_icon_url",
|
|
|
|
"meta_description",
|
|
|
|
"meta_publisher",
|
2019-12-31 11:51:16 +00:00
|
|
|
]
|
2018-11-26 21:09:04 +00:00
|
|
|
widgets = {
|
2019-12-31 11:51:16 +00:00
|
|
|
"name": forms.TextInput(),
|
2020-11-21 18:22:53 +00:00
|
|
|
"meta_launch_url": forms.TextInput(),
|
2020-02-20 12:45:22 +00:00
|
|
|
"meta_icon_url": forms.TextInput(),
|
|
|
|
"meta_publisher": forms.TextInput(),
|
2018-11-26 21:09:04 +00:00
|
|
|
}
|
2020-11-21 18:22:53 +00:00
|
|
|
help_texts = {
|
|
|
|
"meta_launch_url": _(
|
|
|
|
(
|
|
|
|
"If left empty, passbook will try to extract the launch URL "
|
|
|
|
"based on the selected provider."
|
|
|
|
)
|
|
|
|
),
|
|
|
|
}
|
2020-09-02 22:04:12 +00:00
|
|
|
field_classes = {"provider": GroupedModelChoiceField}
|
2019-02-21 15:06:57 +00:00
|
|
|
labels = {
|
2020-02-20 12:45:22 +00:00
|
|
|
"meta_launch_url": _("Launch URL"),
|
|
|
|
"meta_icon_url": _("Icon URL"),
|
2020-02-20 13:30:06 +00:00
|
|
|
"meta_description": _("Description"),
|
|
|
|
"meta_publisher": _("Publisher"),
|
2019-02-21 15:06:57 +00:00
|
|
|
}
|