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

This commit is contained in:
nwb 2014-07-05 09:34:34 +08:00
commit efbffa7436
16 changed files with 46 additions and 46 deletions

View File

@ -281,12 +281,11 @@ class CoursesController < ApplicationController
if @school_id == "0" or @school_id.nil? if @school_id == "0" or @school_id.nil?
@courses_all = Course.active.visible. @courses_all = Course.active.visible.
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id"). joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id").
where("#{Course.table_name}.course_type = ? ", Course::CourseType_course)
else else
@courses_all = Course.active.visible. @courses_all = Course.active.visible.
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id"). joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id").
joins(:course_extra). joins(:course_extra).
where("#{Course.table_name}.course_type = ? AND #{Course.table_name}.school_id = ?", Course::CourseType_course, @school_id) where("#{Course.table_name}.school_id = ?", @school_id)
end end
@course_count = @courses_all.count @course_count = @courses_all.count
@ -407,8 +406,7 @@ class CoursesController < ApplicationController
else else
@courses_all = Course.active.visible. @courses_all = Course.active.visible.
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id"). joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id").
joins(:course_extra). where("#{Course.table_name}.school_id = ?", @school_id)
where("#{Course.table_name}.course_type = ? AND #{Course.table_name}.school_id = ?", Course::CourseType_course, @school_id)
end end
@course_count = @courses_all.count @course_count = @courses_all.count

View File

@ -87,8 +87,11 @@ class MessagesController < ApplicationController
call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply}) call_hook(:controller_messages_reply_after_save, { :params => params, :message => @reply})
attachments = Attachment.attach_files(@reply, params[:attachments]) attachments = Attachment.attach_files(@reply, params[:attachments])
render_attachment_warning_if_needed(@reply) render_attachment_warning_if_needed(@reply)
else
#render file: 'messages#show', layout: 'base_courses'
end end
redirect_to board_message_path(@board, @topic, :r => @reply) redirect_to board_message_path(@board, @topic, :r => @reply)
end end
# Edit a message # Edit a message

View File

@ -141,27 +141,26 @@ module WelcomeHelper
Course.active.visible. Course.active.visible.
joins(:memberships). joins(:memberships).
group('members.course_id'). group('members.course_id').
reorder("courses.time DESC, COUNT(members.course_id) DESC").take sum reorder("courses.created_at DESC, COUNT(members.course_id) DESC").take sum
else else
if school_id.nil? if school_id.nil?
Course.active.visible. Course.active.visible.
joins(:memberships). joins(:memberships).
where("#{Course.table_name}.school_id = ?", User.current.user_extensions.school.id). where("#{Course.table_name}.school_id = ?", User.current.user_extensions.school.id).
group('members.course_id'). group('members.course_id').
reorder("courses.time DESC, COUNT(members.course_id) DESC").take sum reorder("courses.created_at DESC, COUNT(members.course_id) DESC").take sum
else else
if school_id == "0" if school_id == "0"
Course.active.visible. Course.active.visible.
joins(:memberships). joins(:memberships).
group('members.course_id'). group('members.course_id').
reorder("courses.time DESC, COUNT(members.course_id) DESC").take sum reorder("courses.created_at DESC, COUNT(members.course_id) DESC").take sum
else else
Course.active.visible. Course.active.visible.
joins(:memberships). joins(:memberships).
where("#{Course.table_name}.school_id = ?", school_id). where("#{Course.table_name}.school_id = ?", school_id).
group('members.course_id'). group('members.course_id').
reorder("courses.time DESC, COUNT(members.course_id) DESC").take sum reorder("courses.created_at DESC, COUNT(members.course_id) DESC").take sum
end end
end end
end end

View File

@ -274,6 +274,7 @@ class Course < ActiveRecord::Base
end end
end end
#项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题
def name def name
read_attribute('name') || Project.find_by_identifier(self.extra).try(:name) read_attribute('name') || Project.find_by_identifier(self.extra).try(:name)
end end

View File

@ -46,6 +46,8 @@ class Mailer < ActionMailer::Base
when :Project when :Project
return -1 if journals_for_message.jour.project_type == Project::ProjectType_project return -1 if journals_for_message.jour.project_type == Project::ProjectType_project
project_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") project_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
when :Course
course_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
when :Contest when :Contest
show_contest_contest_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}") show_contest_contest_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
when :User when :User
@ -54,9 +56,10 @@ class Mailer < ActionMailer::Base
Rails.logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}" Rails.logger.error "[Builds a Mail::Message ERROR] journalsForMessage's jour is unkown type, journalsForMessage.id = #{journals_for_message.id}"
return -1 return -1
end end
#如果是直接留言并且留言对象是Project并且Project类型是课程 # modify by nwb
if !journals_for_message.at_user && journals_for_message.jour.class.to_s.to_sym == :Project && journals_for_message.jour.project_type == 1 #如果是直接留言并且留言对象是课程
project = journals_for_message.jour if !journals_for_message.at_user && journals_for_message.jour.class.to_s.to_sym == :Course
course = journals_for_message.jour
@author = journals_for_message.user @author = journals_for_message.user
#课程的教师 #课程的教师
@teachers = searchTeacherAndAssistant journals_for_message.jour @teachers = searchTeacherAndAssistant journals_for_message.jour

