Exemple #1
0
class TimeForm(forms.Form):
    """ TimeForm class """
    start_time_field = forms.TimeField(
        label='',
        widget=TimePicker(
            options={
                'format': 'HH:mm',
            },
            attrs={
                'input_toggle': True,
                'input_group': False,
            },
        ),
    )
    end_time_field = forms.TimeField(
        label='',
        widget=TimePicker(
            options={
                'format': 'HH:mm',
            },
            attrs={
                'input_toggle': True,
                'input_group': False,
            },
        ),
    )
Exemple #2
0
 class Meta:
     model = Class
     fields = (
         'course',
         'day',
         'start_time',
         'end_time',
         'room',
     )
     widgets = {
         'start_time':
         TimePicker(
             options={
                 'useCurrent': True,
                 'format':
                 'hh:mm A',  # Format settings: https://momentjs.com/docs/#/displaying/format/
             },
             attrs={
                 'append': 'far fa-clock',
             },
         ),
         'end_time':
         TimePicker(
             options={
                 'useCurrent': True,
                 'format':
                 'hh:mm A',  # Format settings: https://momentjs.com/docs/#/displaying/format/
             },
             attrs={
                 'append': 'far fa-clock',
             },
         ),
     }
Exemple #3
0
 class Meta:
     model = Activity
     fields = ['start_date', 'end_date', 'room', 'event']
     widgets = {
         'event': forms.HiddenInput(),
         'start_date': TimePicker(options={'format': 'HH:mm'}),
         'end_date': TimePicker(options={'format': 'HH:mm'}),
     }
Exemple #4
0
class SolicitudesForm(forms.ModelForm):
    fecha = forms.DateField(widget=DatePicker(options={
        'useCurrent': True,
        'format': 'DD/MM/YYYY',
        'minDate': str(date.today()),
    },
                                              attrs={
                                                  'append': 'fa fa-calendar',
                                                  'icon_toggle': True,
                                              }))

    hora_inicio = forms.TimeField(widget=TimePicker(
        options={
            'useCurrent':
            True,
            'enabledHours': [
                6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
                23
            ],
            'format':
            'HH:mm',
        },
        attrs={
            'append': 'fa fa-clock',
            'icon_toggle': True,
        },
    ), )

    hora_fin = forms.TimeField(widget=TimePicker(
        options={
            'useCurrent':
            True,
            'enabledHours': [
                6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22,
                23
            ],
            'format':
            'HH:mm',
        },
        attrs={
            'append': 'fa fa-clock',
            'icon_toggle': True,
        },
    ), )
    materiales = forms.ModelMultipleChoiceField(
        queryset=Materiales.objects.all().filter(estatus='Disponible'),
        label='Materiales',
        help_text='Ctrl para elegir más de un material')

    class Meta:
        model = Solicitudes
        fields = [
            'fecha', 'hora_inicio', 'hora_fin', 'profesor', 'materia', 'lugar',
            'materiales', 'estatus'
        ]
Exemple #5
0
class CalendarEventForm(forms.Form):
    description = forms.CharField(label='Event', max_length=100, required=True)
    date = forms.DateField(widget=forms.HiddenInput())
    start_time = forms.TimeField(label='Start Time',
                                 widget=TimePicker(options={
                                     'format': 'HH:mm',
                                     'useCurrent': True
                                 }),
                                 required=True)
    end_time = forms.TimeField(label='End Time',
                               widget=TimePicker(options={
                                   'format': 'HH:mm',
                                   'useCurrent': True
                               }),
                               required=True)
Exemple #6
0
class dateForm(forms.Form):
    date_field = forms.DateField(widget=DatePicker())
    date_field_required_with_min_max_date = forms.DateField(
        required=True,
        widget=DatePicker(options={
            'minDate': '2009-01-20',
            'maxDate': '2017-01-20',
        }, ),
        initial='2013-01-01',
    )
    """
    In this example, the date portion of defaultDate is irrelevant;
    only the time portion is used. The reason for this is that it has
    to be passed in a valid MomentJS format. This will default the time
    to be 14:56:00 (or 2:56pm).
    """
    time_field = forms.TimeField(widget=TimePicker(
        options={
            'enabledHours': [9, 10, 11, 12, 13, 14, 15, 16],
            'defaultDate': '1970-01-01T14:56:00'
        },
        attrs={
            'input_toggle': True,
            'input_group': False,
        },
    ), )
    datetime_field = forms.DateTimeField(widget=DateTimePicker(
        options={
            'useCurrent': True,
            'collapse': False,
        },
        attrs={
            'append': 'fa fa-calendar',
            'icon_toggle': True,
        }), )
