def __init__(self, *args, **kwargs): super(GroupSlipAdminForm, self).__init__(*args, **kwargs) self.fields['trainee'].widget.attrs['class'] = 'select-fk' self.fields['TA'].widget.attrs['class'] = 'select-fk' self.fields['TA_informed'].widget.attrs['class'] = 'select-fk' self.fields['finalized'].widget = DatetimePicker() self.fields['start'].widget = DatetimePicker() self.fields['end'].widget = DatetimePicker()
class Meta: model = GospelTrip fields = "__all__" labels = { 'name': 'Gospel Trip Name', } widgets = { 'open_time': DatetimePicker(), 'close_time': DatetimePicker() }
class Meta: model = HCSurveyAdmin fields = [ "open_time", "close_time", "open_survey", ] widgets = { "open_time": DatetimePicker(), "close_time": DatetimePicker(), }
class Meta: model = ServiceRoll fields = [ "start_datetime", "end_datetime", "task_performed", ] widgets = { "start_datetime": DatetimePicker(), "end_datetime": DatetimePicker(), "task_performed": forms.Textarea() }
class Meta: model = InterimIntentionsAdmin fields = [ "open_time", "close_time", "date_1yr_return", "date_2yr_return", "earliest_arrival_date", "term_begin_date" ] widgets = { "open_time": DatetimePicker(), "close_time": DatetimePicker(), "date_1yr_return": DatetimePicker(), "date_2yr_return": DatetimePicker(), "earliest_arrival_date": DatePicker(), "term_begin_date": DatePicker() }
class Meta: model = Discipline fields = '__all__' widgets = { 'due': DatetimePicker(), 'missed_service': forms.Textarea(attrs={'rows': 1}), }
def __init__(self, *args, **kwargs): if 'gospel_trip__pk' in kwargs: gospel_trip = kwargs.pop('gospel_trip__pk') super(AnswerForm, self).__init__(*args, **kwargs) self.fields['response'] = forms.CharField(widget=forms.Textarea) if self.instance.question: answer_type = self.instance.question.answer_type req = self.instance.question.answer_required if answer_type in ["text", "None", "", None]: pass elif answer_type == 'destinations': # this is a special case choices = [('', '---------')] choices.extend([ (d['id'], d['name']) for d in Destination.objects.filter( gospel_trip=gospel_trip).values('id', 'name') ]) self.fields['response'] = forms.ChoiceField(choices=choices, required=req) elif answer_type == 'date': self.fields['response'] = forms.DateField(widget=DatePicker()) elif answer_type == 'datetime': self.fields['response'] = forms.DateTimeField( widget=DatetimePicker()) elif answer_type == 'airports': self.fields['response'].widget.attrs = { 'class': 'airport-field' } elif answer_type == 'airlines': self.fields['response'].widget.attrs = { 'class': 'airline-field' } else: try: opts = AnswerChoice.objects.get( name=answer_type).options.split(',') choices = [('', '---------')] choices.extend([(c, c) for c in opts]) self.fields['response'] = forms.ChoiceField( choices=choices, required=req) except AnswerChoice.DoesNotExist: pass if self.instance.question.section.show == 'READ ONLY': self.fields['response'].widget.attrs['disabled'] = 'true' self.fields['response'].required = req
def __init__(self, *args, **kwargs): trainee = Trainee.objects.filter(groups__name='attendance_monitors').first() if 'trainee' in kwargs: trainee = kwargs.pop('trainee') super(IndividualSlipAdminForm, self).__init__(*args, **kwargs) self.fields['rolls'].queryset = trainee.rolls.all() self.fields['TA'].queryset = User.objects.filter(groups__name='regular_training_assistant') self.fields['TA_informed'].queryset = User.objects.filter(groups__name='regular_training_assistant') self.fields['trainee'].widget.attrs['class'] = 'select-fk' self.fields['TA'].widget.attrs['class'] = 'select-fk' self.fields['TA_informed'].widget.attrs['class'] = 'select-fk' self.fields['finalized'].widget = DatetimePicker()
class FlightForm(forms.Form): def __init__(self, *args, **kwargs): super(FlightForm, self).__init__(*args, **kwargs) choices = [('', '--------'), ('INO', 'International Outbound'), ('INR', 'International Return'), ('IMO', 'Intermediate Outbound'), (('IMR', 'Intermediate Return'))] flight_type = forms.ChoiceField(choices=choices) number = forms.CharField(required=False) airline = forms.CharField(required=False) departure_airport = forms.CharField(required=False) departure_datetime = forms.CharField(widget=DatetimePicker(), required=False) arrival_airport = forms.CharField(required=False) arrival_datetime = forms.CharField(widget=DatetimePicker(), required=False)
class Meta: model = Discipline exclude = ('trainee', ) widgets = {'due': DatetimePicker()}