Use a partial to share code between mobile and desktop, add the new route to the RegistrationController, drop flash message for closed registrations
This commit is contained in:
parent
469983a623
commit
4feab5219e
17 changed files with 91 additions and 94 deletions
|
|
@ -106,26 +106,3 @@ ul#help_nav {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ball{
|
||||
background: image-url('branding/ball.png') no-repeat;
|
||||
background-size: contain;
|
||||
height: 633px;
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.v-center {
|
||||
display: table;
|
||||
height: 633px;
|
||||
}
|
||||
|
||||
.content {
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
|
||||
h2 {
|
||||
font-size: 35px;
|
||||
margin: 12px;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
.page-registrations.action-new,
|
||||
.page-registrations.action-create {
|
||||
.page-registrations {
|
||||
.ball {
|
||||
background: image-url('branding/ball.png') no-repeat;
|
||||
background-size: contain;
|
||||
|
|
@ -12,19 +11,24 @@
|
|||
height: 633px;
|
||||
}
|
||||
|
||||
@media (max-width: $screen-xs-max) {
|
||||
.v-center {
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
|
||||
h2 {
|
||||
h1 {
|
||||
font-size: 35px;
|
||||
margin: 12px;
|
||||
text-align: center;
|
||||
margin: 12px 0;
|
||||
}
|
||||
}
|
||||
|
||||
form {
|
||||
max-width: 400px;
|
||||
max-width: 500px;
|
||||
}
|
||||
|
||||
.captcha-img {
|
||||
|
|
|
|||
|
|
@ -5,9 +5,9 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class RegistrationsController < Devise::RegistrationsController
|
||||
before_action :check_registrations_open_or_valid_invite!
|
||||
before_action :check_registrations_open_or_valid_invite!, except: :registrations_closed
|
||||
|
||||
layout -> { request.format == :mobile ? "application" : "with_header" }
|
||||
layout -> { request.format == :mobile ? "application" : "with_header_with_footer" }
|
||||
|
||||
def create
|
||||
@user = User.build(user_params)
|
||||
|
|
@ -28,17 +28,17 @@ class RegistrationsController < Devise::RegistrationsController
|
|||
end
|
||||
end
|
||||
|
||||
def registrations_closed
|
||||
render "registrations/registrations_closed"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_registrations_open_or_valid_invite!
|
||||
return true if AppConfig.settings.enable_registrations? || invite.try(:can_be_used?)
|
||||
|
||||
if params[:invite]
|
||||
flash[:error] = t("registrations.invalid_invite")
|
||||
redirect_to new_user_session_path
|
||||
else
|
||||
redirect_to registration_closed_path
|
||||
end
|
||||
flash[:error] = t("registrations.invalid_invite") if params[:invite]
|
||||
redirect_to registrations_closed_path
|
||||
end
|
||||
|
||||
def invite
|
||||
|
|
|
|||
|
|
@ -1,25 +0,0 @@
|
|||
- content_for :page_title do
|
||||
= AppConfig.settings.pod_name + " - " + t("devise.shared.links.sign_up_closed")
|
||||
|
||||
.container
|
||||
.row
|
||||
.col-md-10.offset1
|
||||
.col-md-7.hidden-phone
|
||||
%h1.ball
|
||||
.col-md-5.v-center
|
||||
.content
|
||||
%h2
|
||||
= t("devise.shared.links.sign_up_closed")
|
||||
|
||||
!= t("help.closed_pod",
|
||||
wiki: link_to("another pod", "https://diasporafoundation.org/getting_started/sign_up"))
|
||||
|
||||
!= t("help.find_pods",
|
||||
poduptime: link_to("Poduptime", "https://podupti.me/"))
|
||||
|
||||
!= t("help.other_questions",
|
||||
wiki: link_to("Wiki", "https://wiki.diasporafoundation.org/Choosing_a_pod"))
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
- if mobile
|
||||
%legend
|
||||
= image_tag("branding/logos/header-logo2x.png", height: 40, width: 40)
|
||||
= t("aspects.aspect_stream.make_something")
|
||||
= AppConfig.settings.pod_name
|
||||
|
||||
- if mobile
|
||||
= f.label :email, t("registrations.new.email"), class: "control-label", id: "emailLabel"
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
#registration
|
||||
.container
|
||||
.row
|
||||
.col-md-10.offset1
|
||||
.col-md-7.hidden-phone
|
||||
%h1.ball
|
||||
.col-md-5.v-center
|
||||
.col-sm-6.hidden-xs
|
||||
.ball
|
||||
.col-sm-6.col-xs-12.v-center
|
||||
.content.text-center
|
||||
%h2#pod-name
|
||||
%h1#pod-name
|
||||
= AppConfig.settings.pod_name
|
||||
|
||||
= render partial: "form", locals: {mobile: false}
|
||||
|
|
|
|||
8
app/views/registrations/registrations_closed.haml
Normal file
8
app/views/registrations/registrations_closed.haml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
#registration
|
||||
.container
|
||||
.row
|
||||
.col-sm-6.hidden-xs
|
||||
.ball
|
||||
.col-sm-6.col-xs-12.v-center
|
||||
.content
|
||||
= render partial: "registrations_closed"
|
||||
10
app/views/registrations/registrations_closed.mobile.haml
Normal file
10
app/views/registrations/registrations_closed.mobile.haml
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
|
||||
.stream#main-stream
|
||||
- flash.each do |name, msg|
|
||||
.expose#flash-container
|
||||
.flash-message{class: "message alert alert-#{flash_class name}", role: "alert"}
|
||||
= msg
|
||||
|
||||
.login-form
|
||||
.login-container
|
||||
= render partial: "registrations_closed"
|
||||
|
|
@ -347,7 +347,7 @@ en:
|
|||
tutorial: "tutorial"
|
||||
irc: "IRC"
|
||||
closed_pod: "This pod is currently closed to new registrations. However, you can still join the diaspora* network by registering on %{wiki}. Because all pods are interconnected, you will have access to the same content there."
|
||||
find_pods: "You can find pods at %{poduptime}."
|
||||
find_pods: "There’s a list of pods you can sign up to at %{poduptime}."
|
||||
other_questions: "If you have any other questions regarding choosing a pod, check out our %{wiki}."
|
||||
choose_another: "Please, choose another pod"
|
||||
wiki: "wiki"
|
||||
|
|
|
|||
|
|
@ -129,6 +129,7 @@ Rails.application.routes.draw do
|
|||
devise_scope :user do
|
||||
get "/users/sign_up" => "registrations#new", :as => :new_user_registration
|
||||
post "/users" => "registrations#create", :as => :user_registration
|
||||
get "/registrations_closed" => "registrations#registrations_closed", :as => :registrations_closed
|
||||
end
|
||||
|
||||
get "users/invitations" => "invitations#new", :as => "new_user_invitation"
|
||||
|
|
@ -205,7 +206,6 @@ Rails.application.routes.draw do
|
|||
|
||||
# Help
|
||||
get 'help' => 'help#faq', :as => 'help'
|
||||
get "help/registration_closed" => "help#registration_closed", :as => "registration_closed"
|
||||
get 'help/:topic' => 'help#faq'
|
||||
|
||||
#Protocol Url
|
||||
|
|
|
|||
|
|
@ -98,11 +98,11 @@ Feature: new user registration
|
|||
Then I should not be able to sign up
|
||||
And I should have a validation error on "user_password, user_password_confirmation"
|
||||
|
||||
Scenario: User signs up with an already existing username and email and then tries to sign in (Issue #6136)
|
||||
Scenario: User signs up with an already existing username and email and then tries to sign in
|
||||
When I log out manually
|
||||
And I go to the new user registration page
|
||||
And I fill in the new user form with an existing email and username
|
||||
And I fill in the new user form
|
||||
And I submit the form
|
||||
Then I should see a flash message indicating failure
|
||||
When I click the sign in button
|
||||
When I follow "Sign in"
|
||||
Then I should not see a flash message indicating failure
|
||||
24
features/desktop/registrations.feature
Normal file
24
features/desktop/registrations.feature
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
@javascript
|
||||
Feature: New user registration
|
||||
In order to use Diaspora*
|
||||
As a desktop user
|
||||
I want to register an account
|
||||
|
||||
Scenario: user signs up and goes to getting started
|
||||
Given I am on the new user registration page
|
||||
When I fill in the new user form
|
||||
And I press "Create account"
|
||||
Then I should be on the getting started page
|
||||
And I should see the 'getting started' contents
|
||||
|
||||
Scenario: registrations are closed, user is informed
|
||||
Given the registrations are closed
|
||||
When I am on the new user registration page
|
||||
Then I should see "Open signups are closed at this time"
|
||||
|
||||
Scenario: User is unable to register even by manually sending the POST request
|
||||
Given I am on the new user registration page
|
||||
When I fill in the new user form
|
||||
Given the registrations are closed
|
||||
When I press "Create account"
|
||||
Then I should see "Open signups are closed at this time"
|
||||
|
|
@ -5,8 +5,7 @@ Feature: New user registration
|
|||
I want to register an account
|
||||
|
||||
Background:
|
||||
Given I am on the login page
|
||||
And I follow "Create account" within "#main-nav"
|
||||
Given I am on the new user registration page
|
||||
|
||||
Scenario: user signs up and goes to getting started
|
||||
When I fill in the new user form
|
||||
|
|
@ -74,3 +74,11 @@ end
|
|||
Then (/^I should see the 'getting started' contents$/) do
|
||||
confirm_getting_started_contents
|
||||
end
|
||||
|
||||
Given /^the registrations are closed$/ do
|
||||
AppConfig.settings.enable_registrations = false
|
||||
end
|
||||
|
||||
When /^I fill in the new user form$/ do
|
||||
fill_in_new_user_form
|
||||
end
|
||||
|
|
|
|||
|
|
@ -218,20 +218,12 @@ When /^I view "([^\"]*)"'s first post$/ do |email|
|
|||
visit post_path(post)
|
||||
end
|
||||
|
||||
When /^I fill in the new user form/ do
|
||||
fill_in_new_user_form
|
||||
end
|
||||
|
||||
And /^I should be able to friend "([^\"]*)"$/ do |email|
|
||||
user = User.find_by_email(email)
|
||||
step 'I should see a ".aspect-dropdown"'
|
||||
step "I should see \"#{user.name}\""
|
||||
end
|
||||
|
||||
When /^I click the sign in button$/ do
|
||||
click_link "Sign in"
|
||||
end
|
||||
|
||||
Given /^I did request my photos$/ do
|
||||
@me.perform_export_photos!
|
||||
end
|
||||
|
|
|
|||
|
|
@ -25,14 +25,14 @@ describe RegistrationsController, type: :controller do
|
|||
AppConfig.settings.enable_registrations = false
|
||||
end
|
||||
|
||||
it "redirects #new to the registration closed page" do
|
||||
it "redirects #new to the registrations closed page" do
|
||||
get :new
|
||||
expect(response).to redirect_to registration_closed_path
|
||||
expect(response).to redirect_to registrations_closed_path
|
||||
end
|
||||
|
||||
it "redirects #create to the registration closed page" do
|
||||
it "redirects #create to the registrations closed page" do
|
||||
post :create, params: valid_params
|
||||
expect(response).to redirect_to registration_closed_path
|
||||
expect(response).to redirect_to registrations_closed_path
|
||||
end
|
||||
|
||||
it "does not redirect if there is a valid invite token" do
|
||||
|
|
@ -43,7 +43,8 @@ describe RegistrationsController, type: :controller do
|
|||
|
||||
it "does redirect if there is an invalid invite token" do
|
||||
get :new, params: {invite: {token: "fssdfsd"}}
|
||||
expect(response).to redirect_to new_user_session_path
|
||||
expect(flash[:error]).to eq(I18n.t("registrations.invalid_invite"))
|
||||
expect(response).to redirect_to registrations_closed_path
|
||||
end
|
||||
|
||||
it "does redirect if there are no invites available with this code" do
|
||||
|
|
@ -51,7 +52,7 @@ describe RegistrationsController, type: :controller do
|
|||
code.update_attributes(count: 0)
|
||||
|
||||
get :new, params: {invite: {token: code.token}}
|
||||
expect(response).to redirect_to new_user_session_path
|
||||
expect(response).to redirect_to registrations_closed_path
|
||||
end
|
||||
|
||||
it "does redirect when invitations are closed now" do
|
||||
|
|
@ -59,7 +60,7 @@ describe RegistrationsController, type: :controller do
|
|||
AppConfig.settings.invitations.open = false
|
||||
|
||||
get :new, params: {invite: {token: code.token}}
|
||||
expect(response).to redirect_to new_user_session_path
|
||||
expect(response).to redirect_to registrations_closed_path
|
||||
end
|
||||
|
||||
it "does not redirect when the registration is open" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue