Adjusted yaml spec and fixed user interface for storing notification flags

This commit is contained in:
Daniel Schick 2024-12-05 17:25:01 +01:00
parent 941b5e70fb
commit 44f5d07ed7
5 changed files with 454 additions and 181 deletions

File diff suppressed because it is too large Load Diff

View File

@ -657,7 +657,7 @@ paths:
parameters: parameters:
- name: shipcall_id - name: shipcall_id
in: query in: query
required: true required: false
description: '**Id of ship call**. *Example: 52*. Id given in ship call list' description: '**Id of ship call**. *Example: 52*. Id given in ship call list'
schema: schema:
$ref: '#/components/schemas/shipcallId' $ref: '#/components/schemas/shipcallId'
@ -1545,9 +1545,11 @@ components:
id: id:
type: integer type: integer
example: 42 example: 42
nullable: false
shipcall_id: shipcall_id:
type: integer type: integer
example: 5 example: 5
nullable: false
notification_type: notification_type:
$ref: '#/components/schemas/NotificationType' $ref: '#/components/schemas/NotificationType'
message: message:
@ -1567,8 +1569,8 @@ components:
example: example:
id: 42 id: 42
shipcall_id: 5 shipcall_id: 5
notification_type: email notification_type: next24h
message: Entry XY violates rule Z message: Shipcall may be relevant to you in the next 24 hours
created: '2023-08-21T08:23:35Z' created: '2023-08-21T08:23:35Z'
modified: '2023-08-21T08:23:35Z' modified: '2023-08-21T08:23:35Z'
notification_list: notification_list:
@ -1579,13 +1581,13 @@ components:
example: example:
- id: 42 - id: 42
shipcall_id: 5 shipcall_id: 5
notification_type: email notification_type: time_conflict
message: Entry XY violates rule Z message: Entry XY violates rule Z
created: '2023-08-21T08:23:35Z' created: '2023-08-21T08:23:35Z'
modified: '2023-08-21T08:23:35Z' modified: '2023-08-21T08:23:35Z'
- id: 43 - id: 43
shipcall_id: 7 shipcall_id: 7
notification_type: email notification_type: time_conflict
message: Entry AB violates rule C message: Entry AB violates rule C
created: '2023-08-21T08:23:35Z' created: '2023-08-21T08:23:35Z'
modified: '2023-08-21T08:23:35Z' modified: '2023-08-21T08:23:35Z'
@ -1804,10 +1806,11 @@ components:
type: string type: string
description: Type of notification description: Type of notification
enum: enum:
- undefined - assignment
- email - next24h
- push - time_conflict
example: email - time_conflict_resolved
example: time_conflict
EvaluationType: EvaluationType:
description: Evaluation of the ship call description: Evaluation of the ship call
readOnly: true readOnly: true

View File

@ -31,7 +31,11 @@ def GetUser(options):
"last_name": data[0].last_name, "last_name": data[0].last_name,
"user_name": data[0].user_name, "user_name": data[0].user_name,
"user_phone": data[0].user_phone, "user_phone": data[0].user_phone,
"user_email": data[0].user_email "user_email": data[0].user_email,
"notify_email": data[0].notify_email,
"notify_whatsapp": data[0].notify_whatsapp,
"notify_signal": data[0].notify_signal,
"notify_popup": data[0].notify_popup
} }
token = jwt_handler.generate_jwt(payload=result, lifetime=120) # generate token valid 60 mins token = jwt_handler.generate_jwt(payload=result, lifetime=120) # generate token valid 60 mins
result["token"] = token # add token to user data result["token"] = token # add token to user data

View File

@ -35,7 +35,7 @@ def PutUser(schemaModel):
# should this be refactored? # should this be refactored?
# Also, what about the 'user_name'? # Also, what about the 'user_name'?
# 'participant_id' would also not trigger an update in isolation # 'participant_id' would also not trigger an update in isolation
if "first_name" in schemaModel or "last_name" in schemaModel or "user_phone" in schemaModel or "user_email" in schemaModel: if "first_name" in schemaModel or "last_name" in schemaModel or "user_phone" in schemaModel or "user_email" in schemaModel or "notify_email" in schemaModel or "notify_whatsapp" in schemaModel or "notify_signal" in schemaModel or "notify_popup" in schemaModel:
# query = SQLQuery.get_user_put(schemaModel) # query = SQLQuery.get_user_put(schemaModel)
query = "UPDATE user SET " query = "UPDATE user SET "
isNotFirst = False isNotFirst = False

View File

@ -65,18 +65,16 @@ class EvaluationType(IntEnum):
return cls.undefined return cls.undefined
class NotificationType(IntEnum): class NotificationType(IntEnum):
""" """
Any user has the attributes This type is not the way the user is informed but the type of the notification, e.g. time conflict, time conflict resolved, etc.
'notify_email' -> NotificationType.email It can be understood as an event type
'notify_popup' -> NotificationType.push
'notify_whatsapp' -> undeclared
'notify_signal' -> undeclared
""" """
undefined = 0
email = 1 assignment = 0
push = 2 next24h = 1
# whatsapp = 3 time_conflict = 2
# signal = 4 time_conflict_resolved = 3
@classmethod @classmethod
def _missing_(cls, value): def _missing_(cls, value):
@ -489,7 +487,10 @@ class UserSchema(Schema):
user_email = fields.String(allow_none=True, required=False, validate=[validate.Length(max=64)]) user_email = fields.String(allow_none=True, required=False, validate=[validate.Length(max=64)])
old_password = fields.String(allow_none=True, required=False, validate=[validate.Length(max=128)]) old_password = fields.String(allow_none=True, required=False, validate=[validate.Length(max=128)])
new_password = fields.String(allow_none=True, required=False, validate=[validate.Length(min=6, max=128)]) new_password = fields.String(allow_none=True, required=False, validate=[validate.Length(min=6, max=128)])
# #TODO: the user schema does not (yet) include the 'notify_' fields notify_email = fields.Bool(allow_none=True, required=False)
notify_whatsapp = fields.Bool(allow_none=True, required=False)
notify_signal = fields.Bool(allow_none=True, required=False)
notify_popup = fields.Bool(allow_none=True, required=False)
@validates("user_phone") @validates("user_phone")
def validate_user_phone(self, value): def validate_user_phone(self, value):
@ -542,10 +543,10 @@ class User:
user_phone: str user_phone: str
password_hash: str password_hash: str
api_key: str api_key: str
notify_email: bool # #TODO_clarify: should we use an IntFlag for multi-assignment? notify_email: bool
notify_whatsapp: bool # #TODO_clarify: should we use an IntFlag for multi-assignment? notify_whatsapp: bool
notify_signal: bool # #TODO_clarify: should we use an IntFlag for multi-assignment? notify_signal: bool
notify_popup: bool # #TODO_clarify: should we use an IntFlag for multi-assignment? notify_popup: bool
created: datetime created: datetime
modified: datetime modified: datetime