Compare commits

...

2 Commits

Author SHA1 Message Date
ebee2d514c Correct Current Cycle and add styling to new/update
All checks were successful
continuous-integration/drone/push Build is passing
2022-08-12 00:20:37 -04:00
fa7d46623e Update Math on Cycle Length 2022-08-12 00:20:19 -04:00
4 changed files with 44 additions and 13 deletions

View File

@ -17,7 +17,7 @@ def index():
db = get_db()
current_cycle = db.execute('SELECT * from cycle ORDER BY id DESC LIMIT 1').fetchone()
start_time = pendulum.parse(current_cycle['start_time'])
cycle_length = ((pendulum.now() - start_time ).days)+1
cycle_length = ((pendulum.now() - start_time ).days) +1
db.execute(
'UPDATE cycle SET cycle_length = ?'
@ -49,7 +49,7 @@ def create():
error = "You must provide a start date"
if end_time > start_time:
cycle_length = (end_time - start_time).days
cycle_length = (end_time - start_time).days +1
else:
cycle_length = (pendulum.now() - start_time).days
@ -105,7 +105,7 @@ def update(id):
error = "You must provide a start date"
if end_time > start_time:
cycle_length = (end_time - start_time).days
cycle_length = (end_time - start_time).days + 1
else:
cycle_length = (pendulum.now() - start_time).days
@ -154,7 +154,7 @@ def cycle_math():
if num > 0:
this_start = pendulum.parse(cycle['start_time'])
next_start = pendulum.parse(all_cycles[num-1]['start_time'])
cycle_length = (next_start - this_start).days
cycle_length = (next_start - this_start).days +1
db.execute(
'UPDATE cycle SET cycle_length = ?'
' WHERE id = ?',

View File

@ -1,15 +1,31 @@
{% extends 'base.html' %}
{% block header %}
<h1>{% block title %}New Cycle{% endblock %}</h1>
{% endblock %}
{% block content %}
<div class="container-fluid">
<div class="table-responsive">
<div class="table-wrapper">
<div class="table-title">
<div class="row">
<div class="col-sm-6">
{% block header %}
<h2>{% block title %}New Cycle{% endblock %}</h2>
{% endblock %}
</div>
<div class="col-sm-6">
<a class="btn btn-primary" href="{{ url_for('cycles.create') }}">New Cycle</a>
</div>
</div>
</div>
<form method="post">
<label for="start_time">Start Time</label>
<input name="start_time" id="title" value="{{ request.form['start_time'] }}" required type="date">
<br><br>
<label for="end_time">End Time</label>
<input name="end_time" id="end_time" value="{{ request.form['end_time'] }}" type="date">
<br>
<input type="submit" value="Save">
</form>
{% endblock %}

View File

@ -24,7 +24,7 @@
<h5 class="card-title">
{% if cycle['cycle_length'] %}
{% if loop.first %}
Day <b>{{ cycle['cycle_length'] }}</b>
Day <b>{{ cycle['cycle_length'] - 1 }}</b>
{% else %}
<b>{{ cycle['cycle_length'] }}</b> days.
{% endif %}

View File

@ -1,13 +1,28 @@
{% extends 'base.html' %}
{% block header %}
<h1>{% block title %}Edit Cycle{% endblock %}</h1>
{% endblock %}
{% block content %}
<div class="container-fluid">
<div class="table-responsive">
<div class="table-wrapper">
<div class="table-title">
<div class="row">
<div class="col-sm-6">
{% block header %}
<h2>{% block title %}Edit Cycle{% endblock %}</h2>
{% endblock %}
</div>
<div class="col-sm-6">
<a class="btn btn-primary" href="{{ url_for('cycles.create') }}">New Cycle</a>
</div>
</div>
</div>
<form method="post">
<label for="start_time">Start Time</label>
<input name="start_time" id="title" value="{{ request.form['start_time'] or cycle['start_time'][:10] }}" required type="date">
<br>
<label for="end_time">End Time</label>
<input name="end_time" id="end_time" value="{{ request.form['end_time'] or cycle['end_time'][:10] if cycle['end_time'] is not none }}" type="date">
<input type="submit" value="Save">