Exemple #7
0
 class Meta:
     model = Tournament
     fields = ('title', 'superviser', 'start_date', 'start_time',
               'tours_amount', 'tt_category', 'tt_type')
     widgets = {
         'start_date':
         DatePicker(options={
             'useCurrent': True,
             'collapse': False,
         },
                    attrs={
                        'append': 'far fa-calendar-alt',
                        'icon_toggle': True,
                    }),
         'start_time':
         TimePicker(
             options={
                 'enabledHours': [9, 10, 11, 12, 13, 14, 15, 16],
                 'defaultDate': '1992-01-01T10:00:00'
             },
             attrs={
                 'append': 'far fa-clock',
                 'icon_toggle': True,
             },
         ),
     }
Exemple #8
0
class AgendaForms(forms.Form):
    Nome = forms.CharField(label='Nome')
    Sobrenome = forms.CharField(label='Sobrenome')
    Email = forms.EmailField(label='Email')
    Data = forms.DateField(label='Data', widget=DatePicker())
    Hora = forms.TimeField(
        label='Hora',
        widget=TimePicker(options={'enabledHours': [19, 20, 21, 22]}))
Exemple #9
0
    class Meta:

        model = DateTest
        fields = ('date', 'time', 'datetime', 'comment')

        widgets = {
            'date': DatePicker(options=dateOptions),
            'time': TimePicker(),
            'datetime': DateTimePicker(),
        }
Exemple #10
0
 class Meta:
     widgets = {
         'Opening_Time':TimePicker(
         attrs={
             'input_toggle': True,
             'input_group': True,
         },),
         'Closing_Time':forms.TimeInput(format='%I:%M %p')
     }
     model = TimeSlots
     fields = {'Day', 'Opening_Time', 'Closing_Time', 'Interval'}
Exemple #11
0
class PassagemForms(forms.Form):
    origem = forms.CharField(label='Origem', max_length=100)
    destino = forms.CharField(label='Destino', max_length=100)
    data_ida = forms.DateField(label='Data Ida',
                               widget=DatePicker(options={
                                   'minDate': 'moment',
                                   'useCurrent': True,
                               }))
    hr_ida = forms.TimeField(label='Hora ida',
                             widget=TimePicker(options={'format': 'LT'}))
    data_volta = forms.DateField(label='Data Volta', widget=DatePicker())
    hr_volta = forms.TimeField(label='Hora ida',
                               widget=TimePicker(options={'format': 'LT'}))
    data_pesquisa = forms.DateField(label='Data de Pesquisa',
                                    disabled=True,
                                    initial=datetime.today())
    classe_viagem = forms.ChoiceField(label='Classe do vôo',
                                      choices=tipos_de_classe)
    info = forms.CharField(label='Informações',
                           max_length=200,
                           required=False,
                           widget=forms.Textarea())
    email = forms.EmailField(label='E-mail', max_length=150)

    def clean(self):
        origem = self.cleaned_data.get('origem')
        destino = self.cleaned_data.get('destino')
        lst_erros = {}
        verifica_numeros(origem, 'origem', lst_erros)
        verifica_numeros(destino, 'destino', lst_erros)
        verifica_org_des(origem, destino, lst_erros)
        if lst_erros is not None:
            for erro in lst_erros:
                mensagem_erro = lst_erros[erro]
                self.add_error(erro, mensagem_erro)
        return self.cleaned_data
 class Meta:
     model = Task
     fields = ['name', 'description', 'due_date', 'executor', 'notify',
               'scheduled', 'start_date', 'end_date', 'start_time', 'monday',
               'tuesday', 'wednesday', 'thursday', 'friday', 'saturday',
               'sunday']
     widgets = {
         'due_date': DateTimePicker(
             options={
                 'useCurrent': True,
                 'collapse': True,
             },
             attrs={
                 'append': 'fa fa-calendar',
                 'icon_toggle': True,
             }
         ),
         'start_date': DatePicker(
             options={
                 'useCurrent': True,
                 'collapse': True,
             },
             attrs={
                 'append': 'fa fa-calendar',
                 'icon_toggle': True,
             }
         ),
         'end_date': DatePicker(
             options={
                 'useCurrent': True,
                 'collapse': True,
             },
             attrs={
                 'append': 'fa fa-calendar',
                 'icon_toggle': True,
             }
         ),
         'start_time': TimePicker(
             options={
                 'useCurrent': True,
                 'collapse': True,
             },
             attrs={
                 'append': 'fa fa-clock-o',
                 'icon_toggle': True,
             }
         ),
     }
