From d132dc72de6df4de868bfdaba701ff81ae966b8a Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Tue, 1 Nov 2016 11:17:54 +0100 Subject: [PATCH] Add Entitiy for the Service Object --- app/entities.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/app/entities.py b/app/entities.py index 5e06001..d138bbf 100644 --- a/app/entities.py +++ b/app/entities.py @@ -63,6 +63,9 @@ class Vehicle(db.Model): pitstops = db.relationship( 'Pitstop' ) + services = db.relationship( + 'Service' + ) consumables = db.relationship( 'Consumable', secondary=vehicles_consumables @@ -140,3 +143,23 @@ class Consumable(db.Model): def __repr__(self): return '' % (self.name, self.unit) + + +class Service(db.Model): + id = db.Column(db.Integer, primary_key=True) + date = db.Column(db.Date) + odometer = db.Column(db.Integer) + vehicle_id = db.Column(db.Integer, db.ForeignKey('vehicle.id')) + costs = db.Column(db.Numeric(10, 2), default=0) + description = db.Column(db.String(4096)) + + def __init__(self, date, odometer, vehicle_id, costs, description): + self.description = description + self.costs = costs + self.date = date + self.odometer = odometer + self.vehicle_id = vehicle_id + + def __repr__(self): + return '' % \ + (self.odometer, self.date, self.vehicle_id, self.costs, self.description)