Merge remote-tracking branch 'remotes/origin/szzh' into develop

This commit is contained in:
nwb 2014-07-03 17:30:45 +08:00
commit 1a666900c0
6 changed files with 54 additions and 20 deletions

View File

@ -30,6 +30,11 @@ class WelcomeController < ApplicationController
end end
def course def course
if params[:school_id]
@school_id = params[:school_id]
else
@school_id = User.current.user_extensions.school.id
end
@logoLink ||= logolink() @logoLink ||= logolink()
end end

View File

@ -67,6 +67,30 @@ module WatchersHelper
link_to text, url, :remote => true, :method => method, :class => css link_to text, url, :remote => true, :method => method, :class => css
end end
# add by nwb
# 关注课程
def new_course_watcher_link(objects, user, options=[])
return '' unless user && user.logged?
objects = Array.wrap(objects)
watched = objects.any? {|object| object.watched_by?(user)}
@watch_flag = (objects.first.instance_of?(User) or objects.first.instance_of?(Project) or (objects.first.instance_of?(Contest)))
css = @watch_flag ? ([watcher_css(objects), watched ? 'icon ' : 'icon '].join(' ') << options[0].to_s) :
([watcher_css(objects), watched ? 'icon icon-fav ' : 'icon icon-fav-off '].join(' ') << options[0].to_s)
text = @watch_flag ?
(watched ? l(:button_unfollow) : l(:button_follow)) : (watched ? l(:button_unwatch) : l(:button_watch))
url = watch_path(
:object_type => objects.first.class.to_s.underscore,
:object_id => (objects.size == 1 ? objects.first.id : objects.map(&:id).sort)
)
method = watched ? 'delete' : 'post'
link_to text, url, :remote => true, :method => method, :class => css
end
# added by fq, modify nyan # added by fq, modify nyan
# Somebody may use option params # Somebody may use option params
def join_in_course(course, user, options=[]) def join_in_course(course, user, options=[])

View File

@ -233,8 +233,9 @@ module WelcomeHelper
def find_all_new_hot_course limit = 9 ,school_id = 0 def find_all_new_hot_course limit = 9 ,school_id = 0
#sort_project_by_hot_rails 1, 'course_ac_para DESC', limit #sort_project_by_hot_rails 1, 'course_ac_para DESC', limit
time_now = Time.new.strftime("%Y"); time_now = Time.new.strftime("%Y");
Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <> courses = Course.visible.joins(:course_status).where("#{Course.table_name}.created_at like '%#{time_now}%' and #{Course.table_name}.school_id <>
?", school_id).order("course_ac_para DESC").limit(limit).all ?", school_id).order("course_ac_para DESC").limit(limit).all
courses
end end
def find_all_hot_bid def find_all_hot_bid

View File