Exemple #13
0
 class Meta:
     model = Report
     exclude = [
         'checked',
               ]
     widgets = {
                'diagnosis'         : Select2MultipleWidget,
                'city'              : Select2Widget,
                'type_of_visit'     : Select2Widget,
                'date_of_visit'     : DatePicker(
                                     options={
                                         'useCurrent': 'day',
                                         'maxDate': 'now',
                                         },
                                     attrs={
                                         'append': 'fa fa-calendar',
                                         'icon_toggle': True,
                                         'size': 'small'
                                         }
                                 ),
                'time_of_visit': TimePicker(
                                     options={
                                         'useCurrent': 'hour',
                                         'format': "HH:mm",
                                         'stepping': 5
                                         },
                                     attrs={
                                         'append': 'fa fa-clock-o',
                                         'icon_toggle': True,
                                         'size': 'small'
                                     }
                                 ),
                'patients_date_of_birth': DatePicker(
                                     options={
                                         'useCurrent': False,
                                         'viewMode': 'decades',
                                         'maxDate': 'now',
                                         },
                                     attrs={
                                         'append': 'fa fa-calendar',
                                         'icon_toggle': True,
                                         'size': 'small',
                                         }
                                 ),
                }
Exemple #14
0
 class Meta:
     model = Consulta
     fields = ['cpf', 'paciente', 'data', 'hora', 'medico']
     labels = {
         'data': 'Data:',
         'medico': 'Médicos :',
         'hora': 'Horário:',
         'paciente': 'Paciente:'
     }
     widgets = {
         'data':
         DatePicker(options={
             'minDate': 'moment',
             'daysOfWeekDisabled': [0, 6],
             'format': 'L',
             'ignoreReadonly': True,
         },
                    attrs={
                        'readonly': 'readonly',
                        'append': 'fa fa-calendar',
                        'icon_toggle': True,
                        'class': 'dt_hr',
                    }),
         'hora':
         TimePicker(
             options={
                 'format': 'LT',
                 'enabledHours': [9, 10, 11, 12, 13, 14, 15, 16, 17],
                 'stepping': 30,
                 'defaultDate': '1970-01-01T14:56',
                 'ignoreReadonly': True,
             },
             attrs={
                 'readonly': 'readonly',
                 'input_toggle': True,
                 'input_group': True,
                 'append': 'far fa-clock',
                 'class': 'dt_hr',
             },
         ),
     }
Exemple #15
0
 class Meta:
     model = Trabajo
     fields = [
         'contador',
         'cliente',
         'tipo',
         'fecha_inicio',
         'duracion',
         'descripcion',
     ]
     widgets = {
         'fecha_inicio':
         DateTimePicker(options={
             'format': "DD/MM/YYYY H:mm",
             'stepping': 1,
         },
                        attrs={
                            'append': 'fa fa-calendar',
                            'icon_toggle': True,
                        }),
         'duracion':
         TimePicker(
             options={
                 'format': "H:mm",
                 'stepping': 5,
                 'defaultDate': '1970-01-01T00:00:00'
             },
             attrs={
                 'required': True,
                 'append': 'fa fa-clock-o',
             },
         ),
         'descripcion':
         forms.Textarea(attrs={
             'rows': 3,
             'cols': 21
         }),
     }
