-
Notifications
You must be signed in to change notification settings - Fork 500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AO3-6712 Allow invites to be resent and index invitee_email #4791
Open
weeklies
wants to merge
5
commits into
otwcode:master
Choose a base branch
from
weeklies:AO3-6712
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4b5ad3c
AO3-6712 Revert AO3-6666
weeklies faaae43
AO3-6712 Add invitee email index to invitations
weeklies a8b4965
AO3-6712 Make sure button has hover style and i18n
weeklies 02b8fe0
AO3-6712 Normalize
weeklies faf28e6
Merge branch 'master' into AO3-6712
weeklies File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
|
@@ -9,17 +9,40 @@ def index | |
# GET /invite_requests/1 | ||
def show | ||
@invite_request = InviteRequest.find_by(email: params[:email]) | ||
@position_in_queue = @invite_request.position if @invite_request.present? | ||
unless (request.xml_http_request?) || @invite_request | ||
flash[:error] = "You can search for the email address you signed up with below. If you can't find it, your invitation may have already been emailed to that address; please check your email spam folder as your spam filters may have placed it there." | ||
redirect_to status_invite_requests_path and return | ||
|
||
if @invite_request.present? | ||
@position_in_queue = @invite_request.position | ||
else | ||
@invitation = Invitation.unredeemed.from_queue.find_by(invitee_email: params[:email]) | ||
end | ||
|
||
respond_to do |format| | ||
format.html | ||
format.js | ||
end | ||
end | ||
|
||
def resend | ||
@invitation = Invitation.unredeemed.from_queue.find_by(invitee_email: params[:email]) | ||
|
||
if @invitation.nil? | ||
flash[:error] = t("invite_requests.resend.not_found") | ||
elsif [email protected]_resend? | ||
flash[:error] = t("invite_requests.resend.not_yet", | ||
count: ArchiveConfig.HOURS_BEFORE_RESEND_INVITATION) | ||
else | ||
@invitation.send_and_set_date(resend: true) | ||
|
||
if @invitation.errors.any? | ||
flash[:error] = @invitation.errors.full_messages.first | ||
else | ||
flash[:notice] = t("invite_requests.resend.success", email: @invitation.invitee_email) | ||
end | ||
end | ||
|
||
redirect_to status_invite_requests_path | ||
end | ||
|
||
# POST /invite_requests | ||
def create | ||
unless AdminSetting.current.invite_from_queue_enabled? | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<!--Descriptive page name, messages and instructions--> | ||
<h2 class="heading" id="invite-heading"> | ||
<%= t(".title", email: invitation.invitee_email) %> | ||
</h2> | ||
<!--/descriptions--> | ||
|
||
<!--main content--> | ||
<p> | ||
<% status = invitation.resent_at ? "resent" : "not_resent" %> | ||
<%= t(".info.#{status}", | ||
sent_at: l((invitation.sent_at || invitation.created_at).to_date), | ||
resent_at: invitation.resent_at ? l(invitation.resent_at.to_date) : nil) %> | ||
</p> | ||
|
||
<p> | ||
<% if invitation.can_resend? %> | ||
<%# i18n-tasks-use t("invite_requests.invitation.after_cooldown_period.not_resent") | ||
i18n-tasks-use t("invite_requests.invitation.after_cooldown_period.resent_html")-%> | ||
<% status = invitation.resent_at ? "resent_html" : "not_resent" %> | ||
<%= t(".after_cooldown_period.#{status}", | ||
count: ArchiveConfig.HOURS_BEFORE_RESEND_INVITATION, | ||
contact_support_link: link_to(t(".contact_support"), new_feedback_report_path)) %> | ||
<%= button_to t(".resend_button"), resend_invite_requests_path(email: invitation.invitee_email) %> | ||
<% else %> | ||
<%= t(".before_cooldown_period", count: ArchiveConfig.HOURS_BEFORE_RESEND_INVITATION) %> | ||
<% end %> | ||
</p> | ||
<!--/content--> |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<p class="notice"> | ||
<%= t(".email_not_found") %> | ||
</p> |
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,5 +1,11 @@ | ||
<%= render "invite_request", invite_request: @invite_request %> | ||
<% if @invite_request %> | ||
<%= render "invite_request", invite_request: @invite_request %> | ||
<% elsif @invitation %> | ||
<%= render "invitation", invitation: @invitation %> | ||
<% else %> | ||
<%= render "no_invitation" %> | ||
<% end %> | ||
|
||
<p> | ||
<%= ts("To check on the status of your invitation, go to the %{status_page} and enter your email in the space provided!", status_page: link_to("Invitation Request Status page", status_invite_requests_path)).html_safe %> | ||
<%= t(".instructions_html", status_link: link_to("Invitation Request Status page", status_invite_requests_path)) %> | ||
</p> |
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,5 +1,14 @@ | ||
<% if @invite_request %> | ||
$j("#invite-status").html("<%= escape_javascript(render "invite_requests/invite_request", invite_request: @invite_request) %>"); | ||
<% elsif @invitation %> | ||
$j("#invite-status").html("<%= escape_javascript(render "invitation", invitation: @invitation) %>"); | ||
|
||
<%# Correct heading size for JavaScript display %> | ||
$j(document).ready(function(){ | ||
$j('#invite-heading').replaceWith(function () { | ||
return '<h3 class="heading">' + $j(this).html() + "</h3>"; | ||
}); | ||
}) | ||
<% else %> | ||
$j("#invite-status").html("<p>Sorry, we can't find the email address you entered. If you had used it to join our invitation queue, it's possible that your invitation may have already been emailed to you; please check your spam folder, as your spam filters may have placed it there.</p>"); | ||
$j("#invite-status").html("<%= escape_javascript(render "no_invitation") %>"); | ||
<% 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
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
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 |
---|---|---|
|
@@ -80,6 +80,7 @@ | |
collection do | ||
get :manage | ||
get :status | ||
post :resend | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class AddResentAtToInvitations < ActiveRecord::Migration[6.1] | ||
uses_departure! if Rails.env.staging? || Rails.env.production? | ||
|
||
def change | ||
add_column :invitations, :resent_at, :datetime | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class AddIndexToInvitations < ActiveRecord::Migration[6.1] | ||
uses_departure! if Rails.env.staging? || Rails.env.production? | ||
|
||
def change | ||
add_index :invitations, :invitee_email | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,7 +57,7 @@ Feature: Invite queue management | |
# check your place in the queue - invalid address | ||
When I check how long "[email protected]" will have to wait in the invite request queue | ||
Then I should see "Invitation Request Status" | ||
And I should see "If you can't find it, your invitation may have already been emailed to that address; please check your email spam folder as your spam filters may have placed it there." | ||
And I should see "Sorry, we can't find the email address you entered." | ||
And I should not see "You are currently number" | ||
|
||
# check your place in the queue - correct address | ||
|
@@ -98,7 +98,7 @@ Feature: Invite queue management | |
Then 1 email should be delivered to [email protected] | ||
When I check how long "[email protected]" will have to wait in the invite request queue | ||
Then I should see "Invitation Request Status" | ||
And I should see "If you can't find it, your invitation may have already been emailed to that address;" | ||
And I should see "If you can't find it, please check your email spam folder as your spam filters may have placed it there." | ||
|
||
# invite can be used | ||
When I am logged in as an admin | ||
|
@@ -155,3 +155,29 @@ Feature: Invite queue management | |
And I fill in "invite_request_email" with "[email protected]" | ||
And I press "Add me to the list" | ||
Then I should see "Email is already being used by an account holder." | ||
|
||
Scenario: Users can resend their invitation after enough time has passed | ||
Given account creation is enabled | ||
And the invitation queue is enabled | ||
And account creation requires an invitation | ||
And the invite_from_queue_at is yesterday | ||
And an invitation request for "[email protected]" | ||
When the scheduled check_invite_queue job is run | ||
Then 1 email should be delivered to [email protected] | ||
|
||
When I check how long "[email protected]" will have to wait in the invite request queue | ||
Then I should see "Invitation Request Status" | ||
And I should see "If you can't find it, please check your email spam folder as your spam filters may have placed it there." | ||
And I should not see "Because your invitation was sent more than 24 hours ago, you can have your invitation resent." | ||
And I should not see a "Resend Invitation" button | ||
|
||
When all emails have been delivered | ||
And it is currently 25 hours from now | ||
And I check how long "[email protected]" will have to wait in the invite request queue | ||
Then I should see "Invitation Request Status" | ||
And I should see "If you can't find it, please check your email spam folder as your spam filters may have placed it there." | ||
And I should see "Because your invitation was sent more than 24 hours ago, you can have your invitation resent." | ||
And I should see a "Resend Invitation" button | ||
|
||
When I press "Resend Invitation" | ||
Then 1 email should be delivered to [email protected] |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Completely optional, nitpick: It would be nice if this also used count as the interpolation variable and had the one/other distinction in the locale.