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?
@courses_all = Course.active.visible.
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
@courses_all = Course.active.visible.
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id").
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
@course_count = @courses_all.count
@ -407,8 +406,7 @@ class CoursesController < ApplicationController
else
@courses_all = Course.active.visible.
joins("LEFT JOIN #{CourseStatus.table_name} ON #{Course.table_name}.id = #{CourseStatus.table_name}.course_id").
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
@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})
attachments = Attachment.attach_files(@reply, params[:attachments])
render_attachment_warning_if_needed(@reply)
else
#render file: 'messages#show', layout: 'base_courses'
end
redirect_to board_message_path(@board, @topic, :r => @reply)
end
# Edit a message

View File

@ -141,27 +141,26 @@ module WelcomeHelper
Course.active.visible.
joins(:memberships).
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
if school_id.nil?
Course.active.visible.
joins(:memberships).
where("#{Course.table_name}.school_id = ?", User.current.user_extensions.school.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
if school_id == "0"
Course.active.visible.
joins(:memberships).
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
Course.active.visible.
joins(:memberships).
where("#{Course.table_name}.school_id = ?", school_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

View File

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

View File

@ -46,6 +46,8 @@ class Mailer < ActionMailer::Base
when :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}")
when :Course
course_feedback_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
when :Contest
show_contest_contest_url(journals_for_message.jour, anchor: "word_li_#{journals_for_message.id}")
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}"
return -1
end
#如果是直接留言并且留言对象是Project并且Project类型是课程
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
# modify by nwb
#如果是直接留言并且留言对象是课程
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
#课程的教师
@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_exclusion_of :identifier, :in => %w(show entry raw changes annotate diff show stats graph)
# 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
validate :repo_create_validation, :on => :create

View File

@ -1,6 +1,6 @@
<!-- fq -->
<% 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 = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %>
<%= form_tag(:controller => 'bids', :action => "show_courseEx", :method => :get) do %>
@ -21,7 +21,6 @@
<% end %>
</div>
</td>
</tr>
</table>
</div>

View File

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

View File

@ -23,17 +23,17 @@
:bid_id => @bid
}) do |f|%>
<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;" %>
</p>
<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;"%>
<%= link_to '创建项目', new_project_path(course: 0, project_type: 0), :target => '_blank' %>
<p class="font_lighter" style="padding-left:120px;clear:left;">提交项目可以为空</p>
</p>
<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;">
<%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %>
</span>

View File

@ -167,7 +167,7 @@
<tr>
<td valign="top" style="padding-left: 8px;"><%= l(:label_teacher_work_unit) %> :</td>
<!-- 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>
<% else %>
<tr>

View File

@ -121,7 +121,7 @@
<td valign="top" style="padding-left: 8px;"><%= l(:label_teacher_work_unit) %> :</td>
<!-- modified by zjc 有@user.user_extensions.occupation改为 @user.user_extensions.school 并添加超链接 -->
<% 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 %>
</tr>
</table>

View File

@ -168,7 +168,7 @@
<div class="user_underline"></div>
<!--info-->
<div class="inf_user_context">
<table style="font-family:微软雅黑" width="240">
<table style="font-family:'微软雅黑'" width="240">
<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>
</tr>
@ -178,7 +178,7 @@
<!--
<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>
-->
<!-- added by bai 在个人主页里显示“工作单位”“地区”"教师的职称"-->
@ -189,7 +189,7 @@
<tr>
<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? %>
<%= 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 %>
</td>
</tr>

View File

@ -43,7 +43,7 @@
<script type="text/javascript">
function test(id){
location.href = encodeURI('/course/'+id);
location.href = encodeURI('http://course.trustie.net/?school_id='+id);
}
</script>
@ -71,7 +71,7 @@
<p>
<%= 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>
<ul>
<li style="width: 40%; float: left">请选择省份:

View File

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

View File

@ -73,7 +73,7 @@
<div id="J_Slide" class="d-p-index-box d-p-index-hotproject">
<h3><strong>新开课程</strong></h3>
<% if @school_id %>
<% school_course = find_miracle_course(10, 7, @school_id) %>
<% school_course = find_miracle_course(10,7, @school_id) %>
<% else %>
<%school_course=[]%>
<% end %>
@ -138,6 +138,7 @@
</ul>
<ul class="d-p-projectlist">
<% school_course.map do |course| %>
<% if course.school%>
<li class='<%= cycle("odd", "even") %>' title=<%= course.description.to_s %>>
<div class='avatar'>
<%= image_tag(get_course_avatar(course), :class => "avatar-4") %>
@ -167,6 +168,7 @@
<% end %>
</div>
</li>
<%end%>
<% end; reset_cycle %>
<% if school_course.count < 9 %>
<li>

View File

@ -797,7 +797,7 @@ ActiveRecord::Schema.define(:version => 20140704034832) do
t.integer "osp_id"
t.integer "parent_id"
t.string "subject", :null => false
t.text "content", :limit => 16777215, :null => false
t.text "content", :null => false
t.integer "author_id"
t.integer "replies_count", :default => 0
t.integer "last_reply_id"