Compare commits
8 Commits
Kilian
...
158c419747
| Author | SHA1 | Date | |
|---|---|---|---|
| 158c419747 | |||
| 79e5fdf56b | |||
| a9338805e2 | |||
| 7f82a288da | |||
| 8728d3028b | |||
| bc7e1591bd | |||
| 673b671ab8 | |||
| 578b2c15d8 |
@@ -6,7 +6,7 @@ from .checks import *
|
||||
|
||||
|
||||
class CreateServiceForm(FlaskForm):
|
||||
date = DateField('Date of Pitstop')
|
||||
date = DateField('Date of Service')
|
||||
odometer = IntegerField('Odometer (km)', validators=[odometer_date_check])
|
||||
costs = DecimalField('Costs (€, overall)', places=2, validators=[costs_check])
|
||||
description = TextAreaField('Description', validators=[Length(1, 4096)])
|
||||
@@ -72,4 +72,4 @@ class EditServiceForm(FlaskForm):
|
||||
'litres': 'Litres must be higher than 0.01 L.',
|
||||
'costs': 'Costs must be higher than 0.01 €.'
|
||||
}
|
||||
return messages
|
||||
return messages
|
||||
|
||||
@@ -14,6 +14,7 @@ from ..tools import (
|
||||
db_log_delete,
|
||||
get_event_line_for_vehicle,
|
||||
get_latest_pitstop_for_vehicle,
|
||||
get_users_active_vehicle,
|
||||
)
|
||||
from .. import app, db
|
||||
|
||||
|
||||
@@ -164,6 +164,7 @@
|
||||
<ul id="consumable_{{vehicle.id}}_{{consumable.id}}_tabs" class="nav nav-tabs" data-tabs="tabs">
|
||||
{{ nav_tab(vehicle.id|string + '_' + consumable.id|string + '_consumption', 'Consumption', true) }}
|
||||
{{ nav_tab(vehicle.id|string + '_' + consumable.id|string + '_amount', 'Amount', false) }}
|
||||
{{ nav_tab(vehicle.id|string + '_' + consumable.id|string + '_price', 'Price', false) }}
|
||||
</ul>
|
||||
<div id="consumable_{{vehicle.id}}_{{consumable.id}}_content" class="tab-content ">
|
||||
{{ tab_pane(
|
||||
@@ -188,6 +189,17 @@
|
||||
false
|
||||
)
|
||||
}}
|
||||
{{ tab_pane(
|
||||
vehicle.id|string + '_' + consumable.id|string + '_price',
|
||||
chart(
|
||||
consumable.price,
|
||||
'ref_' + vehicle.id|string + '_' + consumable.id|string + '_price',
|
||||
'€ / '+consumable.unit,
|
||||
url_for('create_pit_stop_form', vid=vehicle.id, cid=consumable.id)
|
||||
),
|
||||
false
|
||||
)
|
||||
}}
|
||||
</div>
|
||||
{{ tab_script('vehicle_' + vehicle.id|string + '_' + consumable.id|string + '_tabs') }}
|
||||
</div>
|
||||
|
||||
@@ -27,6 +27,7 @@ class ConsumableStats:
|
||||
self.average_amount_used = 0
|
||||
self.average_amount = []
|
||||
self.amounts = []
|
||||
self.price = []
|
||||
|
||||
pitstops = [
|
||||
stop for stop in vehicle.pitstops if stop.consumable_id == consumable.id
|
||||
@@ -37,6 +38,7 @@ class ConsumableStats:
|
||||
for pitstop in pitstops:
|
||||
self.overall_amount += pitstop.amount
|
||||
self.amounts.append(StatsEvent(pitstop.date, pitstop.amount))
|
||||
self.price.append(StatsEvent(pitstop.date, pitstop.costs/pitstop.amount))
|
||||
self.average_amount_fuelled = self.overall_amount / pitstop_count
|
||||
if pitstop_count > 1:
|
||||
overall_distance = (
|
||||
@@ -204,7 +206,9 @@ def compute_lower_limits_for_new_pitstop(
|
||||
|
||||
|
||||
def pitstop_service_key(x):
|
||||
return x.date, x.odometer
|
||||
# if the entry got no odometer (regular costs!) then we assume it's okay
|
||||
# to have regular cost at a virtual odometer of 0 on that day.
|
||||
return x.date, x.odometer or 0
|
||||
|
||||
|
||||
def get_event_line_for_vehicle(vehicle):
|
||||
|
||||
@@ -41,8 +41,8 @@ class TestingConfig(Config):
|
||||
|
||||
|
||||
class ProductionConfig(Config):
|
||||
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://root:{h}@database/pitstops'.format(
|
||||
h=os.environ.get('DATABASE_ENV_MYSQL_ROOT_PASSWORD'))
|
||||
SQLALCHEMY_DATABASE_URI = 'mysql+pymysql://pitstops:{h}@localhost/pitstops'.format(
|
||||
h=os.environ.get('MYSQL_PASSWORD'))
|
||||
|
||||
|
||||
config = {
|
||||
|
||||
@@ -7,3 +7,4 @@ markdown
|
||||
Flask-Limiter
|
||||
requests
|
||||
email_validator
|
||||
gunicorn
|
||||
Reference in New Issue
Block a user