diff --git a/app/controllers/welcome_controller.rb b/app/controllers/welcome_controller.rb index 7c60e2dc3..9c72d301f 100644 --- a/app/controllers/welcome_controller.rb +++ b/app/controllers/welcome_controller.rb @@ -33,7 +33,7 @@ class WelcomeController < ApplicationController if params[:school_id] @school_id = params[:school_id] elsif User.current.logged? && User.current.user_extensions.school - @school_id = User.current.user_extensions.school.id + @school_id = User.current.user_extensions.school.try(:id) end @logoLink ||= logolink() end diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 87b495f00..e65fe174e 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -247,4 +247,15 @@ module UsersHelper displayed_flag = %w|index| !displayed_flag.include?(params['action']) end + + #获取指定用户的未过期的课程列表 + def user_courses_list user + result = [] + user.coursememberships.map(&:course).each do |course| + if !course_endTime_timeout?(course) + result << course + end + end + return result + end end diff --git a/app/models/course.rb b/app/models/course.rb index bf6190c88..32b192f2d 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -274,4 +274,7 @@ class Course < ActiveRecord::Base end end + def name + read_attribute('name') || Project.find_by_identifier(self.extra).try(:name) + end end diff --git a/app/models/course_status.rb b/app/models/course_status.rb index d5a01ac4b..b36661ebe 100644 --- a/app/models/course_status.rb +++ b/app/models/course_status.rb @@ -1,3 +1,7 @@ class CourseStatus < ActiveRecord::Base attr_accessible :changesets_count, :course_ac_para, :course_id, :grade, :watchers_count + + belongs_to :course + validates_presence_of :course_id + validates_uniqueness_of :course_id end diff --git a/app/views/bids/_bid_homework_show.html.erb b/app/views/bids/_bid_homework_show.html.erb index 4c5c80b87..d452b6d53 100644 --- a/app/views/bids/_bid_homework_show.html.erb +++ b/app/views/bids/_bid_homework_show.html.erb @@ -15,7 +15,7 @@ <% if(User.current.logged? && (!Member.where('user_id = ? and course_id = ?', User.current.id, bid.courses.first.id).first.nil? && (Member.where('user_id = ? and course_id = ?', User.current.id, bid.courses.first.id).first.roles&Role.where('id = ? or id = ? or id =?',5, 10, 7)).size >0)) %> <%# 提交作业按钮 %> - + <% cur_user_homework = cur_user_homework_for_bid(bid) %> <% if cur_user_homework!= nil && cur_user_homework.count == 0 %> <%= link_to l(:label_commit_homework),new_homework_attach_path(bid) %> @@ -41,19 +41,19 @@ - <% @bidding_project = bid.biding_projects.all - @temp = [] - @bidding_project.each do |pro| + <% bidding_project = bid.biding_projects.all + temp = [] + bidding_project.each do |pro| if pro.project && pro.project.project_status - @temp << pro + temp << pro end - @temp + temp end %> <% if bid.homework_type == 1%> <%= l(:label_x_homework_project, :count => bid.homeworks.count) %>(<%= link_to bid.homeworks.count, course_for_bid_path(bid.id) %>) <% else %> - <%= l(:label_x_homework_project, :count => @temp.count) %>(<%= link_to @temp.count, course_for_bid_path(bid.id) %>) + <%= l(:label_x_homework_project, :count => temp.count) %>(<%= link_to temp.count, course_for_bid_path(bid.id) %>) <% end %> <%= l(:label_x_responses, :count => bid.commit) %>(<%= link_to bid.commit, respond_path(bid) %>) @@ -74,7 +74,7 @@ <%= bid.budget%> <% elsif bid.reward_type == 2 %> <%= l(:label_bids_reward_method) %><%= bid.budget%> <% else %> - <% end %> + <% end %> diff --git a/app/views/bids/_bid_show.html.erb b/app/views/bids/_bid_show.html.erb index 8d3ffec18..47f1560dd 100644 --- a/app/views/bids/_bid_show.html.erb +++ b/app/views/bids/_bid_show.html.erb @@ -13,7 +13,34 @@ - + <% if bid.reward_type == 3 %> @@ -60,6 +87,6 @@ diff --git a/app/views/bids/contest.html.erb b/app/views/bids/contest.html.erb index dd10f7b1b..bd069c8c8 100644 --- a/app/views/bids/contest.html.erb +++ b/app/views/bids/contest.html.erb @@ -32,13 +32,13 @@ diff --git a/app/views/school/index.html.erb b/app/views/school/index.html.erb index 6993ee7f5..1dc8bfee4 100644 --- a/app/views/school/index.html.erb +++ b/app/views/school/index.html.erb @@ -71,7 +71,7 @@

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

