예제 #1
0
파일: lco.py 프로젝트: bryanmiller/tom_base
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Add fields for each available filter as specified in the filters property
        for filter_name in self.filters:
            self.fields[filter_name] = FilterField(label=filter_name,
                                                   required=False)

        # Massage cadence form to be SNEx-styled
        self.fields['cadence_strategy'] = forms.ChoiceField(
            choices=[('', 'Once in the next'),
                     ('ResumeCadenceAfterFailureStrategy', 'Repeating every')],
            required=False,
        )
        for field_name in [
                'exposure_time', 'exposure_count', 'start', 'end', 'filter'
        ]:
            self.fields.pop(field_name)
        if self.fields.get('groups'):
            self.fields['groups'].label = 'Data granted to'

        self.helper.layout = Layout(
            Div(Column('name'),
                Column('cadence_strategy'),
                Column('cadence_frequency'),
                css_class='form-row'),
            Layout('facility', 'target_id', 'observation_type'), self.layout(),
            self.button_layout())
예제 #2
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Add fields for each available filter as specified in the filters property
        for filter_name in self.filters:
            self.fields[filter_name] = FilterField(label=filter_name,
                                                   required=False)

        # Massage cadence form to be SNEx-styled
        self.fields['cadence_strategy'].widget = forms.HiddenInput()
        self.fields['cadence_strategy'].required = False
        self.fields['cadence_frequency'].required = True
        self.fields['cadence_frequency'].widget.attrs['readonly'] = False
        self.fields['cadence_frequency'].widget.attrs['help_text'] = 'in hours'

        for field_name in [
                'exposure_time', 'exposure_count', 'start', 'end', 'filter'
        ]:
            self.fields.pop(field_name)
        if self.fields.get('groups'):
            self.fields['groups'].label = 'Data granted to'

        self.helper.layout = Layout(
            Div(Column('name'),
                Column('cadence_type'),
                Column('cadence_frequency'),
                css_class='form-row'),
            Layout('facility', 'target_id', 'observation_type'), self.layout(),
            self.button_layout())
예제 #3
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)

        # Remove labels from several filter fields
        for filter_name in self.filters:
            self.fields[filter_name] = FilterField(label='', required=False)

        # Do not give choices for proposals
        self.fields['proposal'] = forms.CharField()

        # Massage cadence form to be SNEx-styled
        self.fields['name'].label = ''
        self.fields['name'].widget.attrs['placeholder'] = 'Name'
        self.fields['cadence_strategy'] = forms.ChoiceField(choices=[
            ('', 'Once in the next'),
            ('ResumeCadenceAfterFailureStrategy', 'Repeating every')
        ],
                                                            required=False,
                                                            label='')

        self.fields['instrument_type'] = forms.ChoiceField(
            choices=self.instrument_choices(),
            initial=('1M0-SCICAM-SINISTRO', '1.0 meter Sinistro'))

        self.helper.layout = Layout(
            Div(Column('name'),
                Column('cadence_strategy'),
                Column(AppendedText('cadence_frequency', 'Days')),
                css_class='form-row'),
            Layout('facility', 'target_id', 'observation_type'), self.layout(),
            self.button_layout())
예제 #4
0
    def __init__(self, *args, **kwargs):
        super(PhotSchedulingForm, self).__init__(*args, **kwargs)
        for f in self.filters:
            if f in kwargs.get('initial', ''):
                self.fields[f] = FilterField(label=f[0], required=False)

        self.fields['cadence_frequency'].widget.attrs['class'] = 'cadence-input'
        self.fields['delay_start'].widget.attrs['class'] = 'delay-start-input'
예제 #5
0
    def __init__(self, *args, **kwargs):
        super(LCOPhotometricSequenceForm, self).__init__(*args, **kwargs)

        # Add fields for each available filter as specified in the filters property
        for filter_name in self.filters:
            self.fields[filter_name] = FilterField(
                label='', initial=InitialValue(filter_name), required=False)

        # Set default proposal to GSP
        proposal_choices = self.proposal_choices()
        initial_proposal = ''
        for choice in proposal_choices:
            if 'Global Supernova Project' in choice[1]:
                initial_proposal = choice
        self.fields['proposal'] = forms.ChoiceField(choices=proposal_choices,
                                                    initial=initial_proposal)

        # Massage cadence form to be SNEx-styled
        self.fields['name'].label = ''
        self.fields['name'].widget.attrs['placeholder'] = 'Name'
        self.fields['cadence_strategy'] = forms.ChoiceField(choices=[
            ('', 'Once in the next'),
            ('ResumeCadenceAfterFailureStrategy', 'Repeating every')
        ],
                                                            required=False,
                                                            label='')
        for field_name in [
                'exposure_time', 'exposure_count', 'start', 'end', 'filter'
        ]:
            self.fields.pop(field_name)

        if not settings.TARGET_PERMISSIONS_ONLY:
            self.fields['groups'] = forms.ModelMultipleChoiceField(
                Group.objects.all(),
                initial=Group.objects.filter(name__in=settings.DEFAULT_GROUPS),
                required=False,
                widget=forms.CheckboxSelectMultiple,
                label='Data granted to')

        self.fields['instrument_type'] = forms.ChoiceField(
            choices=self.instrument_choices(),
            initial=('1M0-SCICAM-SINISTRO', '1.0 meter Sinistro'))
        #self.fields['name'].widget = forms.HiddenInput()
        #self.fields['proposal'] = forms.ChoiceField(choices=self.proposal_choices(), label='Proposal')

        # Add the Muscat fields
        self.fields['guider_mode'] = forms.ChoiceField(
            choices=self.mode_choices('guiding'), required=False)

        self.fields['exposure_mode'] = forms.ChoiceField(
            choices=self.mode_choices('exposure'), required=False)

        self.fields['diffuser_g_position'] = forms.ChoiceField(
            choices=self.diffuser_position_choices(channel='g'),
            label='g',
            required=False)
        self.fields['diffuser_r_position'] = forms.ChoiceField(
            choices=self.diffuser_position_choices(channel='r'),
            label='r',
            required=False)
        self.fields['diffuser_i_position'] = forms.ChoiceField(
            choices=self.diffuser_position_choices(channel='i'),
            label='i',
            required=False)
        self.fields['diffuser_z_position'] = forms.ChoiceField(
            choices=self.diffuser_position_choices(channel='z'),
            label='z',
            required=False)

        self.helper.layout = Layout(
            Div(Column('name'),
                Column('cadence_strategy'),
                Column(AppendedText('cadence_frequency', 'Days')),
                css_class='form-row'),
            Layout('facility', 'target_id', 'observation_type'), self.layout(),
            self.button_layout())
예제 #6
0
 def __init__(self, *args, **kwargs):
     super(PhotSchedulingForm, self).__init__(*args, **kwargs)
     for f in self.filters:
         if f in kwargs.get('initial', ''):
             self.fields[f] = FilterField(label=f[0], required=False)