diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 20bda61e0..b46ab52b1 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -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 diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 2a408788e..2915ff8f8 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -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 diff --git a/app/helpers/welcome_helper.rb b/app/helpers/welcome_helper.rb index 1004a49ad..4ff5a48e4 100644 --- a/app/helpers/welcome_helper.rb +++ b/app/helpers/welcome_helper.rb @@ -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 diff --git a/app/models/course.rb b/app/models/course.rb index 32b192f2d..5034ab0d8 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -274,6 +274,7 @@ class Course < ActiveRecord::Base end end + #项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题 def name read_attribute('name') || Project.find_by_identifier(self.extra).try(:name) end diff --git a/app/models/mailer.rb b/app/models/mailer.rb index 81ef95c85..09db4de97 100644 --- a/app/models/mailer.rb +++ b/app/models/mailer.rb @@ -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 diff --git a/app/models/repository.rb b/app/models/repository.rb index ce7ac9d0c..57a818270 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -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 diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 705040579..9f6b45dbd 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -1,6 +1,6 @@ <% 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 = @bid.is_evaluation == 1 || @bid.is_evaluation == nil %> <%= form_tag(:controller => 'bids', :action => "show_courseEx", :method => :get) do %> @@ -21,7 +21,6 @@ <% end %> - diff --git a/app/views/homework_attach/edit.html.erb b/app/views/homework_attach/edit.html.erb index 985ccfdfc..9a33ea992 100644 --- a/app/views/homework_attach/edit.html.erb +++ b/app/views/homework_attach/edit.html.erb @@ -42,11 +42,11 @@
<%= form_for(@homework) do |f|%>

- 标      题:  + 标      题 *  <%= f.text_field :name, :required => true, :name => "homework_name", :size => 60, :style => "width:490px;"%>

- 提交项目: + 提交项目  : <% if @homework.project.nil? %> <%= f.select :project_id, options_for_select(user_projects_option),:name => "project_id", :required => true%> <% else %> @@ -57,7 +57,7 @@

提交项目可以为空

- 描      述:  + 描      述  :  <%= f.text_area :description, :rows => 8, :name => "homework_description", :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %> diff --git a/app/views/homework_attach/new.html.erb b/app/views/homework_attach/new.html.erb index 9c594835a..9f0b69f58 100644 --- a/app/views/homework_attach/new.html.erb +++ b/app/views/homework_attach/new.html.erb @@ -23,17 +23,17 @@ :bid_id => @bid }) do |f|%>

- 标      题: + 标      题 * <%= f.text_field "name", :required => true, :size => 60, :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' %>

提交项目可以为空

- 描      述: + 描      述  : <%= f.text_area "description", :rows => 8, :class => 'wiki-edit', :style => "font-size:small;width:490px;margin-left:10px;" %> diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index ac5cc104d..5958e18bd 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -167,7 +167,7 @@ <%= l(:label_teacher_work_unit) %> : - <%= link_to @course.teacher.user_extensions.school,options={:controller => 'welcome',:action => 'course',:school_id => @course.teacher.user_extensions.school.id}, html_options={:method => 'get'} %> + <%= @course.teacher.user_extensions.school %> <% else %> diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index fd95f8c32..e4b5db1bf 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -121,7 +121,7 @@ <%= l(:label_teacher_work_unit) %> : <% unless @user.user_extensions.nil? || @user.user_extensions.school.nil? %> - <%= link_to @user.user_extensions.school,options={:controller => 'welcome',:action => 'course',:school_id => @user.user_extensions.school.id}, html_options={:method => 'get'} %> + <%= link_to @user.user_extensions.school,"http://course.trustie.net/?school_id=#{@user.user_extensions.school.id}" %> <% end %> diff --git a/app/views/layouts/base_users.html.erb b/app/views/layouts/base_users.html.erb index 0f7c273f1..172bd67af 100644 --- a/app/views/layouts/base_users.html.erb +++ b/app/views/layouts/base_users.html.erb @@ -168,7 +168,7 @@

- +
@@ -178,7 +178,7 @@ @@ -189,7 +189,7 @@ diff --git a/app/views/school/index.html.erb b/app/views/school/index.html.erb index 1dc8bfee4..a42844ffb 100644 --- a/app/views/school/index.html.erb +++ b/app/views/school/index.html.erb @@ -43,7 +43,7 @@ @@ -71,7 +71,7 @@

<%= link_to "全部学校",school_index_path %>      - <%= link_to '我的学校',school_course_list_path(User.current.user_extensions.school) if User.current.logged? %> + 我的学校

<%= l(:label_user_joinin) %>:<%= format_time(@user.created_on) %>
<%= l(:field_occupation) %>: <% 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'} %> + <%= @user.user_extensions.school.name %> <% end %>