Skip to content

Commit

Permalink
implement notify finance feature
Browse files Browse the repository at this point in the history
  • Loading branch information
mutoromike committed Mar 22, 2019
1 parent 611bcfe commit aa91a76
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/api/endpoints/redemption_requests/redemption_numeration.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from api.utils.helpers import response_builder
from api.utils.marshmallow_schemas import basic_info_schema
from api.services.slack_notify import SlackNotification
from api.models import Role, User


# import from this package
Expand Down Expand Up @@ -71,6 +72,21 @@ def put(self, redeem_id=None):
society.used_points = redemp_request
redemp_request.status = status

# Send slack notification to finance users
finance_users = User.query.filter(User.roles.any(Role.name=="finance")).all()
for user in finance_users:
if user.center_id == redemp_request.center_id:
user_email = user.email
message = f"Redemption Request on *{redemp_request.name}* for " + \
f"*{redemp_request.society.name}* has been " + \
f"approved. Click the link: " + \
f"{request.host_url + 'api/v1/societies/redeem/' + redeem_id} " + \
f"to view more details"
slack_id = SlackNotification.get_slack_id(self, user_email)
SlackNotification.send_message(self, message, slack_id)
else:
pass

# Get the relevant Finance Center to respond on RedemptionRequest
center_emails = {"kampala": ".finance@andela.com"}
finance_email = redemp_request.center.name.lower() + \
Expand Down

0 comments on commit aa91a76

Please sign in to comment.