srg/artsurvey/forms.py
2024-04-26 12:43:00 +03:00

106 lines
5.2 KiB
Python

from django import forms
from heasarc.models import HeasarcSimpleClass
from artsurvey.models import ArtSurveyParams
from artsurvey.models import ArtSurveyMatchParams
from artsurvey.models import OpticalCounterpart
from artsurvey.models import Category
from artsurvey.models import ArtSurveySource
from artsurvey.models import OtherName
from artsurvey.models import Upload
from artsurvey.models import ArtSurvey
from artsurvey.models import ArtBasket
from artsurvey.models import MetaComment
class UploadForm(forms.ModelForm):
class Meta:
model = Upload
fields = ('title', 'notes', 'filefield')
widgets = {
'title': forms.TextInput(attrs={'style': 'width: 620px;'}),
}
class ArtSurveySourceTypeForm(forms.Form):
users = forms.ModelChoiceField(queryset=HeasarcSimpleClass.objects.all().order_by('class_id'),widget=forms.Select(),required=True)
class NotesForm(forms.Form):
redshift = forms.FloatField(label='Redshift',required=False)
notes = forms.CharField(widget=forms.Textarea(attrs={"rows":10, "cols":60}),required=False)
follow_up = forms.CharField(widget=forms.Textarea(attrs={"rows":10, "cols":60}),required=False)
notes_paper = forms.CharField(widget=forms.Textarea(attrs={"rows":10, "cols":60}),required=False)
bibtex_paper = forms.CharField(widget=forms.Textarea(attrs={"rows":10, "cols":60}),required=False)
class NotesSurveyForm(forms.Form):
notes = forms.CharField(widget=forms.Textarea(attrs={"rows":10, "cols":60}),required=False)
class CnameForm(forms.Form):
cname = forms.CharField(label='cname', required=False)
class ArtSurveyParamsForm(forms.ModelForm):
survey = forms.ModelChoiceField(queryset=ArtSurvey.objects.all().filter(hidden__exact=False),widget=forms.Select(),required=True,help_text='Survey number <b>N=[1..8]</b> of version <b>V=[0..9]</b> is named as <b>SN.V</b>;</br> The combined survey is labeled as <b>SN<...>N.V</b>;<br>SGPLLL: 5x5 degrees Survey Galactic Plane at longitude LLL;<br> Tags: active (<b>*</b>), in work (<b>W</b>), archived (<b>A</b>, archived (<b>H</b>)')
#marshall = forms.ModelChoiceField(queryset=ArtSurveyParams.MARSHALL_SELECT, required=False)
class Meta:
model = ArtSurveyParams
fields = ('sky','survey','band','exclude_survey','exclude_band','exclude_log_nfalse','exclude_log_ml_nfalse','sign_ml_min','sign_ml_max','log_nfalse_min','log_nfalse_max','log_ml_nfalse_min','log_ml_nfalse_max','detlike_min','detlike_max','exposure_min','ext_min','ext_max','class_startswith','cname_contains','category','exclude_category','category_unclassified','marshall','gaia_primary','allwise_primary','turk_possible','glat_min','glat_max','dec_min','dec_max','ecl_lat_min','ecl_lat_max','circle_ra','circle_dec','circle_rmax_deg')
class ArtSurveyMatchParamsForm(forms.ModelForm):
class Meta:
model = ArtSurveyMatchParams
fields = ('band1','survey1','sign_min1','sign_max1','log_ml_nfalse_min1','log_ml_nfalse_max1',
'band2','survey2','sign_min2','sign_max2','log_ml_nfalse_min2','log_ml_nfalse_max2',
'Rmax','maxdist','f2f1_ratio_min','f2f1_ratio_max')
class OpticalCounterpartForm(forms.ModelForm):
class Meta:
model = OpticalCounterpart
fields = ('name','objid','t_objid','redshift','mag','ra','dec',)
class OtherNameForm(forms.ModelForm):
class Meta:
model = OtherName
fields = ('name',)
class CategoryForm(forms.ModelForm):
category = forms.ModelChoiceField(queryset=Category.objects.all(),widget=forms.Select(),required=False)
class Meta:
model = ArtSurveySource
fields = ('category',)
class ArtSurveySourceForm(forms.ModelForm):
class Meta:
model = ArtSurveySource
fields = ('name','ra','dec','flux','fluxerr_lo','fluxerr_up','nfalse','sig','ext',)
class SearchCoordsForm(forms.Form):
ra = forms.FloatField(label='RAJ2000',required=True)
dec = forms.FloatField(label='DEJ2000',required=True)
rmax = forms.FloatField(initial=40, max_value=600, min_value=1, label='Rmax',required=True,help_text="arcsec")
maxdist = forms.FloatField(initial=120, max_value=1200, min_value=60,label='Maxdist',required=True,help_text="arcsec")
class SearchNameForm(forms.Form):
name = forms.CharField(label='Name', required=True,help_text="Any part of SRGA name")
class ResolveNameForm(forms.Form):
name = forms.CharField(label='Name', max_length=65)
rmax = forms.FloatField(initial=40, max_value=600, min_value=1, label='Rmax',required=True,help_text="arcsec")
maxdist = forms.FloatField(initial=120, max_value=1200, min_value=60,label='Maxdist',required=True,help_text="arcsec")
#load_surveypath = forms.BooleanField(required=False, initial=False)
class MetaCommentForm(forms.ModelForm):
body = forms.CharField(label="", help_text="",widget=forms.Textarea(attrs={'rows':'3', 'cols':'60'}))
class Meta:
model = MetaComment
fields = ('body',)
class UserArtBasketListForm(forms.Form):
folder = forms.ModelChoiceField(queryset=ArtBasket.objects.all(),widget=forms.Select(),required=True)
"""
def __init__(self, *args, **kwargs):
qs = kwargs.pop('bars')
super(FooForm, self).__init__(*args, **kwargs)
self.fields['bar'].queryset = qs
"""