def __init__(self, *args, **kwargs):
        self.instance = kwargs.pop('instance')
        self.education_group_year = kwargs.pop('education_group_yr')

        super().__init__(*args, **kwargs)
        if self.instance:
            self.fields['range_date'].initial = (
                convert_datetime_to_date(self.instance.start_date),
                convert_datetime_to_date(self.instance.end_date))
            self.fields['range_date'].widget.add_min_max_value(self.instance.academic_calendar.start_date,
                                                               self.instance.academic_calendar.end_date)
    def __init__(self, *args, **kwargs):
        self.instance = kwargs.pop('instance')
        self.education_group_year = kwargs.pop('education_group_yr')

        super().__init__(*args, **kwargs)
        if self.instance:
            self.fields['range_date'].initial = (
                convert_datetime_to_date(self.instance.start_date),
                convert_datetime_to_date(self.instance.end_date))
            self.fields['range_date'].widget.add_min_max_value(self.instance.academic_calendar.start_date,
                                                               self.instance.academic_calendar.end_date)
    def _init_fields(self):
        for name, field in self.fields.items():
            oyc = self._get_offer_year_calendar(name)
            if not oyc:
                continue

            if isinstance(field, DateRangeField):
                field.initial = (convert_datetime_to_date(oyc.start_date),
                                 convert_datetime_to_date(oyc.end_date))

            elif isinstance(field, forms.DateField):
                field.initial = convert_datetime_to_date(oyc.start_date)

            else:
                field.initial = oyc.start_date

            field.widget.add_min_max_value(oyc.academic_calendar.start_date, oyc.academic_calendar.end_date)
    def _init_fields(self):
        for name, field in self.fields.items():
            oyc = self._get_offer_year_calendar(name)
            if not oyc:
                continue

            if isinstance(field, DateRangeField):
                field.initial = (convert_datetime_to_date(oyc.start_date),
                                 convert_datetime_to_date(oyc.end_date))

            elif isinstance(field, forms.DateField):
                field.initial = convert_datetime_to_date(oyc.start_date)

            else:
                field.initial = oyc.start_date

            field.widget.add_min_max_value(oyc.academic_calendar.start_date, oyc.academic_calendar.end_date)
Esempio n. 5
0
 def test_convert_datetime_to_date(self):
     today = datetime.datetime.today()
     date_today = convert_datetime_to_date(today)
     self.assertEqual(type(date_today), datetime.date)
     self.assertEqual(date_today, today.date())
Esempio n. 6
0
 def test_convert_datetime_to_date(self):
     today = datetime.datetime.today()
     date_today = convert_datetime_to_date(today)
     self.assertEqual(type(date_today), datetime.date)
     self.assertEqual(date_today, today.date())