View File

@ -42,7 +42,7 @@ class Repository < ActiveRecord::Base
validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true validates_uniqueness_of :identifier, :scope => :project_id, :allow_blank => true
validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph) validates_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph)
# donwcase letters, digits, dashes, underscores but not digits only # donwcase letters, digits, dashes, underscores but not digits only
validates_format_of :identifier, :with => /\A(?!\d+$)[a-z0-9\-_]*\z/, :allow_blank => true validates_format_of :identifier, :with => /^[a-zA-Z0-9_\-]+$/, :allow_blank => true
# Checks if the SCM is enabled when creating a repository # Checks if the SCM is enabled when creating a repository
validate :repo_create_validation, :on => :create validate :repo_create_validation, :on => :create

View File

@ -1,6 +1,6 @@
<!-- fq --> <!-- fq -->
<% is_student = is_cur_course_student(@bid.courses.first) %> <% is_student = is_cur_course_student(@bid.courses.first) %>
<% is_teacher = is_course_teacher User.current,@bid.courses.first %> <% is_teacher = is_course_teacher(User.current,@bid.courses.first) %>
<!-- 当is_evaluation为1或者null(null主要是为了兼容前面数据)时代表启用互评功能2表示未启用 --> <!-- 当is_evaluation为1或者null(null主要是为了兼容前面数据)时代表启用互评功能2表示未启用 -->
<% is_evaluation = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %> <% is_evaluation = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %>
<%= form_tag(:controller => 'bids', :action => "show_courseEx", :method => :get) do %> <%= form_tag(:controller => 'bids', :action => "show_courseEx", :method => :get) do %>
@ -21,7 +21,6 @@
<% end %> <% end %>
</div> </div>
</td> </td>
</tr> </tr>
</table> </table>
</div> </div>

View File

@ -42,11 +42,11 @@
<div class="box" id="content1"> <div class="box" id="content1">
<%= form_for(@homework) do |f|%> <%= form_for(@homework) do |f|%>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;"> <p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong>标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题:</strong>&nbsp; <strong>标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题&nbsp;<span style="color: red">*</span></strong>&nbsp;
<%= f.text_field :name, :required => true, :name => "homework_name", :size => 60, :style => "width:490px;"%> <%= f.text_field :name, :required => true, :name => "homework_name", :size => 60, :style => "width:490px;"%>
</p> </p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;"> <p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong>提交项目:</strong> <strong>提交项目&nbsp;&nbsp;</strong>
<% if @homework.project.nil? %> <% if @homework.project.nil? %>
<%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true%> <%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true%>
<% else %> <% else %>
@ -57,7 +57,7 @@
<p class="font_lighter" style="padding-left:120px;clear:left;">提交项目可以为空</p> <p class="font_lighter" style="padding-left:120px;clear:left;">提交项目可以为空</p>
</p> </p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;"> <p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong style="vertical-align: top">描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述:</strong>&nbsp; <strong style="vertical-align: top">描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述&nbsp;&nbsp;</strong>&nbsp;
<span style="margin-left:-10px;padding-right: 20px;"> <span style="margin-left:-10px;padding-right: 20px;">
<%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %> <%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
</span> </span>

View File

@ -23,17 +23,17 @@
:bid_id => @bid :bid_id => @bid
}) do |f|%> }) do |f|%>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;"> <p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong>标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题:</strong> <strong>标&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;题&nbsp;<span style="color: red">*</span></strong>
<%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %> <%= f.text_field "name", :required => true, :size => 60, :style => "width:490px;" %>
</p> </p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;"> <p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong>提交项目:</strong> <strong>提交项目&nbsp;&nbsp;</strong>
<%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true, :style => "width:490px;"%> <%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true, :style => "width:490px;"%>
<%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %> <%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %>
<p class="font_lighter" style="padding-left:120px;clear:left;">提交项目可以为空</p> <p class="font_lighter" style="padding-left:120px;clear:left;">提交项目可以为空</p>
</p> </p>
<p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;"> <p style=" padding: 3px 0 3px 0;padding-left: 50px; clear:left;">
<strong style="vertical-align: top">描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述:</strong> <strong style="vertical-align: top">描&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述&nbsp;&nbsp;</strong>
<span style="margin-left:-10px;padding-right: 20px;"> <span style="margin-left:-10px;padding-right: 20px;">
<%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %> <%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
</span> </span>

