From 4a182f8bbafd79b10cad179b11c7b241ee6223ae Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Wed, 5 Jun 2013 16:50:24 -0700 Subject: [PATCH 1/7] Fix spec doc; sends welcome email for active users --- spec/controllers/users_controller_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index f073db9515b..e1083197720 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -298,7 +298,7 @@ describe UsersController do User.any_instance.stubs(:active?).returns(true) end - it 'should enqueue a signup email' do + it 'enqueues a welcome email' do User.any_instance.expects(:enqueue_welcome_message).with('welcome_user') xhr :post, :create, name: @user.name, username: @user.username, password: "strongpassword", email: @user.email From e7b38fb1884816c238c10f35bf9c290180ee0cc4 Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Wed, 5 Jun 2013 17:09:22 -0700 Subject: [PATCH 2/7] Move duplicated request to helper method --- spec/controllers/users_controller_spec.rb | 46 +++++++++++++---------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index e1083197720..b8980c357f3 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -278,17 +278,25 @@ describe UsersController do DiscourseHub.stubs(:register_nickname).returns([true, nil]) end + def post_user + xhr :post, :create, + name: @user.name, + username: @user.username, + password: "strongpassword", + email: @user.email + end + context 'when creating a non active user (unconfirmed email)' do it 'should enqueue a signup email' do Jobs.expects(:enqueue).with(:user_email, has_entries(type: :signup)) - xhr :post, :create, name: @user.name, username: @user.username, - password: "strongpassword", email: @user.email + post_user end it "doesn't send a welcome email" do User.any_instance.expects(:enqueue_welcome_message).with('welcome_user').never - xhr :post, :create, name: @user.name, username: @user.username, - password: "strongpassword", email: @user.email + post_user + end + end end @@ -300,19 +308,24 @@ describe UsersController do it 'enqueues a welcome email' do User.any_instance.expects(:enqueue_welcome_message).with('welcome_user') - xhr :post, :create, name: @user.name, username: @user.username, - password: "strongpassword", email: @user.email + + post_user + end end it "should be logged in" do User.any_instance.expects(:enqueue_welcome_message) - xhr :post, :create, name: @user.name, username: @user.username, password: "strongpassword", email: @user.email + + post_user + session[:current_user_id].should be_present end it "returns true in the active part of the JSON" do User.any_instance.expects(:enqueue_welcome_message) - xhr :post, :create, name: @user.name, username: @user.username, password: "strongpassword", email: @user.email + + post_user + ::JSON.parse(response.body)['active'].should == true end @@ -320,7 +333,7 @@ describe UsersController do context 'when approving of users is required' do before do SiteSetting.expects(:must_approve_users).returns(true) - xhr :post, :create, name: @user.name, username: @user.username, password: "strongpassword", email: @user.email + post_user end it "doesn't log in the user" do @@ -344,8 +357,7 @@ describe UsersController do TwitterUserInfo.expects(:find_by_twitter_user_id).returns(nil) TwitterUserInfo.expects(:create) - xhr :post, :create, name: @user.name, username: @user.username, - password: "strongpassword", email: @user.email + post_user end it 'should create facebook user info if none exists' do @@ -354,8 +366,7 @@ describe UsersController do FacebookUserInfo.expects(:find_by_facebook_user_id).returns(nil) FacebookUserInfo.expects(:create!) - xhr :post, :create, name: @user.name, username: @user.username, - password: "strongpassword", email: @user.email + post_user end it 'should create github user info if none exists' do @@ -364,18 +375,13 @@ describe UsersController do GithubUserInfo.expects(:find_by_github_user_id).returns(nil) GithubUserInfo.expects(:create) - xhr :post, :create, name: @user.name, username: @user.username, - password: "strongpassword", email: @user.email + post_user end - end end context 'after success' do - before do - xhr :post, :create, name: @user.name, username: @user.username, - password: "strongpassword", email: @user.email - end + before { post_user } it 'should succeed' do should respond_with(:success) From 41b06925434de39db81d8cbc9ffff3b57a34b22f Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Wed, 5 Jun 2013 18:19:27 -0700 Subject: [PATCH 3/7] Show 'waiting approval' and don't send email When 'must approve users' in enabled, we don't want to send an activation email to users after they sign up. Instead, we will show them 'waiting approval' and not take an action until their account is approved by an admin. --- app/controllers/users_controller.rb | 32 ++++------- spec/controllers/users_controller_spec.rb | 70 +++++++++++++---------- 2 files changed, 53 insertions(+), 49 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 88ed557d8c2..f9684a99bca 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -161,35 +161,27 @@ class UsersController < ApplicationController end if user.save - msg = nil - active_user = user.active? - - if active_user - # If the user is active (remote authorized email) - if SiteSetting.must_approve_users? - msg = I18n.t("login.wait_approval") - active_user = false - else - log_on_user(user) - user.enqueue_welcome_message('welcome_user') - msg = I18n.t("login.active") - end - else - msg = I18n.t("login.activate_email", email: user.email) - Jobs.enqueue( - :user_email, type: :signup, user_id: user.id, + if SiteSetting.must_approve_users? + message = I18n.t("login.wait_approval") + elsif !user.active? + message = I18n.t("login.activate_email", email: user.email) + Jobs.enqueue(:user_email, + type: :signup, + user_id: user.id, email_token: user.email_tokens.first.token ) + else + message = I18n.t("login.active") + log_on_user(user) + user.enqueue_welcome_message('welcome_user') end - # Create 3rd party auth records (Twitter, Facebook, GitHub) create_third_party_auth_records(user, auth) if auth.present? # Clear authentication session. session[:authentication] = nil - # JSON result - render json: { success: true, active: active_user, message: msg } + render json: { success: true, active: user.active?, message: message } else render json: { success: false, diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index b8980c357f3..85c67c45850 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -287,62 +287,74 @@ describe UsersController do end context 'when creating a non active user (unconfirmed email)' do - it 'should enqueue a signup email' do + it 'enqueues a signup email' do Jobs.expects(:enqueue).with(:user_email, has_entries(type: :signup)) post_user end - it "doesn't send a welcome email" do + it 'does not enqueue a welcome email' do User.any_instance.expects(:enqueue_welcome_message).with('welcome_user').never post_user end + it 'indicates the user is not active in the response' do + post_user + expect(JSON.parse(response.body)['active']).to be_false + end + + context "and 'must approve users' site setting is enabled" do + before { SiteSetting.expects(:must_approve_users).returns(true) } + + it 'does not enqueue an email' do + Jobs.expects(:enqueue).never + post_user + end + + it 'does not login the user' do + post_user + expect(session[:current_user_id]).to be_blank + end + + it 'indicates the user is not active in the response' do + post_user + expect(JSON.parse(response.body)['active']).to be_false + end + + it "shows the 'waiting approval' message" do + post_user + expect(JSON.parse(response.body)['message']).to eq( + I18n.t 'login.wait_approval' + ) + end end end context 'when creating an active user (confirmed email)' do - - before do - User.any_instance.stubs(:active?).returns(true) - end + before { User.any_instance.stubs(:active?).returns(true) } it 'enqueues a welcome email' do User.any_instance.expects(:enqueue_welcome_message).with('welcome_user') - post_user end + + it "shows the 'active' message" do + User.any_instance.expects(:enqueue_welcome_message) + post_user + expect(JSON.parse(response.body)['message']).to eq( + I18n.t 'login.active' + ) end it "should be logged in" do User.any_instance.expects(:enqueue_welcome_message) - post_user - session[:current_user_id].should be_present end - it "returns true in the active part of the JSON" do + it 'indicates the user is active in the response' do User.any_instance.expects(:enqueue_welcome_message) - post_user - - ::JSON.parse(response.body)['active'].should == true - end - - - context 'when approving of users is required' do - before do - SiteSetting.expects(:must_approve_users).returns(true) - post_user - end - - it "doesn't log in the user" do - session[:current_user_id].should be_blank - end - - it "doesn't return active in the JSON" do - ::JSON.parse(response.body)['active'].should == false - end + expect(JSON.parse(response.body)['active']).to be_true end context 'authentication records for' do From 93fc0e74bc2b3d9fc457439789136b1c70825832 Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Wed, 5 Jun 2013 18:21:19 -0700 Subject: [PATCH 4/7] Test correct login behavior when pending approval --- spec/controllers/session_controller_spec.rb | 27 ++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/spec/controllers/session_controller_spec.rb b/spec/controllers/session_controller_spec.rb index 6ec78a5928a..857fad1d5ae 100644 --- a/spec/controllers/session_controller_spec.rb +++ b/spec/controllers/session_controller_spec.rb @@ -76,21 +76,42 @@ describe SessionController do it "doesn't log in the user" do session[:current_user_id].should be_blank end + + it "shows the 'not approved' error message" do + expect(JSON.parse(response.body)['error']).to eq( + I18n.t('login.not_approved') + ) + end end end end context 'when email has not been confirmed' do - before do + def post_login xhr :post, :create, login: user.email, password: 'myawesomepassword' end it "doesn't log in the user" do + post_login session[:current_user_id].should be_blank end - it 'returns an error message' do - ::JSON.parse(response.body)['error'].should be_present + it "shows the 'not activated' error message" do + post_login + expect(JSON.parse(response.body)['error']).to eq( + I18n.t 'login.not_activated' + ) + end + + context "and the 'must approve users' site setting is enabled" do + before { SiteSetting.expects(:must_approve_users?).returns(true) } + + it "shows the 'not approved' error message" do + post_login + expect(JSON.parse(response.body)['error']).to eq( + I18n.t 'login.not_approved' + ) + end end end end From f6ce985121944de46d107452f578951b16df7ff8 Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Wed, 5 Jun 2013 20:16:31 -0700 Subject: [PATCH 5/7] Send activation email after user approved --- app/mailers/user_notifications.rb | 9 +++++++++ app/models/user.rb | 11 +++++++++-- config/locales/server.cs.yml | 13 ------------- config/locales/server.da.yml | 13 ------------- config/locales/server.de.yml | 13 ------------- config/locales/server.en.yml | 31 ++++++++++++++++++------------- config/locales/server.es.yml | 13 ------------- config/locales/server.fr.yml | 13 ------------- config/locales/server.id.yml | 13 ------------- config/locales/server.it.yml | 13 ------------- config/locales/server.nl.yml | 13 ------------- config/locales/server.pseudo.yml | 12 ------------ config/locales/server.pt.yml | 13 ------------- config/locales/server.sv.yml | 13 ------------- config/locales/server.zh_CN.yml | 13 ------------- config/locales/server.zh_TW.yml | 13 ------------- spec/models/user_spec.rb | 6 ++++-- 17 files changed, 40 insertions(+), 185 deletions(-) diff --git a/app/mailers/user_notifications.rb b/app/mailers/user_notifications.rb index d2c6e9dcba5..d9680e3195a 100644 --- a/app/mailers/user_notifications.rb +++ b/app/mailers/user_notifications.rb @@ -10,6 +10,15 @@ class UserNotifications < ActionMailer::Base build_email(user.email, "user_notifications.signup", email_token: opts[:email_token]) end + def signup_after_approval(user, opts={}) + build_email( + user.email, + 'user_notifications.signup_after_approval', + email_token: opts[:email_token], + new_user_tips: SiteContent.content_for(:usage_tips) + ) + end + def authorize_email(user, opts={}) build_email(user.email, "user_notifications.authorize_email", email_token: opts[:email_token]) end diff --git a/app/models/user.rb b/app/models/user.rb index 558af07fde8..3b76c91b3f5 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -209,7 +209,8 @@ class User < ActiveRecord::Base self.approved = true self.approved_by = approved_by self.approved_at = Time.now - enqueue_welcome_message('welcome_approved') if save + + send_approval_email if save end def self.email_hash(email) @@ -615,7 +616,13 @@ class User < ActiveRecord::Base end end - + def send_approval_email + Jobs.enqueue(:user_email, + type: :signup_after_approval, + user_id: id, + email_token: email_tokens.first.token + ) + end end # == Schema Information diff --git a/config/locales/server.cs.yml b/config/locales/server.cs.yml index 43b224c6aa1..440f8d95dfd 100644 --- a/config/locales/server.cs.yml +++ b/config/locales/server.cs.yml @@ -800,19 +800,6 @@ cs: - Během čtení nějakého tématu se můžete kliknutím na název tématu v horní části stránky vrátit na začátek tématu. Chcete-li naopak skočit na *konec* tématu, klikněte na šipku dolů v indikátoru pozice v dolní části stránky, nebo klikněte na odkaz 'poslední příspěvek' v souhrnu tématu u prvního příspěvku. - welcome_approved: - subject_template: "Byl jste schválen na %{site_name}!" - text_body_template: | - Gratulujeme! - - Váš účet byl schválen a můžete se připojit na %{site_name}, vítejte na našem diskuzním fóru! - - %{new_user_tips} - - Věříme v [civilizované komunitní chování](%{base_url}/faq) za všech okolností. - - Užijte si naše fórum! - welcome_user: subject_template: "Vítejte na %{site_name}!" text_body_template: | diff --git a/config/locales/server.da.yml b/config/locales/server.da.yml index d54855235fa..04d482a9677 100644 --- a/config/locales/server.da.yml +++ b/config/locales/server.da.yml @@ -636,19 +636,6 @@ da: - Mens du læser et emne, kan du altid springe til toppen ved at klikke på emnets titel øverst på siden. For at komme til *bunden*, klik på ned-pilen på status-viseren nederst på skærmen, eller klik på sidste indlæg-feltet på emne-opsummeringen under det første indlæg. - welcome_approved: - subject_template: "Du er blevet godkendt på %{site_name}!" - text_body_template: | - Tillykke! - - Din brugerkonto på %{site_name} er blevet godkendt, velkommen til vores debatforum! - - %{new_user_tips} - - Vi går ind for [civiliseret debatkultur](%{base_url}/faq) til enhver tid. - - Nyd dit ophold! - welcome_user: subject_template: "Velkommen til %{site_name}!" text_body_template: | diff --git a/config/locales/server.de.yml b/config/locales/server.de.yml index fc91448894f..81d4c66c6bd 100644 --- a/config/locales/server.de.yml +++ b/config/locales/server.de.yml @@ -778,19 +778,6 @@ de: - Um an den Anfang eines Themas zu gelangen, klicke auf den Titel am oberen Rand der Seite. Um ans *Ende* zu springen, klicke auf den Abwärtspfeil in der Fortschrittsanzeige des Themas unten auf der Seite oder auf das Feld 'Letzter Beitrag' in der Zusammenfassung des Themas unter dem ersten Beitrag. - welcome_approved: - subject_template: "Du wurdest auf %{site_name} zugelassen!" - text_body_template: | - Glückwunsch! - - Du wurdest auf %{site_name} zugelassen, willkommen in unserem Forum! - - %{new_user_tips} - - Wir stehen für [zivilisiertes Verhalten in Online-Communitys](%{base_url}/faq). - - Viel Vergnügen! - welcome_user: subject_template: "Willkommen auf %{site_name}!" text_body_template: | diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index c26747ea424..fbdd34730f3 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -797,19 +797,6 @@ en: - While reading a topic, move to the top ↑ by clicking its title at the top of the page. To reach the *bottom* ↓, click the down arrow on the topic progress indicator at the bottom of the page, or click the last post field on the topic summary under the first post. - welcome_approved: - subject_template: "You've been approved on %{site_name}!" - text_body_template: | - Congratulations! - - You're approved to join %{site_name}, welcome to our discussion forum! - - %{new_user_tips} - - We believe in [civilized community behavior](%{base_url}/faq) at all times. - - Enjoy your stay! - welcome_user: subject_template: "Welcome to %{site_name}!" text_body_template: | @@ -975,6 +962,24 @@ en: %{base_url}/users/authorize-email/%{email_token} + signup_after_approval: + subject_template: "You've been approved on %{site_name}!" + text_body_template: | + Welcome to %{site_name}! + + You're approved to join %{site_name}, welcome to our discussion forum! + + Click the following link to confirm and activate your new account: + %{base_url}/users/activate-account/%{email_token} + + If the above link is not clickable, try copying and pasting it into the address bar of your web browser. + + %{new_user_tips} + + We believe in [civilized community behavior](%{base_url}/faq) at all times. + + Enjoy your stay! + signup: subject_template: "[%{site_name}] Activate your new account" text_body_template: | diff --git a/config/locales/server.es.yml b/config/locales/server.es.yml index dc6c2cac5d4..db21ab92d1a 100644 --- a/config/locales/server.es.yml +++ b/config/locales/server.es.yml @@ -618,19 +618,6 @@ es: - Mientras lees un topic, vuelve a lo más alto ↑ haciendo click en su título arriba de la página. Para alcanzar el *final* ↓, haz click en la flecha hacia abajo del indicador de prograso del topic al final de la página, or click the last post field on the topic summary under the first post. - welcome_approved: - subject_template: "¡Has sido aprobado en %{site_name}!" - text_body_template: | - ¡Enhorabuena! - - Has sido aprobado para unirte a %{site_name}, ¡Bienvenido a nuestro foro de discusión! - - %{new_user_tips} - - Creemos en [civilized community behavior](%{base_url}/faq) siempre. - - ¡Disfruta tu estancia! - welcome_user: subject_template: "Bienvenido a %{site_name}!" text_body_template: | diff --git a/config/locales/server.fr.yml b/config/locales/server.fr.yml index d8d79f3eb65..d112fd03c09 100644 --- a/config/locales/server.fr.yml +++ b/config/locales/server.fr.yml @@ -785,19 +785,6 @@ fr: - Pendant que vous lisez une discussion, vous pouvez retourner au début en cliquant sur son titre situé en haut de l'écran. Pour atteindre la *fin*, cliquez sur la flèche vers le bas sur l'indiquateur de progression en bas de la page, ou cliquez sur le champ "dernier message" dans le résumé de la discussion, sous le premier message. - welcome_approved: - subject_template: "Vous avez été accepté sur %{site_name} !" - text_body_template: | - Félicitations ! - - Vous avez été accepté pour rejoindre %{site_name}, bienvenue sur notre forum de discussions. - - %{new_user_tips} - - Nous croyons au [comportement communautaire civilisé](%{base_url}/faq) en tous temps. - - Amusez-vous bien ! - welcome_user: subject_template: "Bienvenue sur %{site_name} !" text_body_template: | diff --git a/config/locales/server.id.yml b/config/locales/server.id.yml index 7245a2a45e1..36b829ef890 100644 --- a/config/locales/server.id.yml +++ b/config/locales/server.id.yml @@ -639,19 +639,6 @@ id: - While reading a topic, move to the top ↑ by clicking its title at the top of the page. To reach the *bottom* ↓, click the down arrow on the topic progress indicator at the bottom of the page, or click the last post field on the topic summary under the first post. - welcome_approved: - subject_template: "You've been approved on %{site_name}!" - text_body_template: | - Congratulations! - - You're approved to join %{site_name}, welcome to our discussion forum! - - %{new_user_tips} - - We believe in [civilized community behavior](%{base_url}/faq) at all times. - - Enjoy your stay! - welcome_user: subject_template: "Welcome to %{site_name}!" text_body_template: | diff --git a/config/locales/server.it.yml b/config/locales/server.it.yml index 7c009cd04a1..f5436335ce1 100644 --- a/config/locales/server.it.yml +++ b/config/locales/server.it.yml @@ -765,19 +765,6 @@ it: - Mentre leggi un topic, puoi tornare in cima cliccando il titolo all'inizio della pagina. Per raggiungere il *fondo* invece, clicca la freccia in basso nella progress bar situata in fondo alla pagina, o clicca il campo ultimo post nel sommario presente nel primo post. - welcome_approved: - subject_template: "Il tuo account è stato approvato su %{site_name}!" - text_body_template: | - Congratulazioni! - - Il tuo account è stato approvato per accedere su %{site_name}, benvenuto nel nostro forum! - - %{new_user_tips} - - Crediamo nel [comportamento civilizzato della community](%{base_url}/faq) in ogni momento. - - Goditi la permanenza! - welcome_user: subject_template: "Benvenuto su %{site_name}!" text_body_template: | diff --git a/config/locales/server.nl.yml b/config/locales/server.nl.yml index 7f44c7b021f..90eff11e48a 100644 --- a/config/locales/server.nl.yml +++ b/config/locales/server.nl.yml @@ -791,19 +791,6 @@ nl: - Wanneer je een topic leest, kan je naar boven scrollen (↑) door op de topictitel bovenaan de pagina te klikken. Om de *onderkant* (↓) te bereiken klik je op de pijl naar beneden aan de onderkant van de pagina of je klikt op het Laatste Post-veld in de topicsamenvatting onder het eerste bericht. - welcome_approved: - subject_template: "Je aanmelding voor %{site_name} is goedgekeurd!" - text_body_template: | - Gefeliciteerd! - - Je aanvraag om lid te worden van %{site_name} is goedgekeurd, welkom op ons discussieforum! - - %{new_user_tips} - - We geloven altijd in [beschaafd gemeenschappelijk gedrag](%{base_url}/faq). - - Geniet van je verblijf! - welcome_user: subject_template: "Welkom bij %{site_name}!" text_body_template: | diff --git a/config/locales/server.pseudo.yml b/config/locales/server.pseudo.yml index 654ebb4b020..950b8b092c8 100644 --- a/config/locales/server.pseudo.yml +++ b/config/locales/server.pseudo.yml @@ -894,19 +894,7 @@ pseudo: - Ŵĥíłé řéáďíɳǧ á ťóƿíč, ɱóνé ťó ťĥé ťóƿ ↑ ƀý čłíčǩíɳǧ íťš ťíťłé áť ťĥé ťóƿ óƒ ťĥé ƿáǧé. Ťó řéáčĥ ťĥé *ƀóťťóɱ* ↓, čłíčǩ ťĥé ďóŵɳ ářřóŵ óɳ ťĥé ťóƿíč ƿřóǧřéšš íɳďíčáťóř áť ťĥé ƀóťťóɱ óƒ ťĥé ƿáǧé, óř čłíčǩ ťĥé łášť ƿóšť ƒíéłď óɳ ťĥé ťóƿíč šůɱɱářý ůɳďéř ťĥé ƒířšť ƿóšť. ]] - welcome_approved: - subject_template: '[[ Ýóů''νé ƀééɳ áƿƿřóνéď óɳ %{site_name}! ]]' - text_body_template: |- - [[ Čóɳǧřáťůłáťíóɳš! - Ýóů'řé áƿƿřóνéď ťó ʲóíɳ %{site_name}, ŵéłčóɱé ťó óůř ďíščůššíóɳ ƒóřůɱ! - - %{new_user_tips} - - Ŵé ƀéłíéνé íɳ [číνíłížéď čóɱɱůɳíťý ƀéĥáνíóř](%{base_url}/ƒáƣ) áť áłł ťíɱéš. - - Éɳʲóý ýóůř šťáý! - ]] welcome_user: subject_template: '[[ Ŵéłčóɱé ťó %{site_name}! ]]' text_body_template: |- diff --git a/config/locales/server.pt.yml b/config/locales/server.pt.yml index 42b5232a1be..3f77f5002d0 100644 --- a/config/locales/server.pt.yml +++ b/config/locales/server.pt.yml @@ -555,19 +555,6 @@ pt: - Enquanto estiveres a ler um tópico, podes mover para o topo clicando no título no topo da página. Para chegar ao fundo clica na seta na barra de prograsso no fundo da página, ou clica no último campo sumário do tópico debaixo do primeiro post. - welcome_approved: - subject_template: "Foste aprovado no %{site_name}!" - text_body_template: | - Parabéns! - - Estás aprovado para te juntares a %{site_name}, ben-vindo ao nosso foum! - - %{new_user_tips} - - Acreditamos num [comportamento civilizado na comunidade](%{base_url}/faq) a toda a hora. - - Diverte-te durante a estadia! - welcome_user: subject_template: "Welcome to %{site_name}!" text_body_template: | diff --git a/config/locales/server.sv.yml b/config/locales/server.sv.yml index cc5f21771dd..a68031c42a3 100644 --- a/config/locales/server.sv.yml +++ b/config/locales/server.sv.yml @@ -693,19 +693,6 @@ sv: - While reading a topic, move to the top ↑ by clicking its title at the top of the page. To reach the *bottom* ↓, click the down arrow on the topic progress indicator at the bottom of the page, or click the last post field on the topic summary under the first post. - welcome_approved: - subject_template: "You've been approved on %{site_name}!" - text_body_template: | - Congratulations! - - You're approved to join %{site_name}, welcome to our discussion forum! - - %{new_user_tips} - - We believe in [civilized community behavior](%{base_url}/faq) at all times. - - Enjoy your stay! - welcome_user: subject_template: "Welcome to %{site_name}!" text_body_template: | diff --git a/config/locales/server.zh_CN.yml b/config/locales/server.zh_CN.yml index e7ac902cfbc..40e2aab938e 100644 --- a/config/locales/server.zh_CN.yml +++ b/config/locales/server.zh_CN.yml @@ -763,19 +763,6 @@ zh_CN: - 当阅读一个主题时,你可以通过点击页面顶部的标题回到顶部;要去到 *底部*,点击页面底部的主题浏览进度指示器里的向下箭头,或者点击该主题第一帖下面的汇总信息里的最后一帖区域。 - welcome_approved: - subject_template: "你已经获得了 %{site_name} 的批准!" - text_body_template: | - 恭喜你! - - 你已经被批准加入 %{site_name},欢迎来到我们论坛参与讨论! - - %{new_user_tips} - - 我们始终相信 [文明的社会行为](%{base_url}/faq)。 - - 好好享受你在论坛的时光吧! - welcome_user: subject_template: "欢迎来到 %{site_name}!" text_body_template: | diff --git a/config/locales/server.zh_TW.yml b/config/locales/server.zh_TW.yml index 3ddeeea9d0b..d2cce05e6fd 100644 --- a/config/locales/server.zh_TW.yml +++ b/config/locales/server.zh_TW.yml @@ -763,19 +763,6 @@ zh_TW: - 當閱讀一個主題時,你可以通過點擊頁面頂部的標題回到頂部;要去到 *底部*,點擊頁面底部的主題浏覽進度指示器裏的向下箭頭,或者點擊該主題第一帖下面的彙總信息裏的最後一帖區域。 - welcome_approved: - subject_template: "你已經獲得了 %{site_name} 的批准!" - text_body_template: | - 恭喜你! - - 你已經被批准加入 %{site_name},歡迎來到我們論壇參與討論! - - %{new_user_tips} - - 我們始終相信 [文明的社會行爲](%{base_url}/faq)。 - - 好好享受你在論壇的時光吧! - welcome_user: subject_template: "歡迎來到 %{site_name}!" text_body_template: | diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 9925adadd8b..244e73c243c 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -94,8 +94,10 @@ describe User do let(:user) { Fabricate(:user) } let(:admin) { Fabricate(:admin) } - it "generates a welcome message" do - user.expects(:enqueue_welcome_message).with('welcome_approved') + it "enqueues a 'signup after approval' email" do + Jobs.expects(:enqueue).with( + :user_email, has_entries(type: :signup_after_approval) + ) user.approve(admin) end From d50a598e622f1004fa5e692a0bba4abfc82bf2df Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Wed, 5 Jun 2013 21:18:22 -0700 Subject: [PATCH 6/7] Notify admin of successful user approval --- app/assets/javascripts/admin/models/admin_user.js | 3 +++ .../javascripts/admin/templates/user.js.handlebars | 14 +++++++++----- config/locales/client.en.yml | 4 ++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/admin/models/admin_user.js b/app/assets/javascripts/admin/models/admin_user.js index c1377849a7f..414936be91e 100644 --- a/app/assets/javascripts/admin/models/admin_user.js +++ b/app/assets/javascripts/admin/models/admin_user.js @@ -228,6 +228,9 @@ Discourse.AdminUser.reopenClass({ user.set('can_approve', false); return user.set('selected', false); }); + + bootbox.alert(Em.String.i18n("admin.user.approve_bulk_success")); + return Discourse.ajax("/admin/users/approve-bulk", { type: 'PUT', data: { diff --git a/app/assets/javascripts/admin/templates/user.js.handlebars b/app/assets/javascripts/admin/templates/user.js.handlebars index ac283ddbeac..ab3d9c23ba5 100644 --- a/app/assets/javascripts/admin/templates/user.js.handlebars +++ b/app/assets/javascripts/admin/templates/user.js.handlebars @@ -59,11 +59,15 @@
- {{#if can_approve}} - + {{#if approved}} + {{i18n admin.user.approve_success}} + {{else}} + {{#if can_approve}} + + {{/if}} {{/if}}
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index cd91d85a2d0..cfca2cf8294 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -1131,6 +1131,10 @@ en: flags_received_count: Flags Received approve: 'Approve' approved_by: "approved by" + approve_success: "User approved and email sent with activation + instructions." + approve_bulk_success: "Success! All selected users have been approved + and notified." time_read: "Read Time" delete: "Delete User" delete_forbidden: "This user can't be deleted because there are posts. Delete all this user's posts first." From 2f59c5c513070a63302bccc8c8e093c25416267d Mon Sep 17 00:00:00 2001 From: Chris Hunt Date: Thu, 6 Jun 2013 07:51:33 -0700 Subject: [PATCH 7/7] Set line height on entire row, not two columns --- app/assets/stylesheets/admin/admin_base.scss | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/admin/admin_base.scss b/app/assets/stylesheets/admin/admin_base.scss index d6279712c5c..77f93888c5a 100644 --- a/app/assets/stylesheets/admin/admin_base.scss +++ b/app/assets/stylesheets/admin/admin_base.scss @@ -177,6 +177,8 @@ table { } .display-row { + height: 30px; + line-height: 30px; padding: 5px; &:nth-of-type(1) { border-top: 0; @@ -190,8 +192,6 @@ table { clear: both; } .field { - height: 30px; - line-height: 30px; font-weight: bold; width: 196px; float: left; @@ -199,8 +199,6 @@ table { } .value { width: 250px; - height: 30px; - line-height: 30px; float: left; margin-left: 12px; }