def field(self): from wagtail.admin.widgets import AdminDateInput field_kwargs = { 'widget': AdminDateInput(format=self.format), } field_kwargs.update(self.field_options) return forms.DateField(**field_kwargs)
def __init__(self, attrs=None): freqOptions = [(DAILY, _("Daily")), (WEEKLY, _("Weekly")), (MONTHLY, _("Monthly")), (YEARLY, _("Yearly"))] ordOptions1 = [(1, toTheOrdinal(1)), (2, toTheOrdinal(2)), (3, toTheOrdinal(3)), (4, toTheOrdinal(4)), (5, toTheOrdinal(5)), (-1, toTheOrdinal(-1)), (EVERY_DAY, _("Every")), (SAME_DAY, _("The Same"))] ordOptions2 = [(None, ""), (1, toTheOrdinal(1)), (2, toTheOrdinal(2)), (3, toTheOrdinal(3)), (4, toTheOrdinal(4)), (5, toTheOrdinal(5)), (-1, toTheOrdinal(-1))] dayOptions1 = enumerate(WEEKDAY_ABBRS) dayOptions2 = [(None, "")] + list(enumerate(WEEKDAY_NAMES)) dayOptions3 = list(enumerate(WEEKDAY_NAMES)) +\ [(DAY_OF_MONTH, _("Day of the month"))] monthOptions = enumerate(MONTH_ABBRS[1:], 1) numAttrs = {'min': 1, 'max': 366} disableAttrs = {'disabled': True} if attrs: numAttrs.update(attrs) disableAttrs.update(attrs) widgets = [AdminDateInput(attrs=attrs), Select(attrs=attrs, choices=freqOptions), #1 NumberInput(attrs=numAttrs), CheckboxSelectMultiple(attrs=attrs, choices=dayOptions1), NumberInput(attrs=numAttrs), AdminDateInput(attrs=attrs), #5 Select(attrs=attrs, choices=ordOptions1), Select(attrs=attrs, choices=dayOptions3), Select(attrs=disableAttrs, choices=ordOptions2), Select(attrs=disableAttrs, choices=dayOptions2), Select(attrs=disableAttrs, choices=ordOptions2), #10 Select(attrs=disableAttrs, choices=dayOptions2), CheckboxSelectMultiple(attrs=attrs, choices=monthOptions) ] super().__init__(widgets, attrs)
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['page_chooser'].widget = AdminPageChooser() self.fields['image_chooser'].widget = AdminImageChooser() self.fields['document_chooser'].widget = AdminDocumentChooser() self.fields['snippet_chooser'].widget = AdminSnippetChooser(Page) self.fields['date'].widget = AdminDateInput() self.fields['time'].widget = AdminTimeInput() self.fields['datetime'].widget = AdminDateTimeInput() self.fields['auto_height_text'].widget = AdminAutoHeightTextInput() self.fields['default_rich_text'].widget = get_rich_text_editor_widget('default')
def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields["page_chooser"].widget = AdminPageChooser() self.fields["image_chooser"].widget = AdminImageChooser() self.fields["document_chooser"].widget = AdminDocumentChooser() self.fields["snippet_chooser"].widget = AdminSnippetChooser(Page) self.fields["date"].widget = AdminDateInput() self.fields["time"].widget = AdminTimeInput() self.fields["datetime"].widget = AdminDateTimeInput() self.fields["auto_height_text"].widget = AdminAutoHeightTextInput() self.fields["default_rich_text"].widget = get_rich_text_editor_widget( "default") self.fields["switch"].widget = SwitchInput() self.fields["disabled_switch"].widget = SwitchInput( attrs={"disabled": True})
def __init__(self, attrs=None): freqOptions = [(3, "Daily"), (2, "Weekly"), (1, "Monthly"), (0, "Yearly")] ordOptions1 = [(1, "The First"), (2, "The Second"), (3, "The Third"), (4, "The Fourth"), (5, "The Fifth"), (-1, "The Last"), (_EveryDay, "Every"), (_SameDay, "The Same")] ordOptions2 = [(None, ""), (1, "The First"), (2, "The Second"), (3, "The Third"), (4, "The Fourth"), (5, "The Fifth"), (-1, "The Last")] dayOptions1 = enumerate(calendar.day_abbr) dayOptions2 = [(None, "")] + list(enumerate(calendar.day_name)) dayOptions3 = list(enumerate(calendar.day_name)) +\ [(_DayOfMonth, "Day of the month")] monthOptions = enumerate(calendar.month_abbr[1:], 1) numAttrs = {'min': 1, 'max': 366} disableAttrs = {'disabled': True} if attrs: numAttrs.update(attrs) disableAttrs.update(attrs) widgets = [ AdminDateInput(attrs=attrs), Select(attrs=attrs, choices=freqOptions), #1 NumberInput(attrs=numAttrs), CheckboxSelectMultiple(attrs=attrs, choices=dayOptions1), NumberInput(attrs=numAttrs), AdminDateInput(attrs=attrs), #5 Select(attrs=attrs, choices=ordOptions1), Select(attrs=attrs, choices=dayOptions3), Select(attrs=disableAttrs, choices=ordOptions2), Select(attrs=disableAttrs, choices=dayOptions2), Select(attrs=disableAttrs, choices=ordOptions2), #10 Select(attrs=disableAttrs, choices=dayOptions2), CheckboxSelectMultiple(attrs=attrs, choices=monthOptions) ] super().__init__(widgets, attrs)
class UnitReportingForm(forms.Form): l = 'Filename' filename = forms.CharField(label=l, required=True) l = 'Live pages only' live = forms.BooleanField(label=l, required=False) l = 'Display in campus directory set' display_in_campus_directory = forms.BooleanField(label=l, required=False) v = RegexValidator(r'^[0-9]{8}$', 'Please enter dates in YYYYMMDD format.') l = 'Latest revision created at YYYYMMDD' latest_revision_created_at = forms.CharField(label=l, required=False, validators=[v], widget=AdminDateInput())
class CustomUserEditForm(UserEditForm): date_joined = forms.DateField( widget=AdminDateInput(), help_text="Date joined", )
def setUp(self): self.newDate = AdminDateInput().attrs.get('autocomplete', "new-date")
def __init__(self, attrs=None): widgets = (AdminDateInput(attrs={'placeholder': _("Date from")}), AdminDateInput(attrs={'placeholder': _("Date to")})) super().__init__(widgets, attrs)
class EmergencyPowerNotificationForm(forms.Form): date = forms.DateField(widget=AdminDateInput()) start = forms.TimeField(widget=AdminTimeInput()) end = forms.TimeField(widget=AdminTimeInput())
class AlarmNotificationForm(forms.Form): date = forms.DateField(widget=AdminDateInput()) start = forms.TimeField(widget=AdminTimeInput()) end = forms.TimeField(widget=AdminTimeInput())