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]
|
||||
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -207,7 +207,12 @@
|
|||
</div>
|
||||
</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>
|
||||
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@
|
|||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<!-- <div id="J_Slide" class="d-p-index-box d-p-index-hotproject" style="float: right;">
|
||||
<h3 style="margin-left: 5px; color: color: (51, 119, 51);"><strong>热门竞赛</strong></h3>
|
||||
<span style="margin-top: -20px;float: right; display: block;"><%= link_to "更多>>", {:controller => 'bids', :action => 'contest', :project_type => 1, :host => Setting.contest_domain}, :target => "_blank" %></span>
|
||||
|
@ -234,12 +234,18 @@
|
|||
|
||||
|
||||
|
||||
<br/><br/><br/><br/><br/><br/><br/>
|
||||
|
||||
<div class="clr">
|
||||
</div>
|
||||
|
||||
|
||||
<br/><br/><br/><br/><br/><br/><br/>
|
||||
<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