Exemple #16
0
 class Meta:
     model = TripItinerary
     fields = [
         'date_of_departure',
         'time_of_departure',
         'city_of_departure',
         'destination',
         'mode_of_travel',
         'comment',
     ]
     widgets = {
         'date_of_departure':
         DatePicker(attrs={
             'append': 'fa fa-calendar',
         }),
         'time_of_departure':
         TimePicker(options={
             'format': 'HH:mm',
             'useCurrent': False,
         },
                    attrs={
                        'append': 'fa fa-clock',
                    })
     }
Exemple #17
0
    class Meta:
        model = Activity
        fields = ['name', 'startdate', 'endtdate', 'starttime', 'endtime', 'teachers', 'signup', 'locations', 'intro', 'other', 'status', 'categorys']
        widgets = {
            'name': forms.TextInput(attrs={'class': 'form-control', 'placeholder': '請輸入名稱', 'aria-describedby': 'usernameHelp'}), 
            'startdate': DatePicker(attrs={'append': 'fa fa-calendar'}, options={'locale': 'zh-tw', 'viewMode': 'years'}),
            'endtdate': DatePicker(attrs={'append': 'fa fa-calendar'}, options={'locale': 'zh-tw', 'viewMode': 'years'}),
            'starttime': TimePicker(attrs={'append': 'far fa-clock'}, options={'locale': 'zh-tw', 'format': 'HH:mm'}),
            'endtime': TimePicker(attrs={'append': 'far fa-clock'}, options={'locale': 'zh-tw', 'format': 'HH:mm'}),
            'teachers': forms.SelectMultiple(attrs={'class': 'selectpicker form-control'}),
            'signup': forms.URLInput(attrs={'class': 'form-control', 'placeholder': '請輸入報名連結'}),
            'locations': forms.Select(attrs={'class': 'selectpicker show-tick form-control', 'data-live-search': 'true'}),
            'intro': forms.Textarea(attrs={'class': 'form-control', 'placeholder': '請輸入簡介'}),
            'other': forms.Textarea(attrs={'class': 'form-control', 'placeholder': '請輸入其他', 'aria-describedby': 'otherHelp'}),
            'status': forms.Select(attrs={'class': 'form-control'}),
            'categorys': forms.Select(attrs={'class': 'form-control'}),
        }
        labels = {
            'name': _('名稱'), 
            'startdate': _('開始日期'), 
            'endtdate': _('結束日期'), 
            'starttime': _('開始時間'), 
            'endtime': _('結束時間'), 
            'teachers': _('講師'),  
            'signup': _('報名連結'), 
            'locations': _('地點'), 
            'intro': _('簡介'), 
            'other': _('其他'), 
            'status': _('狀態'), 
            'categorys': _('類別'),
        }
        help_texts = {
            'other': _('補充事項'),
        }
        error_messages = {
            'name': {
                'required': _('必須填寫名稱'),
                'unique': _('這個名稱以經被使用了'),
                'max_length': _('名稱太長了'),
            }, 
            'startdate': {
                'required': _('必須要有開始日期'),
                'invalid': _('你的開始日期看起來怪怪的'),
            }, 
            'endtdate': {
                'required': _('必須要有結束日期'),
                'invalid': _('你的結束日期看起來怪怪的'),
            }, 
            'starttime': {
                'required': _('必須要有開始時間'),
                'invalid': _('你的開始時間看起來怪怪的'),
            }, 
            'endtime': {
                'required': _('必須要有結束時間'),
                'invalid': _('你的結束時間看起來怪怪的'),
            }, 
            'teachers': {
                'required': _('必須填寫講師'),
            }, 
            'signup': {
                'max_length': _('報名網址太長了'),
                'invalid': _('報名網址看起來怪怪的'),
            }, 
            'locations': {
                'required': _('必須填寫地點'),
            }, 
            'intro': {

            }, 
            'other': {

            }, 
            'status': {
                'required': _('必須選擇狀態'),
                'invalid': _('你的狀態看起來怪怪的'),
            }, 
            'categorys': {

            }, 
        }
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        now = datetime.datetime.now()
        range_time = 60
        now_with_range = now + datetime.timedelta(minutes=range_time)
        self.fields['room'].required = True
        self.fields['room'].label = _('room').capitalize()
        self.fields['date'] = forms.DateField(
            label=_('date').capitalize(),
            widget=DatePicker(
                options={
                    'useCurrent': True,
                },
                attrs={'placeholder': formats.date_format(now,
                                                          use_l10n=True)}),
        )
        self.fields['start_time'] = forms.TimeField(
            label=_('start time').capitalize(),
            widget=TimePicker(options={
                'useCurrent': True,
                'format': 'HH:mm',
            },
                              attrs={'placeholder': now.strftime("%H:%M")}),
        )
        self.fields['end_time'] = forms.TimeField(
            label=_('end time').capitalize(),
            widget=TimePicker(
                options={
                    'format': 'HH:mm',
                },
                attrs={'placeholder': now_with_range.strftime("%H:%M")}),
        )
        self.fields['notes'].label = _('notes').capitalize()
        self.fields['notes'].widget.attrs = {
            'rows': 2,
            'columns': 10,
            'placeholder': _('notes')
        }
        self.fields['trainer'].label = _('trainer').capitalize()
        self.fields['trainer'].required = False
        self.fields['trainer'].widget.attrs['readonly'] = True

        self.fields['state'].label = _('state').capitalize()

        self.fields['lectures'].label = _('lectures').capitalize()
        self.fields['lectures'].widget = forms.CheckboxSelectMultiple()
        self.fields['lectures'].required = False

        if kwargs.get('initial') is not None:
            if kwargs.get('initial').get('lectures') is not None:
                self.fields['lectures'].choices = kwargs['initial']['lectures']

        self.helper = FormHelper()
        self.helper.form_show_errors = True
        self.helper.form_id = 'form_new_lesson'

        self.helper.layout = Layout(
            Row(Column('room', css_class='form-group col-md-6 mb-0'),
                Column('trainer', css_class='form-group col-md-6 mb-0'),
                css_class='form-row'),
            Row(Column('date', css_class='form-group col-md-6 mb-0'),
                Column('state', css_class='form-group col-md-6 mb-0'),
                css_class='form-row'),
            Row(Column('start_time', css_class='form-group col-md-6 mb-0'),
                Column('end_time', css_class='form-group col-md-6 mb-0'),
                css_class='form-row'),
            Row(Column('lectures', css_class='form-group col-md-6 mb-0'),
                Column('notes', css_class='form-group col-md-6 mb-0'),
                css_class='form-row'),
            Submit('submit', _('Save'), css_class='btn-success'))
