def test_get_context(self): dp_input = DatePickerInput() context = dp_input.get_context("input_name", "2018-04-12", {}) self.assertEqual(context["widget"]["name"], "input_name") self.assertEqual(context["widget"]["value"], "2018-04-12") self.assertTrue(context["widget"]["attrs"]["data-dp-config"] == json_dumps(dp_input.config))
class Meta: model = Medication fields = ["from_date", "end_date", "type_medication", "comment", "attachment"] widgets = { "from_date": DatePickerInput(options={"locale": "fr", "format": "DD/MM/YYYY"}).start_of('medic days'), "end_date": DatePickerInput(options={"locale": "fr", "format": "DD/MM/YYYY"}).end_of('medic days'), }
class Meta: model = Film fields = [ 'filmstock', 'exposed_at', 'format', 'status', 'date_loaded', 'date_processed', 'camera', 'title', 'frames', 'developer', 'developer_previous_uses', 'development_time', 'development_temperature', 'development_compensation', 'development_notes', 'bulk_film', 'bulk_film_loaded', 'film_batch', 'expiry_date', 'purchase_date', 'price', 'processed_by', 'archive' ] widgets = { 'date_loaded': DatePickerInput(format='%Y-%m-%d'), 'date_processed': DatePickerInput(format='%Y-%m-%d'), 'purchase_date': DatePickerInput(format='%Y-%m-%d'), 'bulk_film_loaded': DatePickerInput(format='%Y-%m-%d'), 'expiry_date': MonthPickerInput(format='%Y-%m-01'), 'dev_time': TimePickerInput(format='%H:%M:%S', options={ "useCurrent": False, "showTodayButton": False, }), }
class Meta: model = Participant exclude = ["uuid", "semester", "registration_time", "transportation"] widgets = { "paid": DatePickerInput(format="%Y-%m-%d"), "payment_deadline": DatePickerInput(format="%Y-%m-%d"), "non_liability": DatePickerInput(format="%Y-%m-%d"), }
class Meta: model = Flash fields = [ 'flashmodel', 'serial', 'own', 'acquired', 'cost', 'lost', 'lost_price' ] widgets = { 'acquired': DatePickerInput(format='%Y-%m-%d'), 'lost': DatePickerInput(format='%Y-%m-%d'), }
class Meta: model = Camera fields = [ 'cameramodel', 'acquired', 'cost', 'source', 'serial', 'datecode', 'manufactured', 'own', 'notes', 'lost', 'lost_price', 'condition', 'condition_notes' ] widgets = { 'acquired': DatePickerInput(format='%Y-%m-%d'), 'lost': DatePickerInput(format='%Y-%m-%d'), }
class Meta: model = Film fields = [ 'filmstock', 'format', 'frames', 'film_batch', 'expiry_date', 'purchase_date', 'price', 'bulk_film', 'bulk_film_loaded', 'status' ] widgets = { 'purchase_date': DatePickerInput(format='%Y-%m-%d'), 'expiry_date': MonthPickerInput(format='%Y-%m-01'), 'bulk_film_loaded': DatePickerInput(format='%Y-%m-%d'), }
class Meta: model = Lens fields = [ 'lensmodel', 'serial', 'date_code', 'manufactured', 'acquired', 'cost', 'notes', 'own', 'lost', 'lost_price', 'source', 'condition', 'condition_notes' ] widgets = { 'acquired': DatePickerInput(format='%Y-%m-%d'), 'lost': DatePickerInput(format='%Y-%m-%d'), } if ('makemigrations' in sys.argv or 'migrate' in sys.argv or 'test' in sys.argv): fields.remove('lensmodel')
class Meta: model = Teleconverter fields = [ 'teleconvertermodel', 'serial', 'own', 'acquired', 'cost', 'lost', 'lost_price', ] widgets = { 'acquired': DatePickerInput(format='%Y-%m-%d'), 'lost': DatePickerInput(format='%Y-%m-%d'), }
class DatesLimitForm(forms.Form): start_date = forms.DateField( widget=DatePickerInput(format=DEFAULT_DATE_FORMAT, attrs={ "class": "form-control" }).start_of("event"), initial=one_month_before_today(), ) end_date = forms.DateField( widget=DatePickerInput(format=DEFAULT_DATE_FORMAT, attrs={ "class": "form-control" }).end_of("event"), initial=datetime.today(), )
class Meta: model = Accessory fields = [ 'manufacturer', 'model', 'type', 'acquired', 'cost', 'lost', 'lost_price', 'camera_model_compatibility', 'lens_model_compatibility' ] widgets = { 'acquired': DatePickerInput(format='%Y-%m-%d'), 'lost': DatePickerInput(format='%Y-%m-%d'), } if ('makemigrations' in sys.argv or 'migrate' in sys.argv or 'test' in sys.argv): fields.remove('manufacturer') fields.remove('camera_model_compatibility') fields.remove('lens_model_compatibility')
class Meta: model = Event fields = [ "start_date", "end_date", "start_time", "end_time", "start_datetime", "end_datetime", "start_month", "end_month", "start_year", "end_year", ] widgets = { # fmt: off "start_date": DatePickerInput(options={ "format": "YYYY-MM-DD", "debug": True }).start_of("event active days"), "end_date": DatePickerInput(options={ "format": "MM/DD/YYYY" }).end_of("event active days"), "start_datetime": DateTimePickerInput(options={ "debug": True }).start_of("event active dtime"), "end_datetime": DateTimePickerInput().end_of("event active dtime"), "start_time": TimePickerInput(options={ "debug": True }).start_of("event active time"), "end_time": TimePickerInput().end_of("event active time"), "start_month": MonthPickerInput().start_of("active month"), "end_month": MonthPickerInput().end_of("active month"), "start_year": YearPickerInput().start_of("active year"), "end_year": YearPickerInput().end_of("active year"), }
class Meta: model = Fahrt exclude: list[str] = ["semester"] widgets = { "date": DatePickerInput(format="%Y-%m-%d"), "open_registration": DateTimePickerInput(format="%Y-%m-%d %H:%M"), "close_registration": DateTimePickerInput(format="%Y-%m-%d %H:%M"), }
class Meta: model = Film fields = [ 'camera', 'title', 'exposed_at', 'date_loaded', 'frames', 'status' ] widgets = { 'date_loaded': DatePickerInput(format='%Y-%m-%d'), }
class Meta: model = Event fields = [ 'title', 'date', ] labels = { 'title': 'Название', 'date': 'Дата (YYYY-MM-DD)', } widgets = { 'date': DatePickerInput(), }
class Meta: model = BulkFilm fields = [ 'format', 'filmstock', 'length', 'finished', 'purchase_date', 'cost', 'source', 'batch', 'expiry' ] widgets = { 'purchase_date': DatePickerInput(format='%Y-%m-%d'), 'expiry': MonthPickerInput(format='%Y-%m-01'), } if ('makemigrations' in sys.argv or 'migrate' in sys.argv or 'test' in sys.argv): fields.remove('filmstock') fields.remove('format')
class Meta: model = Print fields = [ 'negative', 'date', 'paper_stock', 'height', 'width', 'aperture', 'exposure_time', 'filtration_grade', 'development_time', 'toner', 'own', 'location', 'sold_price', 'enlarger', 'lens', 'developer', 'fine', 'notes', 'archive', 'printer' ] widgets = { 'date': DatePickerInput(format='%Y-%m-%d'), } if ('makemigrations' in sys.argv or 'migrate' in sys.argv or 'test' in sys.argv): fields.remove('paper_stock') fields.remove('developer') fields.remove('toner')
class Meta: model = Participant exclude = [ "uuid", "semester", "non_liability", "paid", "payment_deadline", "status", "mailinglist", "comment", "registration_time", "transportation", ] widgets = { "birthday": DatePickerInput(format="%Y-%m-%d"), }
class Meta: model = Film fields = [ 'date_processed', 'developer', 'developer_previous_uses', 'development_time', 'development_temperature', 'development_compensation', 'development_notes', 'processed_by', 'status' ] widgets = { 'date_processed': DatePickerInput(format='%Y-%m-%d'), 'dev_time': TimePickerInput(format='%H:%M:%S', options={ "useCurrent": False, "showTodayButton": False, }), }
class Meta: model = Contest fields = [ 'name', 'source', 'date', 'num_of_problem', 'contest_type', 'contest_link' ] widgets = { 'date': DatePickerInput(options={ "format": "yyyy/mm/dd", "autoclose": True }) } labels = { 'name': 'Contest Name', 'source': 'Contest Source', 'date': 'Contest Start Time', 'num_of_problem': 'Number of Problems', 'contest_link': 'Link', }
class Meta: model = Event fields = [ 'title', 'gym', 'date', 'poster', 'description', 'short_description', ] labels = { 'title': 'Название', 'gym': 'Скалодром', 'date': 'Дата (YYYY-MM-DD)', 'poster': 'Афиша', 'short_description': 'Краткое описание', } widgets = { 'date': DatePickerInput(), }
class Meta: model = Shift fields = [ 'location', 'date', 'start_time', 'end_time', 'role', 'needs_dbs', 'volunteer_can_accept', 'volunteer', 'notes', ] labels = { 'needs_dbs': 'Needs DBS check', } widgets = { 'date': DatePickerInput(), 'start_time': TimePickerInput(), 'end_time': TimePickerInput(), }
class ChoiceChildDateForm(forms.Form): child = forms.ModelChoiceField( queryset=Child.objects.filter(status=Child.STATUS.in_progress), label=_("Child"), widget=ModelSelect2Widget( model=Child, queryset=Child.objects.filter(status=Child.STATUS.in_progress), search_fields=['first_name__icontains'], ), required=True ) date = forms.DateField( label=_("Date"), widget=DatePickerInput(options={ "locale": "fr", "format": "DD/MM/YYYY" }), ) class Meta: fields = ("child", "date") def __init__(self, *args, **kwargs): super(ChoiceChildDateForm, self).__init__(*args, **kwargs) self.helper = FormHelper() self.helper.form_id = 'id-choice-child-date-form' self.helper.form_class = 'form-horizontal blueForms' self.helper.form_method = 'post' self.helper.label_class = "col-lg-2" self.helper.field_class = "col-lg-10" self.helper.layout = Layout( Div( Field("child"), Field("date"), Submit('submit', _('Submit')) , css_class="mx-auto col-md-10" ) )
class EarlyTroubleshootingForm(BSModalModelForm): date = forms.DateField( label=_("Date"), widget=DatePickerInput(options={ "locale": "fr", "format": "DD/MM/YYYY" }), ) class Meta: model = EarlyTroubleshooting fields = ("child", "date", "periods") def clean_periods(self): periods = self.cleaned_data.get("periods") for period in periods: if period.weekday != self.cleaned_data['date'].isoweekday(): # Good periods = periods.exclude(id=period.id) if periods.count() > 0: return periods else: raise ValidationError(_("No valid period selected."), code="invalid")
def test_date_input_snapshot(self): dp_input = DatePickerInput() html = dp_input.render("input_name", "2018-04-12", {}) self.assertGreater(len(html), 0)
class Meta: model = Lens fields = ['own', 'lost', 'lost_price'] widgets = { 'lost': DatePickerInput(format='%Y-%m-%d'), }
class Meta: model = Scan fields = ['negative', 'print', 'filename', 'date'] widgets = { 'date': DatePickerInput(format='%Y-%m-%d'), }
class Meta: model = Tutor exclude = ["semester", "status", "registration_time", "answers"] widgets = { "birthday": DatePickerInput(format="%Y-%m-%d"), }
class CustomForm(forms.Form): date = forms.DateField(label="Date", widget=DatePickerInput()) message = forms.CharField(label="Message", widget=forms.Textarea)