151 lines
5.1 KiB
Python
151 lines
5.1 KiB
Python
# Django imports
|
|
from django import forms
|
|
|
|
# Local imports
|
|
from .models import Geo, Modulation, ObjItem, Parameter, Polarization, Satellite, Standard
|
|
|
|
class UploadFileForm(forms.Form):
|
|
file = forms.FileField(
|
|
label="Выберите файл",
|
|
widget=forms.FileInput(attrs={
|
|
'class': 'form-file-input'
|
|
})
|
|
)
|
|
|
|
|
|
class LoadExcelData(forms.Form):
|
|
file = forms.FileField(
|
|
label="Выберите Excel файл",
|
|
widget=forms.FileInput(attrs={
|
|
'class': 'form-control',
|
|
'accept': '.xlsx,.xls'
|
|
})
|
|
)
|
|
sat_choice = forms.ModelChoiceField(
|
|
queryset=Satellite.objects.all(),
|
|
label="Выберите спутник",
|
|
widget=forms.Select(attrs={
|
|
'class': 'form-select'
|
|
})
|
|
)
|
|
number_input = forms.IntegerField(
|
|
label="Введите число объектов",
|
|
min_value=0,
|
|
widget=forms.NumberInput(attrs={
|
|
'class': 'form-control'
|
|
})
|
|
)
|
|
|
|
class LoadCsvData(forms.Form):
|
|
file = forms.FileField(
|
|
label="Выберите CSV файл",
|
|
widget=forms.FileInput(attrs={
|
|
'class': 'form-control',
|
|
'accept': '.csv'
|
|
})
|
|
)
|
|
|
|
class UploadVchLoad(UploadFileForm):
|
|
sat_choice = forms.ModelChoiceField(
|
|
queryset=Satellite.objects.all(),
|
|
label="Выберите спутник",
|
|
widget=forms.Select(attrs={
|
|
'class': 'form-select'
|
|
})
|
|
)
|
|
|
|
|
|
class VchLinkForm(forms.Form):
|
|
sat_choice = forms.ModelChoiceField(
|
|
queryset=Satellite.objects.all(),
|
|
label="Выберите спутник",
|
|
widget=forms.Select(attrs={
|
|
'class': 'form-select'
|
|
})
|
|
)
|
|
# ku_range = forms.ChoiceField(
|
|
# choices=[(9750.0, '9750'), (10750.0, '10750')],
|
|
# # coerce=lambda x: x == 'True',
|
|
# widget=forms.Select(attrs={'class': 'form-select'}),
|
|
# label='Выбор диапазона'
|
|
# )
|
|
value1 = forms.FloatField(
|
|
label="Первое число",
|
|
widget=forms.NumberInput(attrs={
|
|
'class': 'form-control',
|
|
'placeholder': 'Введите первое число'
|
|
})
|
|
)
|
|
value2 = forms.FloatField(
|
|
label="Второе число",
|
|
widget=forms.NumberInput(attrs={
|
|
'class': 'form-control',
|
|
'placeholder': 'Введите второе число'
|
|
})
|
|
)
|
|
|
|
|
|
class NewEventForm(forms.Form):
|
|
# sat_choice = forms.ModelChoiceField(
|
|
# queryset=Satellite.objects.all(),
|
|
# label="Выберите спутник",
|
|
# widget=forms.Select(attrs={
|
|
# 'class': 'form-select'
|
|
# })
|
|
# )
|
|
# pol_choice = forms.ModelChoiceField(
|
|
# queryset=Polarization.objects.all(),
|
|
# label="Выберите поляризацию",
|
|
# widget=forms.Select(attrs={
|
|
# 'class': 'form-select'
|
|
# })
|
|
# )
|
|
file = forms.FileField(
|
|
label="Выберите файл",
|
|
widget=forms.FileInput(attrs={
|
|
'class': 'form-control',
|
|
'accept': '.xlsx,.xls'
|
|
})
|
|
)
|
|
class ParameterForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Parameter
|
|
fields = [
|
|
'id_satellite', 'frequency', 'freq_range', 'polarization',
|
|
'bod_velocity', 'modulation', 'snr', 'standard'
|
|
]
|
|
widgets = {
|
|
'id_satellite': forms.Select(attrs={'class': 'form-select'}, choices=[]),
|
|
'frequency': forms.NumberInput(attrs={'class': 'form-control', 'step': '0.001'}),
|
|
'freq_range': forms.NumberInput(attrs={'class': 'form-control', 'step': '0.001'}),
|
|
'bod_velocity': forms.NumberInput(attrs={'class': 'form-control', 'step': '0.001'}),
|
|
'snr': forms.NumberInput(attrs={'class': 'form-control', 'step': '0.001'}),
|
|
'polarization': forms.Select(attrs={'class': 'form-select'}, choices=[]),
|
|
'modulation': forms.Select(attrs={'class': 'form-select'}, choices=[]),
|
|
'standard': forms.Select(attrs={'class': 'form-select'}, choices=[]),
|
|
}
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super().__init__(*args, **kwargs)
|
|
self.fields['id_satellite'].choices = [(s.id, s.name) for s in Satellite.objects.all()]
|
|
self.fields['polarization'].choices = [(p.id, p.name) for p in Polarization.objects.all()]
|
|
self.fields['modulation'].choices = [(m.id, m.name) for m in Modulation.objects.all()]
|
|
self.fields['standard'].choices = [(s.id, s.name) for s in Standard.objects.all()]
|
|
|
|
class GeoForm(forms.ModelForm):
|
|
class Meta:
|
|
model = Geo
|
|
fields = ['location', 'comment', 'is_average']
|
|
widgets = {
|
|
'location': forms.TextInput(attrs={'class': 'form-control'}),
|
|
'comment': forms.TextInput(attrs={'class': 'form-control'}),
|
|
'is_average': forms.CheckboxInput(attrs={'class': 'form-check-input'}),
|
|
}
|
|
|
|
class ObjItemForm(forms.ModelForm):
|
|
class Meta:
|
|
model = ObjItem
|
|
fields = ['name']
|
|
widgets = {
|
|
'name': forms.TextInput(attrs={'class': 'form-control'}),
|
|
} |