diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 1587cd61..a4830f2e 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -20,53 +20,12 @@ class WelcomeController < ApplicationController before_filter :entry_select_course, :entry_select_contest, :entry_select_user, :only => [:index] def index - # @news = News.latest User.current - # @projects = Project.latest User.current - #by young - (redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration] - if request.get? - session[:auth_source_registration] = nil - @user = User.new(:language => current_language.to_s) - else - user_params = params[:user] || {} - @user = User.new - @user.safe_attributes = user_params - @user.admin = false - @user.register - if session[:auth_source_registration] - @user.activate - @user.login = session[:auth_source_registration][:login] - @user.auth_source_id = session[:auth_source_registration][:auth_source_id] - if @user.save - session[:auth_source_registration] = nil - self.logged_user = @user - flash[:notice] = l(:notice_account_activated) - redirect_to my_account_path - end - else - @user.login = params[:user][:login] - unless user_params[:identity_url].present? && user_params[:password].blank? && user_params[:password_confirmation].blank? - @user.password, @user.password_confirmation = user_params[:password], user_params[:password_confirmation] - end + projectActive = Project.project_entities.active + @projectCount = projectActive.count + @projectPublicCount = projectActive.all_public.count + @projectHidenCount = @projectCount - @projectPublicCount - case Setting.self_registration - when '1' - register_by_email_activation(@user) - when '3' - register_automatically(@user) - else - register_manually_by_administrator(@user) - end - end - end - - #add by huang - # @memberships = @user.memberships.all(:conditions => Project.visible_condition(User.current)) - - # events = Redmine::Activity::Fetcher.new(User.current, :author => @user).events(nil, nil, :limit => 20) - # @events_by_day = events.group_by(&:event_date) - - # + @developerCount = User.developer.count end def robots diff --git a/app/models/user.rb b/app/models/user.rb index 4042fd84..674e774d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -123,10 +123,16 @@ class User < Principal ## end scope :teacher, -> { - joins(:user_extensions).where('user_extensions.identity = ?', 0) + joins(:user_extensions).where('user_extensions.identity = ?', UserExtensions::TEACHER) } scope :student, -> { - joins(:user_extensions).where('user_extensions.identity = ?', 1) + joins(:user_extensions).where('user_extensions.identity = ?', UserExtensions::STUDENT) + } + scope :developer, -> { + joins(:user_extensions).where('user_extensions.identity = ?', UserExtensions::DEVELOPER) + } + scope :enterprise, -> { + joins(:user_extensions).where('user_extensions.identity = ?', UserExtensions::ENTERPRISE) } attr_accessor :password, :password_confirmation diff --git a/app/views/welcome/course.html.erb b/app/views/welcome/course.html.erb index db1c1ea8..e9dc43ac 100644 --- a/app/views/welcome/course.html.erb +++ b/app/views/welcome/course.html.erb @@ -207,7 +207,12 @@
- +