@ -39,24 +39,24 @@
</div> </div>
<div class="course welcome_left" id="welcome_left" > <div class="course welcome_left" id="welcome_left" >
<span class="font_welcome_school"> <% if params[:school_id].nil? and User.current.user_extensions.school.nil? %> <span class="font_welcome_school"> <% if @school_id.nil? and User.current.user_extensions.school.nil? %>
<% else%> <% else%>
<% if params[:school_id] == "0" %> <% if @school_id == "0" %>
<% else %> <% else %>
<% if params[:school_id].nil? %> <% if @school_id.nil? %>
<%= link_to School.find(User.current.user_extensions.school.id).name, options={:action => 'course',:school_id => User.current.user_extensions.school.id}, html_options={:class => 'font_welcome_school',:method => 'get'}%> <%= link_to School.find(User.current.user_extensions.school.id).name, options={:action => 'course',:school_id => User.current.user_extensions.school.id}, html_options={:class => 'font_welcome_school',:method => 'get'}%>
<br /> <br />
<% else %> <% else %>
<%= link_to School.find(params[:school_id]).name ,options={:action => 'course',:school_id => params[:school_id]}, html_options={:class => 'font_welcome_school',:method => 'get'}%> <%= link_to School.find(@school_id).name ,options={:action => 'course',:school_id => @school_id}, html_options={:class => 'font_welcome_school',:method => 'get'}%>
<br /> <br />
<% end %> <% end %>
<% end %> <% end %>
<% end %> </span> <% end %> </span>
<span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> </span> <span class="font_welcome_trustie"><%= l(:label_welcome_trustie) %><%= l(:label_welcome_trustie_course) %> </span>
<% if params[:school_id].nil? and User.current.user_extensions.school.nil? %> <% if @school_id.nil? and User.current.user_extensions.school.nil? %>
<span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span> <span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span>
<% else %> <% else %>
<% if params[:school_id] == "0" %> <% if @school_id == "0" %>
<span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span> <span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span>
<% end %> <% end %>
<% end %> <% end %>
@ -73,7 +73,7 @@
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject"> <div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
<h3><strong>新开课程</strong></h3> <h3><strong>新开课程</strong></h3>
<% school_course = find_miracle_course(10, 7,params[:school_id]) %> <% school_course = find_miracle_course(10, 7,@school_id) %>
<% if(school_course.count == 0) %> <% if(school_course.count == 0) %>
<span><%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %></span> <span><%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %></span>
<div class="d-p-projectlist-box"> <div class="d-p-projectlist-box">
@ -86,7 +86,7 @@
该学校未开设任何课程,您可以查看其他学校课程 该学校未开设任何课程,您可以查看其他学校课程
</p> </p>
<h1></h1> <h1></h1>
<% find_all_new_hot_course(9,params[:school_id]).map do |project| %> <% find_all_new_hot_course(9,@school_id).map do |project| %>
<li class='<%= cycle("odd", "even") %>' title=<%=project.description.to_s%>> <li class='<%= cycle("odd", "even") %>' title=<%=project.description.to_s%>>
<div class='avatar'> <div class='avatar'>
<%= image_tag(get_course_avatar(project), :class => "avatar-4") %> <%= image_tag(get_course_avatar(project), :class => "avatar-4") %>
@ -94,7 +94,7 @@
<!-- 上左下右 --> <!-- 上左下右 -->
<div class='desc_item' > <div class='desc_item' >
<span class=''> <span class=''>
<% course = Course.find_by_extra(project.identifier)%> <% course = Course.find_by_extra(project.extra)%>
<% if(course.school == nil) %> <% if(course.school == nil) %>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<% else %> <% else %>
@ -116,13 +116,6 @@
<!-- <div class='desc_item' style=""> <!-- <div class='desc_item' style="">
<span class='font_lighter' title=<%#=project.description.to_s%>><%#=project.description.truncate(25, omission: '...')%></span> <span class='font_lighter' title=<%#=project.description.to_s%>><%#=project.description.truncate(25, omission: '...')%></span>
</div> --> </div> -->
<div>
<% if !course_endTime_timeout?(project)%>
<div >
<%= new_watcher_link(project, User.current)%>
</div>
<% end %>
</div>
</li> </li>
<% end %> <% end %>
</ul> </ul>
@ -134,7 +127,7 @@
</span> </span>
<% else %> <% else %>
<span> <span>
<%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => params[:school_id]} %> <%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => @school_id} %>
</span> </span>
<% end %> <% end %>
<div class="d-p-projectlist-box"> <div class="d-p-projectlist-box">
@ -181,7 +174,7 @@
该学校开设课程较少,您可以查看其他学校课程 该学校开设课程较少,您可以查看其他学校课程
</p> </p>
</li> </li>
<% find_all_new_hot_course(9 - school_course.count,params[:school_id]).map do |project| %> <% find_all_new_hot_course(9 - school_course.count,@school_id).map do |project| %>
<li class='<%= cycle("odd", "even") %>' title=<%=project.description.to_s%>> <li class='<%= cycle("odd", "even") %>' title=<%=project.description.to_s%>>
<div class='avatar'> <div class='avatar'>
<%= image_tag(get_course_avatar(project), :class => "avatar-4") %> <%= image_tag(get_course_avatar(project), :class => "avatar-4") %>

View File

@ -0,0 +1,11 @@
class ClearCourseData < ActiveRecord::Migration
def up
# 清理课程表垃圾数据
# 之前删除项目未删除课程的数据
sql = 'delete from courses where name is null and extra not in (select identifier from projects)'
execute(sql)
end
def down
end
end

View File

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20140701075839) do ActiveRecord::Schema.define(:version => 20140703085204) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false