mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-01-13 05:10:59 +00:00
Fix logical flaw in match proposal msg texts
This commit is contained in:
parent
121c4fc29b
commit
1c22ba3482
1 changed files with 23 additions and 21 deletions
|
@ -25,16 +25,12 @@ class MatchProposalsController < ApplicationController
|
||||||
@proposal.team = cuser.team
|
@proposal.team = cuser.team
|
||||||
@proposal.status = MatchProposal::STATUS_PENDING
|
@proposal.status = MatchProposal::STATUS_PENDING
|
||||||
if @proposal.save
|
if @proposal.save
|
||||||
# TODO: send message to teamleaders of opposite team
|
|
||||||
msg = Message.new
|
|
||||||
msg.sender_type = 'System'
|
|
||||||
msg.recipient_type = 'Team'
|
|
||||||
msg.title = 'New Scheduling Proposal'
|
|
||||||
recipient = @match.get_opposing_team(cuser.team)
|
recipient = @match.get_opposing_team(cuser.team)
|
||||||
msg.recipient = recipient
|
msg_text = "There is a new scheduling proposal for your match against #{cuser.team.name}.\n" \
|
||||||
msg.text = "There is a new scheduling proposal for your match against #{recipient.name}.\n" \
|
|
||||||
"Find it [url=#{match_proposals_path(@match)}]here[/url]"
|
"Find it [url=#{match_proposals_path(@match)}]here[/url]"
|
||||||
msg.save
|
|
||||||
|
send_message_to_opp_team(msg_text, 'New Scheduling Proposal', recipient)
|
||||||
|
|
||||||
flash[:notice] = 'Created new proposal'
|
flash[:notice] = 'Created new proposal'
|
||||||
redirect_to(match_proposals_path(@match))
|
redirect_to(match_proposals_path(@match))
|
||||||
else
|
else
|
||||||
|
@ -67,14 +63,10 @@ class MatchProposalsController < ApplicationController
|
||||||
if proposal.save
|
if proposal.save
|
||||||
|
|
||||||
if status_updated
|
if status_updated
|
||||||
msg = Message.new
|
|
||||||
msg.sender_type = 'System'
|
|
||||||
msg.recipient_type = 'Team'
|
|
||||||
msg.title = 'Scheduling Proposal Update'
|
|
||||||
recipient = @match.get_opposing_team(cuser.team)
|
recipient = @match.get_opposing_team(cuser.team)
|
||||||
msg.recipient = recipient
|
msg_text = message_text(new_status)
|
||||||
msg.text = message_text(new_status, recipient)
|
|
||||||
msg.save if msg.text
|
send_message_to_opp_team(msg_text, 'Scheduling Proposal Update', recipient)
|
||||||
end
|
end
|
||||||
|
|
||||||
rjson[:status] = MatchProposal.status_strings[proposal.status]
|
rjson[:status] = MatchProposal.status_strings[proposal.status]
|
||||||
|
@ -94,22 +86,32 @@ private
|
||||||
@match = Match.find params[:match_id]
|
@match = Match.find params[:match_id]
|
||||||
end
|
end
|
||||||
|
|
||||||
def message_text(new_status, recipient)
|
def message_text(new_status)
|
||||||
case new_status
|
case new_status
|
||||||
when MatchProposal::STATUS_CONFIRMED
|
when MatchProposal::STATUS_CONFIRMED
|
||||||
"A scheduling proposal for your match against [b]#{recipient.name}[/b] was confirmed!.\n" \
|
"A scheduling proposal for your match against [b]#{cuser.team.name}[/b] was confirmed!.\n" \
|
||||||
"Find it [url=#{match_proposals_path(@match)}]here[/url]"
|
"Find it [url=#{match_proposals_path(@match)}]here[/url]"
|
||||||
when MatchProposal::STATUS_REJECTED
|
when MatchProposal::STATUS_REJECTED
|
||||||
"A scheduling proposal for your match against [b]#{recipient.name}[/b] was rejected!.\n" \
|
"A scheduling proposal for your match against [b]#{cuser.team.name}[/b] was rejected!.\n" \
|
||||||
"Find it [url=#{match_proposals_path(@match)}]here[/url]"
|
"Find it [url=#{match_proposals_path(@match)}]here[/url]"
|
||||||
when MatchProposal::STATUS_REVOKED
|
when MatchProposal::STATUS_REVOKED
|
||||||
"A scheduling proposal for your match against [b]#{recipient.name}[/b] was revoked!.\n" \
|
"A scheduling proposal for your match against [b]#{cuser.team.name}[/b] was revoked!.\n" \
|
||||||
"Find it [url=#{match_proposals_path(@match)}]here[/url]"
|
"Find it [url=#{match_proposals_path(@match)}]here[/url]"
|
||||||
when MatchProposal::STATUS_DELAYED
|
when MatchProposal::STATUS_DELAYED
|
||||||
"Delaying for your match against [b]#{recipient.name}[/b] was permitted!.\n" \
|
"Delaying for your match against [b]#{cuser.team.name}[/b] was permitted!.\n" \
|
||||||
"Schedule a new time as soon as possible [url=#{match_proposals_path(@match)}]here[/url]"
|
"Schedule a new time as soon as possible [url=#{match_proposals_path(@match)}]here[/url]"
|
||||||
else
|
else
|
||||||
false # Should not happen as transition to any other state is not allowed
|
false # Should not happen as transition to any other state is not allowed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def send_message_to_opp_team(text, title, recipient_team)
|
||||||
|
msg = Message.new
|
||||||
|
msg.sender_type = 'System'
|
||||||
|
msg.recipient_type = 'Team'
|
||||||
|
msg.title = title
|
||||||
|
msg.recipient = recipient_team
|
||||||
|
msg.text = text
|
||||||
|
msg.save if text
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue