-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enhance invitation handling: add development token generation, improv…
…e email sending logic, and update show view layout
- Loading branch information
Showing
4 changed files
with
44 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,26 @@ | ||
class InvitationsController < ApplicationController | ||
|
||
def show | ||
if Rails.env.development? && params[:token].blank? | ||
# make a new invitation for development | ||
@invitation = Invitation.create!(email: '[email protected]', project_allocation: ProjectAllocation.first) | ||
redirect_to invitation_path(token: @invitation.token) and return | ||
end | ||
@invitation = Invitation.find_by_token(params[:token]) | ||
raise ActiveRecord::RecordNotFound unless @invitation | ||
end | ||
|
||
def accept | ||
@invitation = Invitation.find_by_token(params[:token]) | ||
invitation.accept! | ||
redirect_to invitation_path(@invitation.token) | ||
raise ActiveRecord::RecordNotFound unless @invitation | ||
@invitation.accept! | ||
redirect_to invitation_path(token: @invitation.token) | ||
end | ||
|
||
def reject | ||
@invitation = Invitation.find_by_token(params[:token]) | ||
invitation.reject! | ||
redirect_to invitation_path(@invitation.token) | ||
raise ActiveRecord::RecordNotFound unless @invitation | ||
@invitation.reject! | ||
redirect_to invitation_path(token: @invitation.token) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,29 @@ | ||
<h1>Accept or reject the invitation!</h1> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-lg-8 page-content"> | ||
<h1 class="page-content__title display-2">Accept or reject the invitation!</h1> | ||
|
||
<% if @invitation.expired? %> | ||
<% if @invitation.expired? %> | ||
|
||
<p>This invitation has expired</p> | ||
<p>This invitation has expired</p> | ||
|
||
<% else %> | ||
<% else %> | ||
|
||
<p>Accept confirmation button</p> | ||
<% if @invitation.accepted? %> | ||
<p>This invitation has already been accepted</p> | ||
<% end %> | ||
|
||
<p>or they can update their funding.yml and we'll check it again</p> | ||
<% if @invitation.rejected? %> | ||
<p>This invitation has already been rejected</p> | ||
<% end %> | ||
|
||
<p>also an option to reject</p> | ||
<%= button_to 'Accept Invitation', accept_invitation_path(token: @invitation.token) %> | ||
|
||
<p>if it's been accepted/rejected already then show a message</p> | ||
<p>or they can update their funding.yml and we'll check it again</p> | ||
|
||
<% end %> | ||
<%= button_to 'Reject Invitation', reject_invitation_path(token: @invitation.token) %> | ||
|
||
<% end %> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters