add by nyan
This commit is contained in:
parent
2a72f7aac8
commit
b1fc33a697
|
@ -20,53 +20,12 @@ class WelcomeController < ApplicationController
|
||||||
before_filter :entry_select_course, :entry_select_contest, :entry_select_user, :only => [:index]
|
before_filter :entry_select_course, :entry_select_contest, :entry_select_user, :only => [:index]
|
||||||
|
|
||||||
def index
|
def index
|
||||||
# @news = News.latest User.current
|
projectActive = Project.project_entities.active
|
||||||
# @projects = Project.latest User.current
|
@projectCount = projectActive.count
|
||||||
#by young
|
@projectPublicCount = projectActive.all_public.count
|
||||||
(redirect_to(home_url); return) unless Setting.self_registration? || session[:auth_source_registration]
|
@projectHidenCount = @projectCount - @projectPublicCount
|
||||||
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
|
|
||||||
|
|
||||||
case Setting.self_registration
|
@developerCount = User.developer.count
|
||||||
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)
|
|
||||||
|
|
||||||
#
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def robots
|
def robots
|
||||||
|
|
|
@ -123,10 +123,16 @@ class User < Principal
|
||||||
## end
|
## end
|
||||||
|
|
||||||
scope :teacher, -> {
|
scope :teacher, -> {
|
||||||
joins(:user_extensions).where('user_extensions.identity = ?', 0)
|
joins(:user_extensions).where('user_extensions.identity = ?', UserExtensions::TEACHER)
|
||||||
}
|
}
|
||||||
scope :student, -> {
|
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
|
attr_accessor :password, :password_confirmation
|
||||||
|
|
|
@ -207,7 +207,12 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
|
<h3 style="margin-left: 5px; color: #e8770d;"><strong>当前网站状态</strong>
|
||||||
|
活跃课程: <%=@course.count%>
|
||||||
|
高校: 个
|
||||||
|
教师: <%=@teacher.count%> 名
|
||||||
|
学生: <%=@student.count%> 名
|
||||||
|
</h3>
|
||||||
<div style="padding-top: 40px"></div>
|
<div style="padding-top: 40px"></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -234,12 +234,18 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<br/><br/><br/><br/><br/><br/><br/>
|
||||||
|
|
||||||
<div class="clr">
|
<div class="clr">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<br/><br/><br/><br/><br/><br/><br/>
|
|
||||||
<div style="padding-top: 40px"></div>
|
<div style="padding-top: 40px"></div>
|
||||||
|
|
||||||
|
<div class="clearfix">
|
||||||
|
<h3 style="margin-left: 5px; color: #e8770d;">
|
||||||
|
<strong>当前网站状态</strong>
|
||||||
|
活跃项目: <%=@projectCount%>个
|
||||||
|
私有项目: <%=@projectHidenCount%>个
|
||||||
|
开发者: <%= @developerCount%>个
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue