This repository has been archived on 2025-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
BreCal/src/server/BreCal/database/enums.py

73 lines
2.1 KiB
Python

from enum import IntEnum, Enum, IntFlag
class ParticipantType(IntFlag):
"""determines the type of a participant"""
undefined = 0
BSMD = 1
TERMINAL = 2
PILOT = 4
AGENCY = 8
MOORING = 16
PORT_ADMINISTRATION = 32
TUG = 64
@classmethod
def _missing_(cls, value):
return cls.undefined
class ShipcallType(IntEnum):
"""determines the type of a shipcall, as this changes the applicable validation rules"""
undefined = 0
INCOMING = 1
OUTGOING = 2
SHIFTING = 3
@classmethod
def _missing_(cls, value):
return cls.undefined
class ParticipantwiseTimeDelta():
"""stores the time delta for every participant, which triggers the validation rules in the rule set '0001'"""
AGENCY = 1200.0 # 20 h * 60 min/h = 1200 min
MOORING = 960.0 # 16 h * 60 min/h = 960 min
PILOT = 960.0 # 16 h * 60 min/h = 960 min
PORT_ADMINISTRATION = 960.0 # 16 h * 60 min/h = 960 min
TUG = 960.0 # 16 h * 60 min/h = 960 min
TERMINAL = 960.0 # 16 h * 60 min/h = 960 min
NOTIFICATION = 10.0 # after n minutes, an evaluation may rise a notification
class StatusFlags(IntEnum):
"""
these enumerators ensure that each traffic light validation rule state corresponds to a value, which will be used in the ValidationRules object to identify
the necessity of notifications.
"""
NONE = 0
GREEN = 1
YELLOW = 2
RED = 3
class PierSide(IntEnum):
"""These enumerators determine the pier side of a shipcall."""
PORTSIDE = 0 # Port/Backbord
STARBOARD_SIDE = 1 # Starboard / Steuerbord
class NotificationType(IntFlag):
"""determines the method by which a notification is distributed to users. Flagging allows selecting multiple notification types."""
UNDEFINED = 0
EMAIL = 1
POPUP = 2
MESSENGER = 4
class ParticipantFlag(IntFlag):
"""
| 1 | If this flag is set on a shipcall record with participant type Agency (8),
all participants of type BSMD (1) may edit the record.
"""
undefined = 0
BSMD = 1
@classmethod
def _missing_(cls, value):
return cls.undefined