From 8af1ea81f636672014be28b45eaad4edcb7e32b9 Mon Sep 17 00:00:00 2001 From: Tallys Martins Date: Thu, 14 Aug 2014 22:20:54 -0300 Subject: [PATCH] AI3036 Fixed bugs on User Moderation --- app/controllers/public/account_controller.rb | 11 ++--------- app/models/create_user.rb | 2 +- app/models/user.rb | 16 ++++++++++------ app/views/account/signup.html.erb | 15 ++++++++++----- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/app/controllers/public/account_controller.rb b/app/controllers/public/account_controller.rb index 4cc0e30..b5b45e6 100644 --- a/app/controllers/public/account_controller.rb +++ b/app/controllers/public/account_controller.rb @@ -24,12 +24,7 @@ class AccountController < ApplicationController render :action => 'login', :userlogin => @user.login end else - @task = CreateUser.new - @task.user_id = @user.id - @task.name = @user.name - @task.email =@user.email - @task.target = @user.environment - if @task.save + if @user.create_moderate_task session[:notice] = _('Thanks for registering. The administrators were notified.') @register_pending = true @user.activation_code = nil @@ -124,10 +119,8 @@ class AccountController < ApplicationController self.current_user = @user check_join_in_community(@user) go_to_signup_initial_page - elsif environment.enabled?('skip_new_user_email_confirmation') && environment.enabled?('admin_must_approve_new_users') - session[:notice] = _('Thanks for registering. The administrators were notified.') - redirect_to :controller => 'home', :action => 'index' else + session[:notice] = _('Thanks for registering!') @register_pending = true end end diff --git a/app/models/create_user.rb b/app/models/create_user.rb index f095813..1c80b4c 100644 --- a/app/models/create_user.rb +++ b/app/models/create_user.rb @@ -21,7 +21,7 @@ class CreateUser < Task end def perform - user=User.find_by_id(user_id) + user=environment.users.find_by_id(user_id) user.activate end diff --git a/app/models/user.rb b/app/models/user.rb index 914fc18..ba2f3bf 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -51,12 +51,7 @@ class User < ActiveRecord::Base unless user.environment.enabled?('admin_must_approve_new_users') user.activate else - @task = CreateUser.new - @task.user_id = user.id - @task.name = user.name - @task.email = user.email - @task.target = user.environment - @task.save + create_moderate_task end end end @@ -146,6 +141,15 @@ class User < ActiveRecord::Base end end + def create_moderate_task + @task = CreateUser.new + @task.user_id = self.id + @task.name = self.name + @task.email = self.email + @task.target = self.environment + @task.save + end + def activated? self.activation_code.nil? && !self.activated_at.nil? end diff --git a/app/views/account/signup.html.erb b/app/views/account/signup.html.erb index 595d5f3..8168878 100644 --- a/app/views/account/signup.html.erb +++ b/app/views/account/signup.html.erb @@ -3,13 +3,18 @@ <% if environment.has_custom_welcome_screen? %> <%= environment.settings[:signup_welcome_screen_body].html_safe %> <% elsif environment.enabled?('admin_must_approve_new_users')%> -

<%= _("Welcome to %s!") % environment.name %>

+

<%= _("Welcome to %s!") % environment.name %>

<%= _("Thanks for signing up, we're thrilled to have you on our social network!") %>

<%= _("Firstly, some tips for getting started:") %>

-

<%= _("Confirm your account!") %>

-

<%= _("You should receive a welcome email from us shortly. Please take a second to follow the link within to confirm your account.") %>

-

<%= _("After your confirmation the administrators will be able to approve your signup request.") %>

-

<%= _("You won't appear as %s until your account is confirmed and approved.") % link_to(_('user'), {:controller => :search, :action => :people, :filter => 'more_recent'}, :target => '_blank') %>

+ <% unless environment.enabled?('skip_new_user_email_confirmation') %> +

<%= _("Confirm your account and wait for admin approvement!") %>

+

<%= _("You should receive a welcome email from us shortly. Please take a second to follow the link within to confirm your account.") %>

+

<%= _("You won't appear as %s until your account is confirmed and approved.") % link_to(_('user'), {:controller => :search, :action => :people, :filter => 'more_recent'}, :target => '_blank') %>

+ <% else %> +

<%= _("Wait for admin approvement!") %>

+

<%= _("The administrators will evaluate your signup request for approvement.") %>

+

<%= _("You won't appear as %s until your account is approved.") % link_to(_('user'), {:controller => :search, :action => :people, :filter => 'more_recent'}, :target => '_blank') %>

+ <% end %>

<%= _("What to do next?") %>

<%= _("%s. Upload an avatar and let your friends find you easily :)") % link_to(_('Customize your profile'), {:controller => 'doc', :section => 'user', :topic => 'editing-person-info'}, :target => '_blank') %>

<%= _("Learn the guidelines. Read the %s for more details on how to use this social network!") % link_to(_('Documentation'), {:controller => 'doc'}, :target => '_blank') %>

-- libgit2 0.21.2