Exemple #19
0
class BookingCalendarForm(forms.ModelForm):
    today = str(timezone.now())[0:10]
    year = int(today[0:4])
    maxDay = str(year + 1) + today[4:8] + '28'
    init_st = today
    init_en = today
    # def __init__(self, *args, **kwargs):
    # 	self.init_st = kwargs.pop('fr')
    # 	self.init_en = kwargs.pop('to')
    # 	super().__init__(*args, **kwargs)
    start_date = forms.DateField(
        widget=DatePicker(
            options={
                'minDate': today,
                'maxDate': maxDay,
                'daysOfWeekDisabled': [0],
            },
            attrs={
                'input_toggle': True,
                'append': 'fa fa-calendar',
                'icon_toggle': True,
                'class': 'sDate',
            },
        ),
        initial=today,
    )
    end_date = forms.DateField(
        required=True,
        widget=DatePicker(
            options={
                'minDate': today,
                'maxDate': maxDay,
                'daysOfWeekDisabled': [0],
            },
            attrs={
                'input_toggle': True,
                'append': 'fa fa-calendar',
                'icon_toggle': True,
                'class': 'sDate',
            },
        ),
        initial=today,
    )
    print(today)

    start_time = forms.TimeField(
        required=True,
        widget=TimePicker(
            options={
                'enabledHours':
                [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],
                'defaultDate':
                today,
                'stepping':
                30,
            },
            attrs={
                'input_toggle': True,
                'append': 'fa fa-calendar',
                'icon_toggle': True,
                'class': 'sDate',
            },
        ),
        initial=datetime(2020, 4, 3, 12, 0, 0),
    )
    end_time = forms.TimeField(
        required=True,
        widget=TimePicker(
            options={
                'enabledHours':
                [8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21],
                'defaultDate':
                today,
                'stepping':
                30,
            },
            attrs={
                'input_toggle': True,
                'append': 'fa fa-calendar',
                'icon_toggle': True,
                'class': 'sDate',
            },
        ),
        initial='12:00:00')

    def clean_end_date(self):
        startDate = self.cleaned_data.get('start_date')
        endDate = self.cleaned_data.get('end_date')
        if startDate > endDate:
            raise forms.ValidationError('Start date should be before end date')
        delta = endDate - startDate
        print(delta)
        if delta.days > 6:
            raise forms.ValidationError('You cannot book for a week or more.')
        return endDate

    def clean_end_time(self):
        venue = self.cleaned_data.get('venue')
        startDate = self.cleaned_data.get('start_date')
        endDate = self.cleaned_data.get('end_date')
        if endDate == None:
            raise forms.ValidationError('')
        startTime = self.cleaned_data.get('start_time')
        endTime = self.cleaned_data.get('end_time')
        print(endDate)
        for b in Booking.objects.all():
            ven = b.venue
            print(ven)
        venBook = Booking.objects.filter(venue=venue)
        if venue == "Conference Room A" or venue == "Conference Room B":
            venBook = venBook | Booking.objects.filter(
                venue="Joined Conference Room")
        elif venue == "Joined Conference Room":
            venBook = venBook | Booking.objects.filter(
                venue="Conference Room A") | Booking.objects.filter(
                    venue="Conference Room B")
        print("All of " + str(venBook))
        bookingLeft = venBook.filter(startDate__lte=startDate)
        if len(bookingLeft) > 0:
            bookingLeft = bookingLeft.filter(endDate__gte=startDate)
        bookingRight = venBook.filter(endDate__gte=endDate)
        if len(bookingRight) > 0:
            bookingRight = bookingRight.filter(startDate__lte=endDate)
        bookingMid = venBook.filter(startDate__gte=startDate)
        if len(bookingMid) > 0:
            bookingMid = bookingMid.filter(endDate__lte=endDate)

        print(
            str(bookingLeft) + " and " + str(bookingRight) + " and " +
            str(bookingMid))
        conf = bookingRight | bookingLeft | bookingMid
        print(conf)
        confLeft = conf.filter(startTime__lte=startTime).filter(
            endTime__gte=startTime)
        confRight = conf.filter(endTime__gte=endTime).filter(
            startTime__lte=endTime)
        confMid = conf.filter(startTime__gte=startTime).filter(
            endTime__lte=endTime)
        finConf = confRight | confLeft | confMid
        print("CONFLICT FOUND ON: " + str(finConf))
        if len(finConf) > 0:
            if venue == 'Coworking Space':
                timeslots = {}
                for b in finConf:
                    start = b.startDate
                    end = b.endDate
                    stop = False
                    while stop == False:
                        stTime = b.startTime
                        enTime = b.endTime
                        timesl = str(start) + " " + str(stTime)
                        while stTime != enTime:
                            exist = timeslots.get(timesl)
                            if exist == None:
                                timeslots[timesl] = len(
                                    b.attendee.split(", ")) - 1
                            else:
                                timeslots[timesl] = exist + len(
                                    b.attendee.split(", ")) - 1
                            stTime = (datetime.combine(
                                start,
                                time(int(stTime.strftime('%H')),
                                     int(stTime.strftime('%M')))) +
                                      timedelta(minutes=30)).time()
                        if str(start) == str(end):
                            stop = True
                        start = start + timedelta(days=1)
                for timeslot in timeslots:
                    if timeslots[timeslot] >= Venue.objects.get(
                            name="Coworking Space").cap:
                        raise forms.ValidationError('The coworking space in ' +
                                                    timeslot +
                                                    ' is already full')
            else:
                confStartDate = finConf[0].startDate
                confEndDate = finConf[0].endDate
                confStartTime = finConf[0].startTime
                confEndTime = finConf[0].endTime
                raise forms.ValidationError(
                    'At least one conflict scheduled at ' +
                    str(confStartDate) + " to " + str(confEndDate) + " on " +
                    str(confStartTime) + "-" + str(confEndTime))
        if startTime >= endTime:
            raise forms.ValidationError('Start time should be before end time')

        return endTime

    class Meta:
        model = Booking
        fields = [
            'venue',
        ]