Add Entitiy for the Service Object
This commit is contained in:
parent
43fa41aace
commit
d132dc72de
@ -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 '<Consumable name="%s" unit="%s" />' % (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 '<Service odometer="%r" date="%r" vehicle_id="%r" costs="%r" description="%r">' % \
|
||||
(self.odometer, self.date, self.vehicle_id, self.costs, self.description)
|
||||
|
Loading…
Reference in New Issue
Block a user