class Meta: model = XBApplication exclude = ['trainee', 'submitted', 'date_submitted', 'last_updated'] widgets = { "birthdate": DatePicker(), "grad_date": DatePicker(), "date_marriage": DatePicker(), "gender": forms.RadioSelect, "loans": forms.RadioSelect, "automobile": forms.RadioSelect, "citizenship": forms.RadioSelect, "marital": forms.RadioSelect, "spouse_attitude": forms.RadioSelect, "support_yourself": forms.CheckboxInput, "support_church": forms.CheckboxInput, "support_family": forms.CheckboxInput, "support_other": forms.CheckboxInput, 'ftta_service': forms.TextInput(attrs={ 'rows': 1, 'size': '60vh' }), 'pertinent_info': forms.Textarea(attrs={ 'rows': 4, 'cols': '100' }), }
class AnnouncementForm(forms.ModelForm): announcement_date = forms.DateField(widget=DatePicker()) announcement_end_date = forms.DateField(widget=DatePicker(), required=False) label = 'Trainees to show announcement (if on server).' trainees_show = forms.ModelMultipleChoiceField( queryset=Trainee.objects.all(), label=label, required=False, widget=TraineeSelect2MultipleInput, ) def __init__(self, *args, **kwargs): user = kwargs.pop('user', None) super(AnnouncementForm, self).__init__(*args, **kwargs) # if the user can see/modify the status, not trainee, so make it easy for approved announcements to be created by non-trainees self.fields['announcement_end_date'].widget.attrs[ 'class'] += ' hide-if-in-class hide-if-popup' attrs = {'class': 'hide-if-in-class', 'id': 'id_trainees'} self.fields['trainees_show'].widget.attrs = attrs self.fields['is_popup'].widget.attrs['class'] = 'hide-if-in-class' self.fields['is_popup'].label = 'Show announcement as a popup.' self.fields['all_trainees'].widget.attrs['class'] = 'hide-if-in-class' self.fields[ 'all_trainees'].label = "Show announcement to all trainees." self.fields[ 'trainee_comments'].label = "Trainee's comments/description for why this announcement is necessary." if not is_TA(user): del self.fields['TA_comments'] del self.fields['status'] if is_TA(user): self.fields['status'].initial = 'A' self.fields['status'].widget = forms.HiddenInput() del self.fields['trainee_comments'] def clean(self): cleaned_data = super(AnnouncementForm, self).clean() type = cleaned_data.get('type') end_date = cleaned_data.get('announcement_end_date') is_popup = cleaned_data.get('is_popup') if type == 'SERVE' and not end_date and not is_popup: self._errors["announcement_end_date"] = self.error_class( ["This is a required field."]) return cleaned_data class Meta: model = Announcement fields = [ 'type', 'is_popup', 'status', 'announcement', 'TA_comments', 'trainee_comments', 'announcement_date', 'announcement_end_date', 'all_trainees', 'trainees_show', ]
class ReportGenerateForm(forms.Form): # training_class = ModelChoiceField(Class.objects.all(), empty_label=None) date_from = forms.DateField(widget=DatePicker(), label="From: ") date_to = forms.DateField(widget=DatePicker(), label="to: ") attendancePeriodStart = forms.DateTimeField(initial=datetime.date.today) attendancePeriodEnd = forms.DateTimeField(initial=datetime.date.today) Gender = forms.CharField(initial='M') Term = forms.IntegerField(initial='1') GeneralItems = forms.CharField(max_length=500) GeneralReport = forms.CharField(max_length=500)
class Meta: model = InterimItinerary fields = [ "start", "end", "comments", ] widgets = { "start": DatePicker(), "end": DatePicker(), "comments": forms.Textarea(attrs={'rows': 2}) }
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(GenericModelForm.Meta): model = Consideration widgets = { 'attend_XB': forms.RadioSelect, 'XB_other': forms.TextInput(attrs={ 'rows': 1, 'cols': '100vh' }), 'fellowshipped': forms.RadioSelect, 'fship_date': DatePicker(), 'consideration_plan': forms.Textarea(attrs={ 'rows': 4, 'cols': '100vh', 'class': 'char_count' }), 'comments': forms.Textarea(attrs={ 'rows': 4, 'cols': '100vh', 'class': 'char_count' }), }
class Meta: model = XBAdmin exclude = [ 'term', ] widgets = { 'due_date': DatePicker(), }
class Meta: model = RoomReservation fields = [ 'group', 'date', 'start', 'end', 'room', 'frequency', 'reason' ] widgets = { "start": TimePicker(), "end": TimePicker(), "date": DatePicker() }
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
class Meta: model = ServiceException fields = [ 'name', 'desc', 'tag', 'start', 'end', 'active', 'workers', 'services', 'schedule', 'workload', 'service', ] widgets = { 'start': DatePicker(), 'end': DatePicker(), 'services': MultipleSelectFullCalendar(Service.objects.all(), 'services') }
class PassportForm(forms.Form): def __init__(self, *args, **kwargs): super(PassportForm, self).__init__(*args, **kwargs) passport_firstname = forms.CharField(required=False) passport_middlename = forms.CharField(required=False) passport_lastname = forms.CharField(required=False) citizenship = forms.CharField(required=False) expiration_date = forms.CharField(widget=DatePicker(), required=False) passport_number = forms.CharField(required=False)
def __init__(self, *args, **kwargs): super(RoomReservationForm, self).__init__(*args, **kwargs) # These fields are required for clean to be called req_keys = [ 'group', 'date', 'start', 'end', 'room', 'group_size', 'frequency', 'reason' ] for key in req_keys: self.fields[key].required = True self.fields['group'].widget.attrs[ 'placeholder'] = 'Group making reservation (will be displayed on TV)' self.fields['start'].widget = TimePicker() self.fields['end'].widget = TimePicker() self.fields['date'].widget = DatePicker()
def __init__(self, *args, **kwargs): trainee = None if 'trainee' in kwargs: trainee = kwargs.pop('trainee') super(RollAdminForm, self).__init__(*args, **kwargs) if trainee is not None: event_qs = Event.objects.none() for s in trainee.schedules.all(): event_qs = event_qs | s.events.all() self.fields['event'].queryset = event_qs self.fields['event'].widget.attrs['class'] = 'select-fk' self.fields['trainee'].widget.attrs['class'] = 'select-fk' self.fields['submitted_by'].widget.attrs['class'] = 'select-fk' self.fields['date'].widget = DatePicker()
class WebAccessRequestCreateForm(forms.ModelForm): date_expire = forms.DateField(widget=DatePicker(), label="Request expires after: ") comments = forms.CharField(widget=forms.Textarea( attrs={ 'placeholder': 'Please be as detailed and specific as possible to prevent unnecessary delays' })) def clean_date_expire(self): """ Invalid form if date expire is earlier than today """ data = self.cleaned_data['date_expire'] if datetime.now().date() > data: raise forms.ValidationError("Date expire has already passed.") return data class Meta: model = WebRequest fields = ['reason', 'minutes', 'date_expire', 'comments', 'urgent']
class Meta: model = GradAdmin exclude = [ 'term', ] widgets = { 'testimony_due_date': DatePicker(), 'consideration_due_date': DatePicker(), 'website_due_date': DatePicker(), 'outline_due_date': DatePicker(), 'remembrance_due_date': DatePicker(), 'misc_due_date': DatePicker(), 'speaking_trainees': TraineeSelect2MultipleInput(attrs={'id': 'id_trainees'}), }
class DateForm(forms.Form): start_date = forms.DateField(required=True, widget=DatePicker()) end_date = forms.DateField(required=True, widget=DatePicker())
class AnnouncementDayForm(forms.Form): announcement_day = forms.DateField(widget=DatePicker(), label="Choose a date")