Merge remote-tracking branch 'remotes/origin/szzh' into develop
This commit is contained in:
commit
1a666900c0
|
@ -30,6 +30,11 @@ class WelcomeController < ApplicationController
|
|||
end
|
||||
|
||||
def course
|
||||
if params[:school_id]
|
||||
@school_id = params[:school_id]
|
||||
else
|
||||
@school_id = User.current.user_extensions.school.id
|
||||
end
|
||||
@logoLink ||= logolink()
|
||||
end
|
||||
|
||||
|
|
|
@ -67,6 +67,30 @@ module WatchersHelper
|
|||
|
||||
link_to text, url, :remote => true, :method => method, :class => css
|
||||
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
|
||||
# Somebody may use option params
|
||||
def join_in_course(course, user, options=[])
|
||||
|
|
|
@ -233,8 +233,9 @@ module WelcomeHelper
|
|||
def find_all_new_hot_course limit = 9 ,school_id = 0
|
||||
#sort_project_by_hot_rails 1, 'course_ac_para DESC', limit
|
||||
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
|
||||
courses
|
||||
end
|
||||
|
||||
def find_all_hot_bid
|
||||
|
|
|
@ -39,24 +39,24 @@
|
|||
|
||||
</div>
|
||||
<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%>
|
||||
<% if params[:school_id] == "0" %>
|
||||
<% if @school_id == "0" %>
|
||||
<% 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'}%>
|
||||
<br />
|
||||
<% 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 />
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %> </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>
|
||||
<% else %>
|
||||
<% if params[:school_id] == "0" %>
|
||||
<% if @school_id == "0" %>
|
||||
<span class="font_welcome_tdescription">, <%= l(:label_welcome_trustie_course_description) %></span>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
@ -73,7 +73,7 @@
|
|||
|
||||
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
|
||||
<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) %>
|
||||
<span><%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => nil} %></span>
|
||||
<div class="d-p-projectlist-box">
|
||||
|
@ -86,7 +86,7 @@
|
|||
该学校未开设任何课程,您可以查看其他学校课程
|
||||
</p>
|
||||
<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%>>
|
||||
<div class='avatar'>
|
||||
<%= image_tag(get_course_avatar(project), :class => "avatar-4") %>
|
||||
|
@ -94,7 +94,7 @@
|
|||
<!-- 上左下右 -->
|
||||
<div class='desc_item' >
|
||||
<span class=''>
|
||||
<% course = Course.find_by_extra(project.identifier)%>
|
||||
<% course = Course.find_by_extra(project.extra)%>
|
||||
<% if(course.school == nil) %>
|
||||
|
||||
<% else %>
|
||||
|
@ -116,13 +116,6 @@
|
|||
<!-- <div class='desc_item' style="">
|
||||
<span class='font_lighter' title=<%#=project.description.to_s%>><%#=project.description.truncate(25, omission: '...')%></span>
|
||||
</div> -->
|
||||
<div>
|
||||
<% if !course_endTime_timeout?(project)%>
|
||||
<div >
|
||||
<%= new_watcher_link(project, User.current)%>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
@ -134,7 +127,7 @@
|
|||
</span>
|
||||
<% else %>
|
||||
<span>
|
||||
<%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => params[:school_id]} %>
|
||||
<%= link_to "更多>>", {:controller => 'courses', :action => 'index', :school_id => @school_id} %>
|
||||
</span>
|
||||
<% end %>
|
||||
<div class="d-p-projectlist-box">
|
||||
|
@ -181,7 +174,7 @@
|
|||
该学校开设课程较少,您可以查看其他学校课程
|
||||
</p>
|
||||
</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%>>
|
||||
<div class='avatar'>
|
||||
<%= image_tag(get_course_avatar(project), :class => "avatar-4") %>
|
||||
|
|
|
@ -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
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# 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|
|
||||
t.integer "act_id", :null => false
|
||||
|
|
Loading…
Reference in New Issue