From 29fa624e9dbc10af44cf908e0e530d2c370e8165 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 11 Jun 2014 17:41:06 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E5=B0=81=E8=A3=85=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=88=90=E5=91=98=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index 09d357ebf..abbb47c1c 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -18,6 +18,13 @@ class HomeworkAttachController < ApplicationController @project = @homework.bid.courses[0] end + #获取作业的成员 + def get_homework_member homework + @hoemwork_users = users_for_homework(@homework) + @members = members_for_homework(@homework,@hoemwork_users,params[:q]) + @members = paginateHelper @members,10 + end + def index @homeworks = HomeworkAttach.all respond_to do |format| @@ -40,9 +47,7 @@ class HomeworkAttachController < ApplicationController end end @homework.save - @hoemwork_users = users_for_homework(@homework) - @members = members_for_homework(@homework,@hoemwork_users,params[:q]) - @members = paginateHelper @members,10 + get_homework_member @homework respond_to do |format| format.js end @@ -57,9 +62,7 @@ class HomeworkAttachController < ApplicationController if User.current.admin? || User.current == @homework.user homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first homework_user.destroy - @hoemwork_users = users_for_homework(@homework) - @members = members_for_homework(@homework,@hoemwork_users,params[:q]) - @members = paginateHelper @members,10 + get_homework_member @homework respond_to do |format| format.js end @@ -136,11 +139,7 @@ class HomeworkAttachController < ApplicationController @homework = HomeworkAttach.find(params[:bid_id]) course = @homework.bid.courses.first if User.current.admin? || User.current.member_of?(course) - @hoemwork_users = users_for_homework(@homework) - @members = members_for_homework(@homework,@hoemwork_users,params[:q]) - #该课程的学生的集合 - #@members = course.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]}) - @members = paginateHelper @members,10 + get_homework_member @homework else raise "error" end @@ -165,9 +164,7 @@ class HomeworkAttachController < ApplicationController #@homework = HomeworkAttach.find(params[:id]) if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) #@members = @homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id)", {:role_id => [5, 10]}) - @hoemwork_users = users_for_homework(@homework) - @members = members_for_homework(@homework,@hoemwork_users,params[:q]) - @members = paginateHelper @members,10 + get_homework_member @homework else render_403 :message => :notice_not_authorized end From d832a5eecf9af73ef62f0f073835c6d41015b1f4 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 12 Jun 2014 14:43:51 +0800 Subject: [PATCH 02/10] rake db:migrate --- app/controllers/homework_attach_controller.rb | 1 + app/views/homework_attach/show.html.erb | 2 +- db/schema.rb | 12 +++++------- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index abbb47c1c..e5f9685f0 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -156,6 +156,7 @@ class HomeworkAttachController < ApplicationController #获取可选成员列表 #homework:作业 #users:该作业所有成员 + #q:模糊匹配的用户的昵称 def members_for_homework homework,users,q homework.bid.courses.first.members.joins(:member_roles).where("member_roles.role_id IN (:role_id) and user_id not in (:users)", {:role_id => [5, 10],:users => users}).joins(:user).where("users.login like '%#{q}%'") end diff --git a/app/views/homework_attach/show.html.erb b/app/views/homework_attach/show.html.erb index 0e7adacbe..7df12032f 100644 --- a/app/views/homework_attach/show.html.erb +++ b/app/views/homework_attach/show.html.erb @@ -49,7 +49,7 @@ - 平均评分: + 平均评分: <%= rating_for @homework, :static => true, dimension: :quality, class: 'rateable div_inline' %> 发布时间:<%=format_time @homework.created_at %> diff --git a/db/schema.rb b/db/schema.rb index b37bc56e8..826d0eb81 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -924,13 +924,11 @@ ActiveRecord::Schema.define(:version => 20140609061903) do add_index "user_preferences", ["user_id"], :name => "index_user_preferences_on_user_id" create_table "user_scores", :force => true do |t| - t.integer "user_id", :null => false - t.integer "collaboration" - t.integer "influence" - t.integer "skill" - t.integer "active" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.integer "user_id" + t.integer "collaboration" + t.integer "influence" + t.integer "skill" + t.integer "activity" end create_table "user_statuses", :force => true do |t| From 8ed95f132a56d78ceaa7fc4f532d759aeb43d401 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 12 Jun 2014 15:05:39 +0800 Subject: [PATCH 03/10] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=E3=80=81=E6=96=B0?= =?UTF-8?q?=E5=BB=BA=E5=8D=A0=E4=BD=8D=E9=A1=B5=E9=9D=A2=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AF=BC=E8=88=AA=E6=A0=8F=20=20=20=20=20=20=20=20=20=20=20=20?= =?UTF-8?q?=20=20=20=20=202.=E4=BD=9C=E4=B8=9A=E7=9A=84=E4=BD=9C=E8=80=85?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E5=AF=B9=E4=BD=9C=E4=B8=9A=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E8=AF=84=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_attach/edit.html.erb | 16 ++++++ app/views/homework_attach/new.html.erb | 16 ++++++ app/views/homework_attach/show.html.erb | 65 +++++++++++++------------ 3 files changed, 66 insertions(+), 31 deletions(-) diff --git a/app/views/homework_attach/edit.html.erb b/app/views/homework_attach/edit.html.erb index a36c1a8bf..f7104840b 100644 --- a/app/views/homework_attach/edit.html.erb +++ b/app/views/homework_attach/edit.html.erb @@ -8,6 +8,22 @@ } +
+ + + + + + + + + + +
高校课程实践社区<%= l(:label_user_location) %> :
<%= link_to request.host()+"/courses", :controller => 'projects', :action => 'course'%>

