-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSend.py
More file actions
61 lines (54 loc) · 2.29 KB
/
Send.py
File metadata and controls
61 lines (54 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# AmazRT - Parcel Management System
# First semester Technical Degree project
# Copyright (c) 2021 - 2022
# - Meryem KAYA @MeryemKy
# - Alexis LEBEL @Alestrio
# - Malo LEGRAND @HoesMaaad
import datetime
from datetime import date
from sqlalchemy import ForeignKey, Column, Boolean, Date
from application.data.entities.AbstractEntity import AbstractEntity
from application.data.entities.platforms.Plr import Plr
from application.data.entities.platforms.Pld import Pld
class Send(AbstractEntity):
"""
@Entity
This is the entity class responsible for the middle step of the parcel trip.
The tablename is "envoyer"
"""
root_url = 'send/'
def todict(self):
return {
'parcel': self.parcel,
'pld': self.pld,
'plr': self.plr,
'send_date': self.send_date.timestamp(),
'reception_date': self.reception_date.timestamp(),
'pld_to_plr': self.pld_to_plr
}
def __init__(self, parcel=0, pld=0, plr=0, send_date: datetime.datetime = datetime.datetime.fromtimestamp(0),
reception_date: datetime.datetime = datetime.datetime.fromtimestamp(0), pld_to_plr: bool = False):
"""Constructor"""
super().__init__(0)
self.parcel = parcel
self.pld = pld
self.plr = plr
self.send_date = send_date
self.reception_date = reception_date
self.pld_to_plr = pld_to_plr
@staticmethod
def fromdict(origin_dict):
if origin_dict is not None:
sendlist = []
if not isinstance(origin_dict, dict):
for i in origin_dict:
sendlist.append(Send(i['parcel'], i['pld'], i['plr'],
datetime.datetime.fromtimestamp(i['send_date']),
datetime.datetime.fromtimestamp(i['reception_date']),
i['pld_to_plr']))
return sendlist
else:
return Send(origin_dict['parcel'], origin_dict['pld'], origin_dict['plr'],
datetime.datetime.fromtimestamp(origin_dict['send_date']),
datetime.datetime.fromtimestamp(origin_dict['reception_date']),
origin_dict['pld_to_plr'])