View File

@ -167,7 +167,7 @@
<tr> <tr>
<td valign="top" style="padding-left: 8px;"><%= l(:label_teacher_work_unit) %> :</td> <td valign="top" style="padding-left: 8px;"><%= l(:label_teacher_work_unit) %> :</td>
<!-- modified by zjc 教师单位添加超链接 --> <!-- modified by zjc 教师单位添加超链接 -->
<td class="font_lighter_sidebar"><%= link_to @course.teacher.user_extensions.school,options={:controller => 'welcome',:action => 'course',:school_id => @course.teacher.user_extensions.school.id}, html_options={:method => 'get'} %></td> <td class="font_lighter_sidebar"><a href="http://course.trustie.net/?school_id=<%= @course.teacher.user_extensions.school.id%>"><%= @course.teacher.user_extensions.school %></a></td>
</tr> </tr>
<% else %> <% else %>
<tr> <tr>

View File

@ -121,7 +121,7 @@
<td valign="top" style="padding-left: 8px;"><%= l(:label_teacher_work_unit) %> :</td> <td valign="top" style="padding-left: 8px;"><%= l(:label_teacher_work_unit) %> :</td>
<!-- modified by zjc 有@user.user_extensions.occupation改为 @user.user_extensions.school 并添加超链接 --> <!-- modified by zjc 有@user.user_extensions.occupation改为 @user.user_extensions.school 并添加超链接 -->
<% unless @user.user_extensions.nil? || @user.user_extensions.school.nil? %> <% unless @user.user_extensions.nil? || @user.user_extensions.school.nil? %>
<td class="font_lighter_sidebar"><%= link_to @user.user_extensions.school,options={:controller => 'welcome',:action => 'course',:school_id => @user.user_extensions.school.id}, html_options={:method => 'get'} %></td> <td class="font_lighter_sidebar"><%= link_to @user.user_extensions.school,"http://course.trustie.net/?school_id=#{@user.user_extensions.school.id}" %></td>
<% end %> <% end %>
</tr> </tr>
</table> </table>

View File

@ -168,7 +168,7 @@
<div class="user_underline"></div> <div class="user_underline"></div>
<!--info--> <!--info-->
<div class="inf_user_context"> <div class="inf_user_context">
<table style="font-family:微软雅黑" width="240"> <table style="font-family:'微软雅黑'" width="240">
<tr> <tr>
<td style="padding-left: 5px" width="70px"><%= l(:label_user_joinin) %></td><td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"><%= format_time(@user.created_on) %></td> <td style="padding-left: 5px" width="70px"><%= l(:label_user_joinin) %></td><td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"><%= format_time(@user.created_on) %></td>
</tr> </tr>
@ -178,7 +178,7 @@
<!-- <!--
<tr> <tr>
<td valign="top" style="padding-left: 5px;"><%= l(:label_user_mail) %></td><td class="font_lighter_sidebar" style="padding-left: 0px; word-wrap: break-word; word-break: break-all"><%= mail_to(h(@user.mail), nil, :encode => 'javascript') %></td> <td valign="top" style="padding-left: 5px;"><%#= l(:label_user_mail) %></td><td class="font_lighter_sidebar" style="padding-left: 0px; word-wrap: break-word; word-break: break-all"><%#= mail_to(h(@user.mail), nil, :encode => 'javascript') %></td>
</tr> </tr>
--> -->
<!-- added by bai 在个人主页里显示“工作单位”“地区”"教师的职称"--> <!-- added by bai 在个人主页里显示“工作单位”“地区”"教师的职称"-->
@ -189,7 +189,7 @@
<tr> <tr>
<td style="padding-left: 5px" width="70px"><%= l(:field_occupation) %></td><td class="font_lighter_sidebar" style="padding-left: 0px" width="170px"> <td style="padding-left: 5px" width="70px"><%= l(:field_occupation) %></td><td class="font_lighter_sidebar" style="padding-left: 0px" width="170px">
<% unless @user.user_extensions.school.nil? %> <% unless @user.user_extensions.school.nil? %>
<%= link_to @user.user_extensions.school.name, options={:controller => 'welcome',:action => 'course',:school_id => @user.user_extensions.school.id}, html_options={:method => 'get'} %> <a href="http://course.trustie.net/?school_id=<%= @user.user_extensions.school.id%>"><%= @user.user_extensions.school.name %></a>
<% end %> <% end %>
</td> </td>
</tr> </tr>

View File

