Skip to content

Commit

Permalink
EAS-2419 Added rejected_by_api_key_id column to broadcast_message tab…
Browse files Browse the repository at this point in the history
…le (#181)

* Added migration version for new broadcast_message rejection columns

* Fixed value too long error

* Updated broadcast_message model to include rejection columns

* Added rejected_at & rejected_by attributes to BroadcastMessage model

* Added rejection_reason attribute to update_broadcast_message_status_schema

* Sourcing rejection_reason from request for updating broadcast message

* Added logic for rejection status in update_broadcast_message_status

* Added rejected_at column to table

* Added two new routes & functions for retrieving broadcast messages and messages with user joins

* Renamed migration version

* Added test for updated update_status function

* Updated endpoints

* Added sample user and service for tests

* Added tests

* Added rest tests

* Adjusted test

* Adjusted tests to add more assertions

* Added detail to dao functions

* Renamed revision

* Swapped the endpoint urls

* Updated migration version

* Created new update status function for accepting rejection reason

* Created new tests for new updated status function

* Revised migration version

* Removed irrelevant assertion from test

* Adjusted error response text

* Added foreign key contraint for rejected_by_id

* Changing utils source to commit to verify utils fix

* Reverting utils source

* Added rejected_by_api_key_id field that's updated with api key rejection

* Added rejected_by_api_key_id to serialize method for admin
  • Loading branch information
leylayaltiligil authored Jan 6, 2025
1 parent f276035 commit f66d831
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/broadcast_message/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ def update_broadcast_message_status(
broadcast_message.rejected_at = datetime.utcnow()
broadcast_message.rejected_by = updating_user
broadcast_message.rejection_reason = rejection_reason
broadcast_message.rejected_by_api_key_id = api_key_id

current_app.logger.info(
f"broadcast_message {broadcast_message.id} moving from {broadcast_message.status} to {new_status}"
Expand Down
3 changes: 3 additions & 0 deletions app/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,8 @@ class BroadcastMessage(db.Model):
cancelled_by_api_key_id = db.Column(UUID(as_uuid=True), db.ForeignKey("api_keys.id"), nullable=True)
created_by_api_key = db.relationship("ApiKey", foreign_keys=[created_by_api_key_id])
cancelled_by_api_key = db.relationship("ApiKey", foreign_keys=[cancelled_by_api_key_id])
rejected_by_api_key_id = db.Column(UUID(as_uuid=True), db.ForeignKey("api_keys.id"), nullable=True)
rejected_by_api_key = db.relationship("ApiKey", foreign_keys=[rejected_by_api_key_id])

reference = db.Column(db.String(255), nullable=True)
cap_event = db.Column(db.String(255), nullable=True)
Expand Down Expand Up @@ -926,6 +928,7 @@ def serialize(self):
"cancelled_by_id": get_uuid_string_or_none(self.cancelled_by_id),
"rejected_by_id": get_uuid_string_or_none(self.rejected_by_id),
"rejection_reason": self.rejection_reason if self.rejection_reason else None,
"rejected_by_api_key_id": self.rejected_by_api_key_id or None,
}


Expand Down

0 comments on commit f66d831

Please sign in to comment.