2020-12-29 14:37:37 +01:00
|
|
|
"""Provide the ORM's `Customer` model."""
|
2020-08-09 03:45:19 +02:00
|
|
|
|
|
|
|
import sqlalchemy as sa
|
|
|
|
from sqlalchemy import orm
|
|
|
|
|
|
|
|
from urban_meal_delivery.db import meta
|
|
|
|
|
|
|
|
|
|
|
|
class Customer(meta.Base):
|
2020-12-29 14:37:37 +01:00
|
|
|
"""A customer of the UDP."""
|
2020-08-09 03:45:19 +02:00
|
|
|
|
|
|
|
__tablename__ = 'customers'
|
|
|
|
|
|
|
|
# Columns
|
|
|
|
id = sa.Column(sa.Integer, primary_key=True, autoincrement=False) # noqa:WPS125
|
|
|
|
|
|
|
|
def __repr__(self) -> str:
|
|
|
|
"""Non-literal text representation."""
|
|
|
|
return '<{cls}(#{customer_id})>'.format(
|
|
|
|
cls=self.__class__.__name__, customer_id=self.id,
|
|
|
|
)
|
|
|
|
|
|
|
|
# Relationships
|
|
|
|
orders = orm.relationship('Order', back_populates='customer')
|