@ -43,7 +43,7 @@
<script type="text/javascript"> <script type="text/javascript">
function test(id){ function test(id){
location.href = encodeURI('/course/'+id); location.href = encodeURI('http://course.trustie.net/?school_id='+id);
} }
</script> </script>
@ -71,7 +71,7 @@
<p> <p>
<%= link_to "全部学校",school_index_path %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <%= link_to "全部学校",school_index_path %>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<%= link_to '我的学校',school_course_list_path(User.current.user_extensions.school) if User.current.logged? %> <a href="http://course.trustie.net">我的学校</a>
</p> </p>
<ul> <ul>
<li style="width: 40%; float: left">请选择省份: <li style="width: 40%; float: left">请选择省份:

View File

@ -1,7 +1,6 @@
<!-- added by bai --> <!-- added by bai -->
<div class="autoscroll"> <div class="autoscroll">
<% for user in @users -%> <% for user in @users -%>
<% unless user.id == 1%>
<!-- added by bai --> <!-- added by bai -->
<% messages_count = user.messages.count %> <% messages_count = user.messages.count %>
<% messages_score = messages_count * 0.05%> <% messages_score = messages_count * 0.05%>
@ -51,15 +50,12 @@
</div> </div>
<div class="user-bottom"> <div class="user-bottom">
<% unless user.memberships.empty? %>
<% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %> <% cond = Project.visible_condition(User.current) + " AND projects.project_type <> 1" %>
<% memberships = user.memberships.all(:conditions => cond) %> <% memberships = user.memberships.all(:conditions => cond) %>
<%= l(:label_x_contribute_to, :count => memberships.count) %> <%= l(:label_x_contribute_to, :count => memberships.count) %>
<% for member in memberships %> <% for member in memberships %>
<%= link_to_project(member.project) %><%= (user.memberships.last == member) ? '' : '' %> <%= link_to_project(member.project) %><%= (memberships.last == member) ? '' : '' %>
<% end %> <% end %>
<% end %>
<p> <p>
<%# unless user.memberships.empty? %> <%# unless user.memberships.empty? %>
<%# cond = Project.visible_condition(User.current) + " AND projects.project_type = 1" %> <%# cond = Project.visible_condition(User.current) + " AND projects.project_type = 1" %>
@ -74,9 +70,8 @@
<%# end %> <%# end %>
</p> </p>
<%= user.changesets.count == 0 ? '' : "#{l(:label_x_total_commit, :count => user.changesets.count)}" %> <%= l(:label_x_total_commit, :count => user.changesets.count) %>
</div> </div>
</div> </div>
<% end -%> <% end -%>
<% end -%>
</div> </div>

View File

@ -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>
<% if @school_id %> <% if @school_id %>
<% school_course = find_miracle_course(10, 7, @school_id) %> <% school_course = find_miracle_course(10,7, @school_id) %>
<% else %> <% else %>
<%school_course=[]%> <%school_course=[]%>
<% end %> <% end %>
@ -138,6 +138,7 @@
</ul> </ul>
<ul class="d-p-projectlist"> <ul class="d-p-projectlist">
<% school_course.map do |course| %> <% school_course.map do |course| %>
<% if course.school%>
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s %>> <li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s %>>
<div class='avatar'> <div class='avatar'>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %> <%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
@ -167,6 +168,7 @@
<% end %> <% end %>
</div> </div>
</li> </li>
<%end%>
<% end; reset_cycle %> <% end; reset_cycle %>
<% if school_course.count < 9 %> <% if school_course.count < 9 %>
<li> <li>

View File

@ -796,18 +796,18 @@ ActiveRecord::Schema.define(:version => 20140704034832) do
create_table "relative_memos", :force => true do |t| create_table "relative_memos", :force => true do |t|
t.integer "osp_id" t.integer "osp_id"
t.integer "parent_id" t.integer "parent_id"
t.string "subject", :null => false t.string "subject", :null => false
t.text "content", :limit => 16777215, :null => false t.text "content", :null => false
t.integer "author_id" t.integer "author_id"
t.integer "replies_count", :default => 0 t.integer "replies_count", :default => 0
t.integer "last_reply_id" t.integer "last_reply_id"
t.boolean "lock", :default => false t.boolean "lock", :default => false
t.boolean "sticky", :default => false t.boolean "sticky", :default => false
t.boolean "is_quote", :default => false t.boolean "is_quote", :default => false
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.integer "viewed_count_crawl", :default => 0 t.integer "viewed_count_crawl", :default => 0
t.integer "viewed_count_local", :default => 0 t.integer "viewed_count_local", :default => 0
t.string "url" t.string "url"
t.string "username" t.string "username"
t.string "userhomeurl" t.string "userhomeurl"