<% if bid.reward_type.nil? or bid.reward_type == 1%> <%= l(:label_bids_reward_method) %><%= l(:label_call_bonus) %> <%= l(:label_RMB_sign) %><%= bid.budget%> <% elsif bid.reward_type == 2%> <%= l(:label_bids_reward_method) %><%= bid.budget%> <% else %> <% end %> + <% if bid.reward_type.nil? or bid.reward_type == 1%> + + <%= l(:label_bids_reward_method) %> + + <%= l(:label_call_bonus) %>  + <%= l(:label_RMB_sign) %> + <%= bid.budget%> + + + <% elsif bid.reward_type == 2%> + + <%= l(:label_bids_reward_method) %> + <%= bid.budget%> + + <% else %> + <% end %> +
<% case e.act_type %> <% when 'JournalsForMessage' %> - <% if User.current.login == @user.login %> + <% if User.current.login == e.user.try(:login) %> <%# if e.user_id == act.jour.id %> diff --git a/db/migrate/20140603042015_stored_course_procedure.rb b/db/migrate/20140603042015_stored_course_procedure.rb index 2f5faf5c7..426567cac 100644 --- a/db/migrate/20140603042015_stored_course_procedure.rb +++ b/db/migrate/20140603042015_stored_course_procedure.rb @@ -31,7 +31,7 @@ class StoredCourseProcedure < ActiveRecord::Migration courseStatus.watchers_count = projectstatus.watchers_count courseStatus.grade = projectstatus.grade courseStatus.course_ac_para = projectstatus.course_ac_para - courseStatus.save(:validate => false) + courseStatus.save() end end end diff --git a/db/migrate/20140704034832_clear_course_status.rb b/db/migrate/20140704034832_clear_course_status.rb new file mode 100644 index 000000000..527bfd412 --- /dev/null +++ b/db/migrate/20140704034832_clear_course_status.rb @@ -0,0 +1,16 @@ +class ClearCourseStatus < ActiveRecord::Migration + def up + # 删除重复的课程状态 + # 之前做迁移的时候未加验证可能引起此问题 + courseidlist = "(-1" + CourseStatus.all.each do |status| + sql = "delete from course_statuses where course_id=" + status.course_id.to_s + " and id<>" + status.id.to_s + + " and course_id not in " +courseidlist + ")" + courseidlist += "," + status.course_id.to_s; + execute(sql) + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 371883051..32a903aa8 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20140703085204) do +ActiveRecord::Schema.define(:version => 20140704034832) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -794,20 +794,20 @@ ActiveRecord::Schema.define(:version => 20140703085204) do end create_table "relative_memos", :force => true do |t| - t.integer "osp_id", :null => false + t.integer "osp_id" t.integer "parent_id" - t.string "subject", :null => false - t.text "content", :null => false + t.string "subject", :null => false + t.text "content", :limit => 16777215, :null => false t.integer "author_id" - t.integer "replies_count", :default => 0 + t.integer "replies_count", :default => 0 t.integer "last_reply_id" - t.boolean "lock", :default => false - t.boolean "sticky", :default => false - t.boolean "is_quote", :default => false - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - t.integer "viewed_count_crawl", :default => 0 - t.integer "viewed_count_local", :default => 0 + t.boolean "lock", :default => false + t.boolean "sticky", :default => false + t.boolean "is_quote", :default => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "viewed_count_crawl", :default => 0 + t.integer "viewed_count_local", :default => 0 t.string "url" t.string "username" t.string "userhomeurl"
<%= link_to("#{l(:label_i)}", user_path(e.user_id)) %> <%= l(:label_have_feedback) %><%= link_to("#{e.act.user.name}", user_path(e.act.user.id)) %><%= l(:label_of_feedback) + l(:label_layouts_feedback) %>