This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2020-09-02 22:04:12 +00:00
|
|
|
"""Outpost forms"""
|
|
|
|
|
|
|
|
from django import forms
|
|
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
|
|
from passbook.admin.fields import CodeMirrorWidget, YAMLField
|
|
|
|
from passbook.outposts.models import Outpost
|
2020-09-18 19:46:14 +00:00
|
|
|
from passbook.providers.proxy.models import ProxyProvider
|
2020-09-02 22:04:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
class OutpostForm(forms.ModelForm):
|
|
|
|
"""Outpost Form"""
|
|
|
|
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
2020-09-18 19:46:14 +00:00
|
|
|
self.fields["providers"].queryset = ProxyProvider.objects.all()
|
2020-09-02 22:04:12 +00:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
|
|
|
|
model = Outpost
|
|
|
|
fields = [
|
|
|
|
"name",
|
|
|
|
"type",
|
|
|
|
"deployment_type",
|
|
|
|
"providers",
|
|
|
|
"_config",
|
|
|
|
]
|
|
|
|
widgets = {
|
|
|
|
"name": forms.TextInput(),
|
|
|
|
"_config": CodeMirrorWidget,
|
|
|
|
}
|
|
|
|
field_classes = {
|
|
|
|
"_config": YAMLField,
|
|
|
|
}
|
|
|
|
labels = {"_config": _("Configuration")}
|