diff --git a/ITPlanning/db.py b/ITPlanning/db.py index 01a8c82..ca16157 100644 --- a/ITPlanning/db.py +++ b/ITPlanning/db.py @@ -5,6 +5,7 @@ from urllib.parse import urlparse, parse_qsl from pony.orm import Database, Required, Optional, Set, PrimaryKey, LongStr db = Database() + class Service(db.Entity): id = PrimaryKey(int, auto=True) name = Required(str, unique=True) @@ -22,6 +23,7 @@ class Planning(db.Entity): working_plan = Required(LongStr) services = Set(Service) appointments = Set('Appointment') + planners = Set('Planner') class Setting(db.Entity): @@ -40,11 +42,11 @@ class Appointment(db.Entity): service = Required(Service) planning = Required(Planning) ticket = Optional('Ticket') - user = Optional('User') + customer = Optional('Customer') notes = Optional(LongStr) -class User(db.Entity): +class Customer(db.Entity): id = PrimaryKey(int, auto=True) first_name = Required(str) last_name = Required(str) @@ -61,7 +63,7 @@ class Ticket(db.Entity): id = PrimaryKey(int, auto=True) ref = Optional(str, unique=True) service_category = Required('Service_category') - user = Required(User) + customer = Required(Customer) appointment = Required(Appointment) notes = Optional(str) @@ -76,6 +78,10 @@ class Service_category(db.Entity): description = Optional(str) +class Planner(Customer): + plannings = Set(Planning) + password = Required(str) + is_admin = Optional(bool) def parse_uri(database_uri): if not isinstance(database_uri, str): diff --git a/docs/database.png b/docs/database.png index c0b8c27..80d98b2 100644 Binary files a/docs/database.png and b/docs/database.png differ