Compare commits
7 Commits
revert-43b
...
master
Author | SHA1 | Date | |
---|---|---|---|
ebee2d514c | |||
fa7d46623e | |||
87f936c331 | |||
d69001d72d | |||
6e9a78029b | |||
16ad5e3a98 | |||
65b925f90d |
35
.drone.yml
Normal file
35
.drone.yml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: build
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: build
|
||||||
|
image: python:3-buster
|
||||||
|
commands:
|
||||||
|
- export PYTHONPATH=.
|
||||||
|
- export FLASK_APP=period
|
||||||
|
- apt-get update -qy
|
||||||
|
- apt-get install -y python3-dev python3-pip
|
||||||
|
- pip3 install --upgrade pip
|
||||||
|
- pip3 install --upgrade setuptools
|
||||||
|
- pip3 install Flask gunicorn pytest pytest-cov
|
||||||
|
- pip3 install pendulum
|
||||||
|
|
||||||
|
---
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: test
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: test
|
||||||
|
image: python:3-buster
|
||||||
|
commands:
|
||||||
|
- export PYTHONPATH=.
|
||||||
|
- export FLASK_APP=period
|
||||||
|
- apt-get update -qy
|
||||||
|
- apt-get install -y python3-dev python3-pip
|
||||||
|
- pip3 install --upgrade pip
|
||||||
|
- pip3 install --upgrade setuptools
|
||||||
|
- pip3 install Flask gunicorn pytest pytest-cov
|
||||||
|
- pip3 install pendulum
|
||||||
|
- pytest tests --cov --cov-report term --cov-report html --junitxml=report.xml
|
@ -17,7 +17,7 @@ def index():
|
|||||||
db = get_db()
|
db = get_db()
|
||||||
current_cycle = db.execute('SELECT * from cycle ORDER BY id DESC LIMIT 1').fetchone()
|
current_cycle = db.execute('SELECT * from cycle ORDER BY id DESC LIMIT 1').fetchone()
|
||||||
start_time = pendulum.parse(current_cycle['start_time'])
|
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(
|
db.execute(
|
||||||
'UPDATE cycle SET cycle_length = ?'
|
'UPDATE cycle SET cycle_length = ?'
|
||||||
@ -49,7 +49,7 @@ def create():
|
|||||||
error = "You must provide a start date"
|
error = "You must provide a start date"
|
||||||
|
|
||||||
if end_time > start_time:
|
if end_time > start_time:
|
||||||
cycle_length = (end_time - start_time).days
|
cycle_length = (end_time - start_time).days +1
|
||||||
else:
|
else:
|
||||||
cycle_length = (pendulum.now() - start_time).days
|
cycle_length = (pendulum.now() - start_time).days
|
||||||
|
|
||||||
@ -105,7 +105,7 @@ def update(id):
|
|||||||
error = "You must provide a start date"
|
error = "You must provide a start date"
|
||||||
|
|
||||||
if end_time > start_time:
|
if end_time > start_time:
|
||||||
cycle_length = (end_time - start_time).days
|
cycle_length = (end_time - start_time).days + 1
|
||||||
else:
|
else:
|
||||||
cycle_length = (pendulum.now() - start_time).days
|
cycle_length = (pendulum.now() - start_time).days
|
||||||
|
|
||||||
@ -151,15 +151,16 @@ def cycle_math():
|
|||||||
for num, cycle in enumerate(all_cycles):
|
for num, cycle in enumerate(all_cycles):
|
||||||
# http://127.0.0.1:5000/cycle_math
|
# http://127.0.0.1:5000/cycle_math
|
||||||
# cycle length = next start - this start
|
# cycle length = next start - this start
|
||||||
this_start = pendulum.parse(cycle['start_time'])
|
if num > 0:
|
||||||
next_start = pendulum.parse(all_cycles[num-1]['start_time'])
|
this_start = pendulum.parse(cycle['start_time'])
|
||||||
cycle_length = (next_start - this_start).days
|
next_start = pendulum.parse(all_cycles[num-1]['start_time'])
|
||||||
db.execute(
|
cycle_length = (next_start - this_start).days +1
|
||||||
'UPDATE cycle SET cycle_length = ?'
|
db.execute(
|
||||||
' WHERE id = ?',
|
'UPDATE cycle SET cycle_length = ?'
|
||||||
(cycle_length, cycle['id'])
|
' WHERE id = ?',
|
||||||
)
|
(cycle_length, cycle['id'])
|
||||||
db.commit()
|
)
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
|
||||||
return redirect(url_for('cycles.index'))
|
return redirect(url_for('cycles.index'))
|
@ -15,7 +15,7 @@
|
|||||||
margin: 30px 0;
|
margin: 30px 0;
|
||||||
}
|
}
|
||||||
.table-wrapper {
|
.table-wrapper {
|
||||||
/* min-width: 1000px; */
|
min-width: 400px;
|
||||||
background: #fff;
|
background: #fff;
|
||||||
padding: 20px 25px;
|
padding: 20px 25px;
|
||||||
border-radius: 3px;
|
border-radius: 3px;
|
||||||
@ -230,12 +230,12 @@ table.table .avatar {
|
|||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<nav class="navbar navbar-expand-lg navbar-light bg-light">
|
<!-- <nav class="navbar navbar-expand-lg navbar-light bg-light">
|
||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<a class="navbar-brand" href="#">Period</a>
|
<a class="navbar-brand" href="#">Period</a>
|
||||||
<a class="btn btn-primary" href="{{ url_for('cycles.create') }}">New Cycle</a>
|
<a class="btn btn-primary" href="{{ url_for('cycles.create') }}">New Cycle</a>
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav> -->
|
||||||
</nav>
|
</nav>
|
||||||
<section class="content">
|
<section class="content">
|
||||||
<header>
|
<header>
|
||||||
|
@ -1,15 +1,31 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block header %}
|
|
||||||
<h1>{% block title %}New Cycle{% endblock %}</h1>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% 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">
|
<form method="post">
|
||||||
<label for="start_time">Start Time</label>
|
<label for="start_time">Start Time</label>
|
||||||
<input name="start_time" id="title" value="{{ request.form['start_time'] }}" required type="date">
|
<input name="start_time" id="title" value="{{ request.form['start_time'] }}" required type="date">
|
||||||
|
<br><br>
|
||||||
<label for="end_time">End Time</label>
|
<label for="end_time">End Time</label>
|
||||||
<input name="end_time" id="end_time" value="{{ request.form['end_time'] }}" type="date">
|
<input name="end_time" id="end_time" value="{{ request.form['end_time'] }}" type="date">
|
||||||
|
<br>
|
||||||
<input type="submit" value="Save">
|
<input type="submit" value="Save">
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
@ -13,6 +13,9 @@
|
|||||||
<h2>{% block title %}Cycles{% endblock %}</h2>
|
<h2>{% block title %}Cycles{% endblock %}</h2>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-sm-6">
|
||||||
|
<a class="btn btn-primary" href="{{ url_for('cycles.create') }}">New Cycle</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% for cycle in cycles %}
|
{% for cycle in cycles %}
|
||||||
@ -21,7 +24,7 @@
|
|||||||
<h5 class="card-title">
|
<h5 class="card-title">
|
||||||
{% if cycle['cycle_length'] %}
|
{% if cycle['cycle_length'] %}
|
||||||
{% if loop.first %}
|
{% if loop.first %}
|
||||||
Day <b>{{ cycle['cycle_length'] }}</b>
|
Day <b>{{ cycle['cycle_length'] - 1 }}</b>
|
||||||
{% else %}
|
{% else %}
|
||||||
<b>{{ cycle['cycle_length'] }}</b> days.
|
<b>{{ cycle['cycle_length'] }}</b> days.
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -1,13 +1,28 @@
|
|||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block header %}
|
|
||||||
<h1>{% block title %}Edit Cycle{% endblock %}</h1>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block content %}
|
{% 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">
|
<form method="post">
|
||||||
<label for="start_time">Start Time</label>
|
<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">
|
<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>
|
<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 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">
|
<input type="submit" value="Save">
|
||||||
|
Loading…
Reference in New Issue
Block a user