<%=link_to "主页", home_path %> > <%=link_to l(:label_course_practice), :controller => 'projects', :action => 'course' %> > + <%= link_to(@homework.bid.courses.first.name.to_s, homework_project_path(@homework.bid.courses.first)) if @homework.bid.courses.first%> > + <%=link_to(@homework.bid.name, respond_path(@homework.bid)) %> > <%= link_to "修改作业",edit_homework_attach_path(@homework)%>

+
+

<%=raw l(:label_edit_homework)%>

From a100193373a0d9d926792408e741f1f2a39b8bd0 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 12 Jun 2014 15:25:59 +0800 Subject: [PATCH 05/10] =?UTF-8?q?1.=E4=BD=9C=E4=B8=9A=E5=8F=82=E4=B8=8E?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E5=8F=AF=E4=BB=A5=E5=AF=B9=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E8=BF=9B=E8=A1=8C=E4=BF=AE=E6=94=B9=EF=BC=8C=E4=BD=86=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E8=BF=9B=E8=A1=8C=E5=88=A0=E9=99=A4=202.=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=88=90=E5=91=98(=E5=8F=91=E5=B8=83=E4=BA=BA?= =?UTF-8?q?=E5=91=98=E5=92=8C=E5=8F=82=E4=B8=8E=E4=BA=BA=E5=91=98)?= =?UTF-8?q?=E4=B8=8D=E8=83=BD=E5=AF=B9=E4=BD=9C=E4=B8=9A=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E8=AF=84=E5=88=86=203.=E4=BF=AE=E6=94=B9=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E5=88=A0=E9=99=A4=E3=80=81=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E3=80=81=E4=BF=AE=E6=94=B9=E3=80=81=E6=B7=BB=E5=8A=A0=E6=88=90?= =?UTF-8?q?=E5=91=98=E7=AD=89=E6=96=B9=E6=B3=95=E7=9A=84=E6=9D=83=E9=99=90?= =?UTF-8?q?=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_attach_controller.rb | 6 +++--- app/helpers/courses_helper.rb | 5 +++++ app/views/bids/_homework_list.html.erb | 10 ++++++---- app/views/homework_attach/show.html.erb | 3 ++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/app/controllers/homework_attach_controller.rb b/app/controllers/homework_attach_controller.rb index e5f9685f0..d10f09ffa 100644 --- a/app/controllers/homework_attach_controller.rb +++ b/app/controllers/homework_attach_controller.rb @@ -35,7 +35,7 @@ class HomeworkAttachController < ApplicationController #作业添加成员(参与人员) def add_homework_users - if User.current.admin? || User.current == @homework.user + if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) #@homework = HomeworkAttach.find(params[:id]) if params[:membership] if params[:membership][:user_ids] @@ -59,7 +59,7 @@ class HomeworkAttachController < ApplicationController #作业删除成员(参与人员) def destory_homework_users #@homework = HomeworkAttach.find(params[:id]) - if User.current.admin? || User.current == @homework.user + if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) homework_user = @homework.homework_users.where("user_id = #{params[:user_id]}").first homework_user.destroy get_homework_member @homework @@ -196,7 +196,7 @@ class HomeworkAttachController < ApplicationController def destroy #@homework = HomeworkAttach.find(params[:id]) - if User.current.admin? || User.current.member_of?(@homework.bid.courses.first) + if User.current.admin? || User.current == @homework if @homework.destroy respond_to do |format| format.html { redirect_to project_for_bid_path @homework.bid } diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index eef630996..0602e52d2 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -177,4 +177,9 @@ module CoursesHelper seem_count = homework.rates(:quality).where("rater_id = ?",User.current).count seem_count > 0 end + + #获取指定作业的所有成员 + def users_for_homework homework + homework.nil? ? [] : (homework.users + [homework.user]) + end end diff --git a/app/views/bids/_homework_list.html.erb b/app/views/bids/_homework_list.html.erb index 0f605d6fa..18778f5e9 100644 --- a/app/views/bids/_homework_list.html.erb +++ b/app/views/bids/_homework_list.html.erb @@ -90,10 +90,12 @@ <% end %> - <% if (User.current == homework.user) || is_teacher %> + <% if (users_for_homework(homework).include?(User.current) || is_teacher) %> <%= link_to l(:button_edit), edit_homework_attach_path(homework) %> - <%= link_to(l(:label_bid_respond_delete), homework, - method: :delete, :confirm => l(:text_are_you_sure)) %> + <% if homework.user == User.current || is_teacher %> + <%= link_to(l(:label_bid_respond_delete), homework, + method: :delete, :confirm => l(:text_are_you_sure)) %> + <% end %> <% end %> @@ -102,4 +104,4 @@
-<% end %> +<% end %> \ No newline at end of file diff --git a/app/views/homework_attach/show.html.erb b/app/views/homework_attach/show.html.erb index 31377c609..d4bc0de42 100644 --- a/app/views/homework_attach/show.html.erb +++ b/app/views/homework_attach/show.html.erb @@ -142,7 +142,8 @@
-<% if User.current != @homework.user %> + +<% if !users_for_homework(@homework).include?(User.current) %>
作业评论:
<% if is_student %> From 9bd813235968990d07497b6f032c8868514ce44a Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 12 Jun 2014 15:42:58 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=97=A0=E6=B3=95=E7=95=99=E8=A8=80=E3=80=81=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E7=BB=BC=E8=AF=84=E7=9A=84BUG?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/homework_attach.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/homework_attach.rb b/app/models/homework_attach.rb index c801885b1..e60d4230b 100644 --- a/app/models/homework_attach.rb +++ b/app/models/homework_attach.rb @@ -14,8 +14,8 @@ class HomeworkAttach < ActiveRecord::Base "user_id" acts_as_attachable - def addjours user_id,message,status = 0,is_comprehensive_evaluation = 0 - jfm = self.journals_for_messages.build(:user_id => user_id,:notes =>message,:status => status,:is_comprehensive_evaluation => is_comprehensive_evaluation) + def addjours user_id,message,status = 0,is_comprehensive_evaluation = 0,reply_id = 0 + jfm = self.journals_for_messages.build(:user_id => user_id,:notes =>message,:status => status,:is_comprehensive_evaluation => is_comprehensive_evaluation,:reply_id => reply_id) jfm.save jfm end From cccb19e7339ca07681e2ed752d8488dd8dc2a584 Mon Sep 17 00:00:00 2001 From: yanxd Date: Thu, 12 Jun 2014 15:46:16 +0800 Subject: [PATCH 07/10] cnzz --- app/views/layouts/_base_footer.html.erb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/views/layouts/_base_footer.html.erb b/app/views/layouts/_base_footer.html.erb index baf438cb2..5bcd78e6e 100644 --- a/app/views/layouts/_base_footer.html.erb +++ b/app/views/layouts/_base_footer.html.erb @@ -31,7 +31,9 @@
<%= debug(params) if Rails.env.development? %> +
+ +<% end %> \ No newline at end of file From 277aa81a60c2d44ebfbf590405c0109363388960 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 12 Jun 2014 16:43:02 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8D=A0=E4=BD=8D?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=95=8C=E9=9D=A2=E6=98=BE=E7=A4=BA=E7=9A=84?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E6=8F=8F=E8=BF=B0=E6=A0=B7=E5=BC=8F=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/homework_attach/show.html.erb | 2 +- app/views/layouts/base_homework.html.erb | 16 +--------------- 2 files changed, 2 insertions(+), 16 deletions(-) diff --git a/app/views/homework_attach/show.html.erb b/app/views/homework_attach/show.html.erb index d4bc0de42..4ab6141dc 100644 --- a/app/views/homework_attach/show.html.erb +++ b/app/views/homework_attach/show.html.erb @@ -105,7 +105,7 @@
<%= @stars_status_map["star#{(star/20).to_s}".to_sym] %> -
+
<% end %> diff --git a/app/views/layouts/base_homework.html.erb b/app/views/layouts/base_homework.html.erb index 65cdd62ff..34d3b7b5a 100644 --- a/app/views/layouts/base_homework.html.erb +++ b/app/views/layouts/base_homework.html.erb @@ -74,14 +74,6 @@ - @@ -97,7 +89,7 @@ - <%= project.description %> + <%= textilizable project.description %> @@ -132,12 +124,6 @@
- - From f8bfa83ae44f34297af021c2ea45bde05ddc455f Mon Sep 17 00:00:00 2001 From: yanxd Date: Fri, 13 Jun 2014 08:35:37 +0800 Subject: [PATCH 10/10] move cache --- app/views/welcome/index.html.erb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/views/welcome/index.html.erb b/app/views/welcome/index.html.erb index 483dbfc02..a9d7e994a 100644 --- a/app/views/welcome/index.html.erb +++ b/app/views/welcome/index.html.erb @@ -53,8 +53,8 @@
    <% projects = find_miracle_project(10, 3) %> - <% cache projects do %> <% projects.map do |project| %> + <% cache "welcome_index_hotProject_ul_#{project}_li" do %>
  • <%= image_tag(get_project_avatar(project), :class => "avatar-4") %> @@ -75,9 +75,9 @@ :id => "tooltip-#{project.id}" %>
  • + <% end %> <% end; reset_cycle %>
- <% end %>
@@ -87,8 +87,8 @@ <%= link_to "更多>>", { :controller => 'users', :action => 'index'}, :target => "_blank" %>
<%activities = find_all_activities%> - <% cache activities do %> <% activities.each do |event| %> + <% cache "welcome_index_userActivity_ul_#{event}_li" do %>
  • <%= image_tag url_to_avatar(event.event_author), :class => "avatar-3" %> @@ -99,8 +99,8 @@

    <%= l(:field_updated_on) %><%= time_tag_welcome event.event_datetime %>前     <%= show_event_reply event %>

  • - <% end %> <% end %> + <% end %>
    @@ -118,8 +118,8 @@ <% end %>
    <% topics = find_new_forum_topics(7) %> - <% cache topics do %> <% topics.each do |topic|%> + <% cache "welcome_index_memosActivity_ul_#{topic}_li" do %>
  • <%= link_to '['+topic.forum.name + ']',forum_path(topic.forum),:class => 'memo_Bar_title' %><%= link_to topic.subject.truncate(30, omission: '...'), topic.event_url,title: topic.subject %> @@ -139,8 +139,8 @@
  • - <% end %> <% end %> + <% end %>
    <%= l(:label_limit_time) %>: <%= @bid.deadline %>