Skip to content

Commit c4e94d0

Browse files
author
Yoanis Gil Delgado
committed
Default year/month/day/hour/minute
1 parent 179b569 commit c4e94d0

2 files changed

Lines changed: 14 additions & 6 deletions

File tree

app.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,20 @@ def index():
6666
if request.method == 'POST' and form.validate():
6767
count_down = Countdown(form.name.data, form.year.data, form.month.data, form.day.data, form.hour.data,
6868
form.minute.data,
69-
'America/Chicago')
69+
'America/New_York')
7070
db.session.add(count_down)
7171
db.session.commit()
7272

7373
return redirect(url_for('countdown', countdown_id=count_down.id))
7474

75+
now = datetime.now()
76+
77+
form.year.data = now.year
78+
form.month.data = now.month
79+
form.day.data = now.day
80+
form.hour.data = now.hour
81+
form.minute.data = now.minute
82+
7583
return render_template('index.html', form=form)
7684

7785

templates/index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
</div>
3232
<div class="col-lg-8">
3333
<input class="countdown-input" name="name" placeholder="my birthday" type="text"
34-
value="{{ form.name.data }}" required autocomplete="off">
34+
value="{{ form.name.data }}" required autocomplete="off" autofocus="">
3535
</div>
3636
{{ show_if_error('name', form.errors) }}
3737
</div>
@@ -50,15 +50,15 @@
5050
</div>
5151
<div class="col-lg-3">
5252
<input class="countdown-input" name="month" placeholder="month" type="number"
53-
value="{{ form.month.data }}" required>
53+
value="{{ form.month.data }}" required min="1" max="12">
5454
{{ show_if_error('month', form.errors) }}
5555
</div>
5656
<div class="col-lg-1">
5757
<label class="cool-text">/</label>
5858
</div>
5959
<div class="col-lg-2">
6060
<input class="countdown-input" name="day" placeholder="day" type="number"
61-
value="{{ form.day.data }}"
61+
value="{{ form.day.data }}" min="1" max="31"
6262
required>
6363
{{ show_if_error('day', form.errors) }}
6464
</div>
@@ -70,15 +70,15 @@
7070
</div>
7171
<div class="col-lg-2">
7272
<input class="countdown-input" name="hour" placeholder="hour" type="number"
73-
value="{{ form.hour.data }}" required>
73+
value="{{ form.hour.data }}" required min="0" max="23">
7474
{{ show_if_error('hour', form.errors) }}
7575
</div>
7676
<div class="col-lg-1">
7777
<label class="cool-text">:</label>
7878
</div>
7979
<div class="col-lg-2">
8080
<input class="countdown-input" name="minute" placeholder="minute" type="number"
81-
value="{{ form.minute.data }}" required>
81+
value="{{ form.minute.data }}" required min="0" max="59">
8282
{{ show_if_error('minute', form.errors) }}
8383
</div>
8484
</div>

0 commit comments

Comments
 (0)