From 5d82f3336e9a0392dc5990c04704dc7e5f2923b8 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 10 Aug 2015 09:12:26 +0800 Subject: [PATCH 01/51] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=BD=9C=E8=80=85?= =?UTF-8?q?=E6=98=AF=E6=88=91=EF=BC=8C=E4=BD=86=E6=98=AF=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E5=9C=A8=E5=85=B6=E4=BB=96=E8=AF=BE=E7=A8=8B=E9=87=8C=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E5=8D=B7=EF=BC=8C=E5=8F=AF=E4=BB=A5=E5=A4=9A=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/poll_controller.rb | 62 ++++++++++++++++++++++++++++++ app/helpers/poll_helper.rb | 9 +++++ app/views/poll/_poll.html.erb | 1 + app/views/poll/_poll_list.html.erb | 14 ++----- app/views/poll/index.html.erb | 5 +++ config/routes.rb | 3 ++ public/stylesheets/polls.css | 2 +- 7 files changed, 85 insertions(+), 11 deletions(-) diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index dda5b81b2..b376a9acd 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -410,6 +410,68 @@ class PollController < ApplicationController end end + # 将其他地方的问卷导出来 + def other_poll + # 查作者是我,且不在当前课程内的问卷 进行导入 + @polls = Poll.where("user_id = #{User.current.id} and polls_type = 'course' and polls_group_id != #{params[:polls_group_id]}") + @polls_group_id = params[:polls_group_id] + respond_to do |format| + format.js + end + end + + # 将问卷导入本课程 + def import_other_poll + course_id = params[:course_id] + @course = Course.find(course_id) + params[:polls].each_with_index do |p,i| + poll = Poll.find(p) + option = { + :polls_name => poll.polls_name, + :polls_type => 'Course', + :polls_group_id => course_id, + :polls_status => 1, + :user_id => User.current.id, + :published_at => Time.now, + :closed_at => Time.now, + :show_result => 1, + :polls_description => poll.polls_description + } + @poll = Poll.create option + + poll.poll_questions.each do | q| + #question_title = params[:poll_questions_title].nil? || params[:poll_questions_title].empty? ? l(:label_enter_single_title) : params[:poll_questions_title] + option = { + :is_necessary => q[:is_necessary], + :question_title => q[:question_title], + :question_type => q[:question_type] || 1, + :question_number => q[:question_number] + } + @poll_questions = @poll.poll_questions.new option + + for i in 1..q.poll_answers.count + answer = q.poll_answers[i-1].nil? ? l(:label_new_answer) : q.poll_answers[i-1][:answer_text] + question_option = { + :answer_position => i, + :answer_text => answer + } + @poll_questions.poll_answers.new question_option + end + end + @poll.save + end + @is_teacher = User.current.allowed_to?(:as_teacher,@course) + if @is_teacher + polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id}") + else + polls = Poll.where("polls_type = 'Course' and polls_group_id = #{@course.id} and polls_status = 2") + end + @polls = paginateHelper polls,20 #分页 + respond_to do |format| + format.js + end + end + private def find_poll_and_course @poll = Poll.find params[:id] diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb index 3156f1b3a..0baad37ee 100644 --- a/app/helpers/poll_helper.rb +++ b/app/helpers/poll_helper.rb @@ -74,4 +74,13 @@ module PollHelper end end + #带勾选框的问卷列表 + def poll_check_box_tags(name,polls,current_poll) + s = '' + polls.each do |poll| + s << "
" + end + s.html_safe + end + end \ No newline at end of file diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb index 180fed0f0..b4d944220 100644 --- a/app/views/poll/_poll.html.erb +++ b/app/views/poll/_poll.html.erb @@ -41,6 +41,7 @@
  • 导出
  • <% elsif poll.polls_status == 2 || poll.polls_status == 3 %>
  • <%= link_to "导出", export_poll_poll_path(poll.id,:format => "xls"), :class => "polls_de fr ml5"%>
  • + <% end%> diff --git a/app/views/poll/_poll_list.html.erb b/app/views/poll/_poll_list.html.erb index becfc32a5..fb8b765a3 100644 --- a/app/views/poll/_poll_list.html.erb +++ b/app/views/poll/_poll_list.html.erb @@ -3,20 +3,14 @@ (<%= @obj_count%>) <% if @is_teacher%> + <%= link_to "导入", other_poll_poll_index_path(:polls_group_id => @course.id), :remote=>true,:class => "newbtn"%> <%= link_to l(:label_new_poll), new_poll_path(:polls_type => "Course",:polls_group_id => @course.id), :class => "newbtn" %> <% end%>
    -
    - <% @polls.each do |poll|%> - -
    - <% end%> +
    + + <%= render :partial => 'polls_list', :locals => {:polls => @polls,:obj_pages=>@obj_pages,:obj_count=>@obj_count} %> -
    \ No newline at end of file diff --git a/app/views/poll/index.html.erb b/app/views/poll/index.html.erb index bede915b4..92a42cbac 100644 --- a/app/views/poll/index.html.erb +++ b/app/views/poll/index.html.erb @@ -80,6 +80,11 @@ $('#ajax-modal').parent().css("top","").css("left",""); $('#ajax-modal').parent().addClass("popbox_polls"); } + + function closeModal() + { + hideModal($("#popbox_upload")); + }
    <%= render :partial => 'poll_list'%> diff --git a/config/routes.rb b/config/routes.rb index 5af5ea3d7..9a14b4599 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -83,10 +83,13 @@ RedmineApp::Application.routes.draw do get 'close_poll' get 'export_poll' get 'import_poll' + end collection do delete 'delete_poll_question' post 'update_poll_question' + get 'other_poll' + post 'import_other_poll' end end diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css index 83fa5089b..97faa0f57 100644 --- a/public/stylesheets/polls.css +++ b/public/stylesheets/polls.css @@ -130,7 +130,7 @@ a:hover.btn_de{ background:#ff5d31;} a.btn_pu{ border:1px solid #3cb761; color:#3cb761; } a:hover.btn_pu{ background:#3cb761;} .pollsbtn_grey{ border:1px solid #b1b1b1; color:#b1b1b1; padding:0px 9px; height:19px; padding-top:3px; } -.polls_title_w { width:300px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;} +.polls_title_w { width:280px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;} .polls_title_st { max-width:530px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;} .polls_de_grey{ color:#b1b1b1; margin-top:3px;} .ml5{ margin-left:5px;} From 44f22feefd93b3e85745724bdb9cf950b74cd179 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 10 Aug 2015 09:13:38 +0800 Subject: [PATCH 02/51] =?UTF-8?q?=E5=AF=BC=E5=85=A5=E4=BD=9C=E8=80=85?= =?UTF-8?q?=E6=98=AF=E6=88=91=EF=BC=8C=E4=BD=86=E6=98=AF=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E5=9C=A8=E5=85=B6=E4=BB=96=E8=AF=BE=E7=A8=8B=E9=87=8C=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E5=8D=B7=EF=BC=8C=E5=8F=AF=E4=BB=A5=E5=A4=9A=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/poll/_other_poll.html.erb | 27 +++++++++++++++++++++++++ app/views/poll/_polls_list.html.erb | 10 +++++++++ app/views/poll/import_other_poll.js.erb | 1 + app/views/poll/other_poll.js.erb | 9 +++++++++ 4 files changed, 47 insertions(+) create mode 100644 app/views/poll/_other_poll.html.erb create mode 100644 app/views/poll/_polls_list.html.erb create mode 100644 app/views/poll/import_other_poll.js.erb create mode 100644 app/views/poll/other_poll.js.erb diff --git a/app/views/poll/_other_poll.html.erb b/app/views/poll/_other_poll.html.erb new file mode 100644 index 000000000..c899f0d47 --- /dev/null +++ b/app/views/poll/_other_poll.html.erb @@ -0,0 +1,27 @@ +
    +
    +

    将以下问卷导入本课程

    +
    +
    + <%= form_tag import_other_poll_poll_index_path, + method: :post, + remote: true, + id: "relation_file_form" do %> + + <%= content_tag('div', poll_check_box_tags('polls[]', polls,polls_group_id), :id => 'courses')%> + 导  入 + 取  消 + <% end -%> +
    + + +
    +
    + + \ No newline at end of file diff --git a/app/views/poll/_polls_list.html.erb b/app/views/poll/_polls_list.html.erb new file mode 100644 index 000000000..c096f396d --- /dev/null +++ b/app/views/poll/_polls_list.html.erb @@ -0,0 +1,10 @@ +<% polls.each do |poll|%> + +
    +<% end%> + + \ No newline at end of file diff --git a/app/views/poll/import_other_poll.js.erb b/app/views/poll/import_other_poll.js.erb new file mode 100644 index 000000000..f60cea1c5 --- /dev/null +++ b/app/views/poll/import_other_poll.js.erb @@ -0,0 +1 @@ +$('#polls_list').html('<%= escape_javascript(render :partial => 'polls_list', :locals => {:polls => @polls,:obj_pages=>@obj_pages,:obj_count=>@obj_count}) %>
    '); \ No newline at end of file diff --git a/app/views/poll/other_poll.js.erb b/app/views/poll/other_poll.js.erb new file mode 100644 index 000000000..34f53b73e --- /dev/null +++ b/app/views/poll/other_poll.js.erb @@ -0,0 +1,9 @@ + +$('#ajax-modal').html('<%= escape_javascript(render :partial => 'other_poll',:locals => {:polls => @polls,:polls_group_id=>@polls_group_id}) %>'); + + +showModal('ajax-modal', '513px'); +$('#ajax-modal').siblings().remove(); +$('#ajax-modal').before(""); +$('#ajax-modal').parent().css("top","").css("left",""); +$('#ajax-modal').parent().addClass("popbox_polls"); \ No newline at end of file From a282d8155199abc66ae6cdc28372a999d7253311 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 10 Aug 2015 15:31:23 +0800 Subject: [PATCH 03/51] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E6=88=96=E8=80=85=E5=B7=B2=E7=BB=8F=E5=8A=A0=E5=85=A5=E7=9A=84?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=EF=BC=8C=E6=8F=90=E7=A4=BA=E5=90=8E=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 11 ++++++++--- app/views/courses/_set_join.js.erb | 2 ++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 1623979f0..d9980e286 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -39,9 +39,14 @@ class CoursesController < ApplicationController else @state = 5 #未登录 end - respond_to do |format| - format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} } - end + # if @state == 1 || @state == 3 + # respond_to course_path(course.id) + # else + respond_to do |format| + format.js { render :partial => 'set_join', :locals => {:user => user, :course => course, :object_id => params[:object_id]} } + end + #end + rescue Exception => e @state = 4 #已经加入了课程 respond_to do |format| diff --git a/app/views/courses/_set_join.js.erb b/app/views/courses/_set_join.js.erb index 0542f2a0c..5476e7ff0 100644 --- a/app/views/courses/_set_join.js.erb +++ b/app/views/courses/_set_join.js.erb @@ -6,12 +6,14 @@ alert("加入成功"); hideModal($("#popbox02")); $("#try_join_course_link").replaceWith(" 'index',:course=>course.id, :host=>Setting.host_course)%>' target='_blank' class='blue_n_btn fr mt20'>提交作品"); + window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>" <% elsif @state == 1 %> alert("密码错误"); <% elsif @state == 2 %> alert("课程已过期\n请联系课程管理员重启课程。(在配置课程处)"); <% elsif @state == 3 %> alert("您已经加入了课程"); + window.location.href= "http://"+"<%= Setting.host_name%>"+"/courses/" + "<%= course.id%>" <% elsif @state == 4 %> alert("您加入的课程不存在"); <% elsif @state == 5 %> From 82747a769089149d2ca8fb6a5a8608cc398cf6e1 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 10 Aug 2015 16:12:13 +0800 Subject: [PATCH 04/51] =?UTF-8?q?=E7=95=99=E8=A8=80=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 8 +++++--- app/models/user.rb | 5 +++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 0c5b441d4..39a467d53 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -262,9 +262,11 @@ class UsersController < ApplicationController # modified by fq def user_newfeedback jours = @user.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC') - jours.update_all(:is_readed => true, :status => false) - jours.each do |journal| - fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false) + if User.current == @user + jours.update_all(:is_readed => true, :status => false) + jours.each do |journal| + fetch_user_leaveWord_reply(journal).update_all(:is_readed => true, :status => false) + end end @jour = paginateHelper jours,10 @state = false diff --git a/app/models/user.rb b/app/models/user.rb index 2271adc18..1cd0675c8 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -291,9 +291,10 @@ class User < Principal name end ## end - + + # 查询用户未读过的记录 def count_new_jour - count = self.new_jours.count + count = self.journals_for_messages.where("status=?", 1).count end #added by nie From 21f81a931afc105bde4d15c0bea6165e8054c4a0 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 11 Aug 2015 11:26:22 +0800 Subject: [PATCH 05/51] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=BB=E9=A1=B5=E7=9A=84=E2=80=9C=E6=96=B0=E5=BB=BA=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E2=80=9D=E2=80=9C=E6=96=B0=E5=BB=BA=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E2=80=9D=E2=80=9C=E5=8A=A0=E5=85=A5=E8=AF=BE=E7=A8=8B=E2=80=9D?= =?UTF-8?q?=E2=80=9D=E5=8A=A0=E5=85=A5=E9=A1=B9=E7=9B=AE=E2=80=9C=E7=9A=84?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/show.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index e53d734c6..b2e6258ee 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -5,14 +5,14 @@ <% if @user.allowed_to?(:add_project, nil, :global => true) %> 新建项目 <% else %> - 加入项目 + 加入项目 <% end %> <% if @user.user_extensions.identity == 0 && @user.allowed_to?(:add_course, nil, :global => true) %> - 新建课程 + 新建课程 <% else %> - 加入课程 + 加入课程 <% end %>
    From d43ded4f8bcdcb66abb52254e21559a56106ef6c Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 11 Aug 2015 11:30:17 +0800 Subject: [PATCH 06/51] =?UTF-8?q?1.=E6=B2=A1=E6=9C=89=E5=8F=AF=E5=AF=BC?= =?UTF-8?q?=E5=85=A5=E7=9A=84=E9=97=AE=E5=8D=B7=E6=8F=90=E7=A4=BA=202.?= =?UTF-8?q?=E6=95=99=E8=BE=85=E4=B9=9F=E5=8F=AF=E4=BB=A5=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E8=80=81=E5=B8=88=E7=9A=84=E9=97=AE=E5=8D=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 10 +++++----- app/controllers/poll_controller.rb | 9 ++++++--- app/helpers/poll_helper.rb | 2 +- app/views/poll/_other_poll.html.erb | 4 ++-- app/views/poll/other_poll.js.erb | 16 ++++++++++------ 5 files changed, 24 insertions(+), 17 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 19c1214e2..7b81d12db 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -177,11 +177,11 @@ class FilesController < ApplicationController def index @flag = params[:flag] || false #sort_init 'filename', 'asc' - sort_init 'created_on', 'desc' - sort_update 'created_on' => "#{Attachment.table_name}.created_on", - 'filename' => "#{Attachment.table_name}.filename", - 'size' => "#{Attachment.table_name}.filesize", - 'downloads' => "#{Attachment.table_name}.downloads" + # sort_init 'created_on', 'desc' + # sort_update 'created_on' => "#{Attachment.table_name}.created_on", + # 'filename' => "#{Attachment.table_name}.filename", + # 'size' => "#{Attachment.table_name}.filesize", + # 'downloads' => "#{Attachment.table_name}.downloads" sort = "" @sort = "" @order = "" diff --git a/app/controllers/poll_controller.rb b/app/controllers/poll_controller.rb index b376a9acd..edf8c2259 100644 --- a/app/controllers/poll_controller.rb +++ b/app/controllers/poll_controller.rb @@ -1,3 +1,4 @@ +#encoding utf-8 class PollController < ApplicationController before_filter :find_poll_and_course, :only => [:edit,:update,:destroy,:show,:statistics_result,:create_poll_question,:commit_poll,:commit_answer,:publish_poll,:republish_poll,:poll_result,:close_poll,:export_poll] before_filter :find_container, :only => [:new,:create, :index] @@ -412,8 +413,10 @@ class PollController < ApplicationController # 将其他地方的问卷导出来 def other_poll - # 查作者是我,且不在当前课程内的问卷 进行导入 - @polls = Poll.where("user_id = #{User.current.id} and polls_type = 'course' and polls_group_id != #{params[:polls_group_id]}") + # 查作者是我,或者作者是当前课程的老师,且不在当前课程内的问卷 进行导入 + tea_ids = '(' + tea_ids << Course.find(params[:polls_group_id]).tea_id.to_s << ','<< User.current.id.to_s << ')' + @polls = Poll.where("user_id in #{tea_ids} and polls_type = 'course' and polls_group_id != #{params[:polls_group_id]}") @polls_group_id = params[:polls_group_id] respond_to do |format| format.js @@ -427,7 +430,7 @@ class PollController < ApplicationController params[:polls].each_with_index do |p,i| poll = Poll.find(p) option = { - :polls_name => poll.polls_name, + :polls_name => poll.polls_name || l(:label_poll_new), :polls_type => 'Course', :polls_group_id => course_id, :polls_status => 1, diff --git a/app/helpers/poll_helper.rb b/app/helpers/poll_helper.rb index 0baad37ee..22ee21936 100644 --- a/app/helpers/poll_helper.rb +++ b/app/helpers/poll_helper.rb @@ -78,7 +78,7 @@ module PollHelper def poll_check_box_tags(name,polls,current_poll) s = '' polls.each do |poll| - s << "
    " + s << "
    " end s.html_safe end diff --git a/app/views/poll/_other_poll.html.erb b/app/views/poll/_other_poll.html.erb index c899f0d47..850d821fd 100644 --- a/app/views/poll/_other_poll.html.erb +++ b/app/views/poll/_other_poll.html.erb @@ -1,6 +1,6 @@
    -

    将以下问卷导入本课程

    +

    选择问卷导入本课程

    <%= form_tag import_other_poll_poll_index_path, @@ -8,7 +8,7 @@ remote: true, id: "relation_file_form" do %> - <%= content_tag('div', poll_check_box_tags('polls[]', polls,polls_group_id), :id => 'courses')%> + <%= content_tag('div', poll_check_box_tags('polls[]', polls,polls_group_id), :id => 'courses',:style=> 'width: 300px;')%> 导  入 取  消 <% end -%> diff --git a/app/views/poll/other_poll.js.erb b/app/views/poll/other_poll.js.erb index 34f53b73e..eee4ed4a1 100644 --- a/app/views/poll/other_poll.js.erb +++ b/app/views/poll/other_poll.js.erb @@ -1,9 +1,13 @@ -$('#ajax-modal').html('<%= escape_javascript(render :partial => 'other_poll',:locals => {:polls => @polls,:polls_group_id=>@polls_group_id}) %>'); +<% if @polls.empty? %> + alert('您目前还没有自己新建的问卷'); +<% else %> + $('#ajax-modal').html('<%= escape_javascript(render :partial => 'other_poll',:locals => {:polls => @polls,:polls_group_id=>@polls_group_id}) %>'); -showModal('ajax-modal', '513px'); -$('#ajax-modal').siblings().remove(); -$('#ajax-modal').before(""); -$('#ajax-modal').parent().css("top","").css("left",""); -$('#ajax-modal').parent().addClass("popbox_polls"); \ No newline at end of file + showModal('ajax-modal', '513px'); + $('#ajax-modal').siblings().remove(); + $('#ajax-modal').before(""); + $('#ajax-modal').parent().css("top","").css("left",""); + $('#ajax-modal').parent().addClass("popbox_polls"); +<% end %> \ No newline at end of file From 477db5841bd1678bcab255857daec1a54bc1047e Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 11 Aug 2015 14:32:01 +0800 Subject: [PATCH 07/51] =?UTF-8?q?=E6=B2=A1=E6=9C=89=E9=80=89=E6=8B=A9?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E9=97=AE=E5=8D=B7=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/poll/_other_poll.html.erb | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/app/views/poll/_other_poll.html.erb b/app/views/poll/_other_poll.html.erb index 850d821fd..40ecbc569 100644 --- a/app/views/poll/_other_poll.html.erb +++ b/app/views/poll/_other_poll.html.erb @@ -19,9 +19,19 @@
    \ No newline at end of file From a87269298457474cc5e27d01644b9d6f1d6f4462 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 11 Aug 2015 14:49:32 +0800 Subject: [PATCH 08/51] =?UTF-8?q?=E4=B8=BAactivities=E8=A1=A8=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0created=5Fat=E5=AD=97=E6=AE=B5=EF=BC=8C=E5=B9=B6?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/locales/projects/en.yml | 6 +++--- ...0810064247_add_created_at_to_activities.rb | 8 +++++++ .../20150811010817_update_activities_data.rb | 21 +++++++++++++++++++ db/schema.rb | 21 +++++++------------ 4 files changed, 40 insertions(+), 16 deletions(-) create mode 100644 db/migrate/20150810064247_add_created_at_to_activities.rb create mode 100644 db/migrate/20150811010817_update_activities_data.rb diff --git a/config/locales/projects/en.yml b/config/locales/projects/en.yml index b142c6ca8..703e0878e 100644 --- a/config/locales/projects/en.yml +++ b/config/locales/projects/en.yml @@ -42,10 +42,10 @@ en: label_member: "Members" project_module_attachments: "Resources" - label_project_mail_attachments: Project Resources - label_project_mail_upload: had uploaded project resources + label_project_mail_attachments: "Project Resources" + label_project_mail_upload: "had uploaded project resources" - label_invite: Invitation + label_invite: "Invitation" label_invite_new_user: "Send email to invite new user" label_invite_trustie_user: "Invite the Trustie registered user" diff --git a/db/migrate/20150810064247_add_created_at_to_activities.rb b/db/migrate/20150810064247_add_created_at_to_activities.rb new file mode 100644 index 000000000..864ed82d6 --- /dev/null +++ b/db/migrate/20150810064247_add_created_at_to_activities.rb @@ -0,0 +1,8 @@ +class AddCreatedAtToActivities < ActiveRecord::Migration + def up + add_column :activities, :created_at, :timestamp + end + def end + remove_column :activities, :created_at + end +end diff --git a/db/migrate/20150811010817_update_activities_data.rb b/db/migrate/20150811010817_update_activities_data.rb new file mode 100644 index 000000000..de4a080f2 --- /dev/null +++ b/db/migrate/20150811010817_update_activities_data.rb @@ -0,0 +1,21 @@ +class UpdateActivitiesData < ActiveRecord::Migration + def up + count = Activity.all.count / 10 + 1 + transaction do + for i in 1 ... count do i + Activity.all.each do |activity| + type = activity.act_type + if type=='Contest' || type=='Message' || type=='News'|| type=='Journal'|| type=='Issue'|| type=='Principal'||type=='JournalsForMessage' + activity.created_at = activity.act.created_on if activity.act + elsif type=='Contestnotification' || type=='HomeworkCommon' || type=='Poll' + activity.created_at = activity.act.created_at if activity.act + end + activity.save + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 30ca29d12..db9b9ff9b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,14 +11,15 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20150801034945) do +ActiveRecord::Schema.define(:version => 20150810064247) do create_table "activities", :force => true do |t| - t.integer "act_id", :null => false - t.string "act_type", :null => false - t.integer "user_id", :null => false - t.integer "activity_container_id" - t.string "activity_container_type", :default => "" + t.integer "act_id", :null => false + t.string "act_type", :null => false + t.integer "user_id", :null => false + t.integer "activity_container_id" + t.string "activity_container_type", :default => "" + t.datetime "created_at" end add_index "activities", ["act_id", "act_type"], :name => "index_activities_on_act_id_and_act_type" @@ -454,13 +455,6 @@ ActiveRecord::Schema.define(:version => 20150801034945) do add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority" - create_table "discuss_demos", :force => true do |t| - t.string "title" - t.text "body" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false - end - create_table "documents", :force => true do |t| t.integer "project_id", :default => 0, :null => false t.integer "category_id", :default => 0, :null => false @@ -863,6 +857,7 @@ ActiveRecord::Schema.define(:version => 20150801034945) do t.datetime "created_on" t.integer "comments_count", :default => 0, :null => false t.integer "course_id" + t.datetime "updated_on" end add_index "news", ["author_id"], :name => "index_news_on_author_id" From fbcd19b54ff7b098aaa0c8135d9fb2515a1a220d Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 11 Aug 2015 15:00:40 +0800 Subject: [PATCH 09/51] =?UTF-8?q?1.=E7=BC=96=E8=BE=91=E5=88=86=E7=8F=AD?= =?UTF-8?q?=E7=9A=84=E6=97=B6=E5=80=99=E7=BC=96=E8=BE=91=E6=A1=86=E9=87=8C?= =?UTF-8?q?=E8=A6=81=E6=9C=89=E9=BB=98=E8=AE=A4=E6=98=AF=E5=8E=9F=E6=9D=A5?= =?UTF-8?q?=E7=9A=84=E8=AF=A5=E7=8F=AD=E7=BA=A7=E5=90=8D=E5=AD=97=202.?= =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=80=9A=E7=9F=A5=E6=90=9C=E7=B4=A2=E8=BE=93?= =?UTF-8?q?=E5=85=A5=E7=A9=BA=E6=A0=BC=E4=BB=8D=E7=84=B6=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E6=89=80=E6=9C=89=E7=9A=84=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/news_controller.rb | 2 +- app/views/courses/_new_groups_name.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 185e7128e..1a8e75b54 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -72,7 +72,7 @@ class NewsController < ApplicationController @news_count = scope.count @q = params[:subject] - if params[:subject].nil? + if params[:subject].nil? || params[:subject].blank? scope_order = scope.all(:include => [:author, :course], :order => "#{News.table_name}.created_on DESC") else diff --git a/app/views/courses/_new_groups_name.html.erb b/app/views/courses/_new_groups_name.html.erb index fc2c5a62d..6ffbb6dd2 100644 --- a/app/views/courses/_new_groups_name.html.erb +++ b/app/views/courses/_new_groups_name.html.erb @@ -21,7 +21,7 @@ 删除班级 <% end%> - + 编辑班级 <% end %> From 5f87d5806b360de807b06cfdfeb1cd727cb2e6d8 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 11 Aug 2015 15:26:41 +0800 Subject: [PATCH 10/51] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=95=99=E8=A8=80?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E6=8F=90=E7=A4=BA=E4=B8=AD=E9=81=97=E7=95=99?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journal.rb | 2 +- app/models/user.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/journal.rb b/app/models/journal.rb index 3b660132e..14eecc9cd 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -163,7 +163,7 @@ class Journal < ActiveRecord::Base # Description 公共表中需要保存一份该记录 def act_as_forge_activity self.forge_acts << ForgeActivity.new(:user_id => self.user_id, - :project_id => self.issue.project.id) + :project_id => self.issue.project.id) end diff --git a/app/models/user.rb b/app/models/user.rb index 1cd0675c8..12ce8719f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -258,7 +258,7 @@ class User < Principal ###添加留言 fq def add_jour(user, notes, reference_user_id = 0, options = {}) if options.count == 0 - self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true) + self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id, :status => true, :is_readed => false) else jfm = self.journals_for_messages.build(options) jfm.save @@ -294,7 +294,7 @@ class User < Principal # 查询用户未读过的记录 def count_new_jour - count = self.journals_for_messages.where("status=?", 1).count + count = self.journals_for_messages.where("status=? and is_readed = ? " ,1, 0).count end #added by nie From 465af5e2d33b9a6ac09fa168f2301a602ed60714 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 11 Aug 2015 15:54:05 +0800 Subject: [PATCH 11/51] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=8A=A8=E6=80=81=EF=BC=8C=E4=BB=A5=E5=8F=8A=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=86=85=E7=9B=B8=E5=85=B3=E6=B4=BB=E5=8A=A8=E6=97=B6=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E7=9A=84=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/attachment.rb | 12 ++++++++++-- app/models/course_activity.rb | 7 +++++++ app/models/homework_common.rb | 12 +++++++++++- app/models/journals_for_message.rb | 11 ++++++++++- app/models/message.rb | 11 ++++++++++- app/models/news.rb | 11 ++++++++++- app/models/poll.rb | 10 +++++++++- .../20150811065543_add_course_activities.rb | 15 +++++++++++++++ db/schema.rb | 11 ++++++++++- 9 files changed, 92 insertions(+), 8 deletions(-) create mode 100644 app/models/course_activity.rb create mode 100644 db/migrate/20150811065543_add_course_activities.rb diff --git a/app/models/attachment.rb b/app/models/attachment.rb index f999e27d6..f7fb9b1aa 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -27,6 +27,8 @@ class Attachment < ActiveRecord::Base belongs_to :attachmentstype, :foreign_key => "attachtype",:primary_key => "id" # 被ForgeActivity虚拟关联 has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy + # 课程动态 + has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy # end include UserScoreHelper @@ -71,8 +73,8 @@ class Attachment < ActiveRecord::Base cattr_accessor :thumbnails_storage_path @@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails") - before_save :files_to_final_location - after_create :office_conver, :be_user_score,:act_as_forge_activity# user_score + before_save :files_to_final_location,:act_as_course_activity + after_create :office_conver, :be_user_score,:act_as_forge_activity after_update :office_conver, :be_user_score after_destroy :delete_from_disk,:down_user_score @@ -552,4 +554,10 @@ class Attachment < ActiveRecord::Base end end + #课程动态公共表记录 + def act_as_course_activity + if self.container_type == "Course" && self.course_acts.empty? + self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.container_id) + end + end end diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb new file mode 100644 index 000000000..1b05e876d --- /dev/null +++ b/app/models/course_activity.rb @@ -0,0 +1,7 @@ +class CourseActivity < ActiveRecord::Base + attr_accessible :user_id, :course_act_id,:course_act_type,:course_id + # 虚拟关联 + belongs_to :act ,:polymorphic => true + belongs_to :course + belongs_to :user +end diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 291c14563..5fe01db96 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -13,17 +13,27 @@ class HomeworkCommon < ActiveRecord::Base has_many :student_works, :dependent => :destroy has_many :student_works_evaluation_distributions, :through => :student_works #一个作业的分配的匿评列表 has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动 + # 课程动态 + has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy acts_as_attachable acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" }, :description => :description, :author => :author, :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} - after_create :act_as_activity, :send_mail + after_create :act_as_activity, :send_mail, :act_as_course_activity after_destroy :delete_kindeditor_assets def act_as_activity self.acts << Activity.new(:user_id => self.user_id) end + + #课程动态公共表记录 + def act_as_course_activity + if self.course + self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.course_id) + end + end + #删除对应的图片 def delete_kindeditor_assets delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index b15c9b2d1..bcae58174 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -56,9 +56,11 @@ class JournalsForMessage < ActiveRecord::Base acts_as_attachable has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy + # 课程动态 + has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy validates :notes, presence: true, if: :is_homework_jour? - after_create :act_as_activity #huang + after_create :act_as_activity, :act_as_course_activity after_create :reset_counters! after_destroy :reset_counters! after_save :be_user_score @@ -177,4 +179,11 @@ class JournalsForMessage < ActiveRecord::Base def delete_kindeditor_assets delete_kindeditor_assets_from_disk self.id,7 end + + #课程动态公共表记录 + def act_as_course_activity + if self.jour_type == 'Course' + self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.jour_id) + end + end end diff --git a/app/models/message.rb b/app/models/message.rb index 15d358789..de5cc3f9b 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -32,6 +32,8 @@ class Message < ActiveRecord::Base has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy # 被ForgeActivity虚拟关联 has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy + # 课程动态 + has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy # end has_many :ActivityNotifies,:as => :activity, :dependent => :destroy @@ -68,7 +70,7 @@ class Message < ActiveRecord::Base after_update :update_messages_board after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets - after_create :act_as_activity,:be_user_score,:act_as_forge_activity, :send_mail + after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :send_mail #before_save :be_user_score scope :visible, lambda {|*args| @@ -185,6 +187,13 @@ class Message < ActiveRecord::Base :project_id => self.board.project.id) end end + + #课程动态公共表记录 + def act_as_course_activity + if self.course + self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.board.course_id) + end + end #更新用户分数 -by zjc def be_user_score diff --git a/app/models/news.rb b/app/models/news.rb index 7d33d760e..e5c1d192a 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -28,6 +28,8 @@ class News < ActiveRecord::Base has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy # 被ForgeActivity虚拟关联 has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy + # 课程动态 + has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy # end has_many :ActivityNotifies,:as => :activity, :dependent => :destroy @@ -49,7 +51,7 @@ class News < ActiveRecord::Base :author_key => :author_id acts_as_watchable - after_create :act_as_activity,:act_as_forge_activity,:add_author_as_watcher, :send_mail + after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:add_author_as_watcher, :send_mail after_destroy :delete_kindeditor_assets @@ -121,6 +123,13 @@ class News < ActiveRecord::Base end end + #课程动态公共表记录 + def act_as_course_activity + if self.course + self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.course_id) + end + end + # Time 2015-03-31 13:50:54 # Author lizanle # Description 删除news后删除对应的资源 diff --git a/app/models/poll.rb b/app/models/poll.rb index 64e9df79a..34a381246 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -8,7 +8,9 @@ class Poll < ActiveRecord::Base has_many :users, :through => :poll_users #该文件被哪些用户提交答案过 # 添加课程的poll动态 has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy - after_create :act_as_activity + # 课程动态 + has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy + after_create :act_as_activity, :act_as_course_activity acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" }, :description => :polls_description, @@ -27,4 +29,10 @@ class Poll < ActiveRecord::Base self.acts << Activity.new(:user_id => self.user_id) end + #课程动态公共表记录 + def act_as_course_activity + if self.polls_type == "Course" + self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id) + end + end end diff --git a/db/migrate/20150811065543_add_course_activities.rb b/db/migrate/20150811065543_add_course_activities.rb new file mode 100644 index 000000000..03ec7e354 --- /dev/null +++ b/db/migrate/20150811065543_add_course_activities.rb @@ -0,0 +1,15 @@ +class AddCourseActivities < ActiveRecord::Migration + def up + create_table :course_activities do |t| + t.integer :user_id + t.integer :course_id + t.integer :course_act_id + t.string :course_act_type + t.timestamps + end + end + + def down + drop_table :course_activities + end +end diff --git a/db/schema.rb b/db/schema.rb index 30ca29d12..ac1bb987c 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 => 20150801034945) do +ActiveRecord::Schema.define(:version => 20150811065543) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -324,6 +324,15 @@ ActiveRecord::Schema.define(:version => 20150801034945) do t.datetime "updated_on", :null => false end + create_table "course_activities", :force => true do |t| + t.integer "user_id" + t.integer "course_id" + t.integer "course_act_id" + t.string "course_act_type" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "course_attachments", :force => true do |t| t.string "filename" t.string "disk_filename" From 998fe24e49e3765a48e2f9a0a2a03430b56c6292 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 11 Aug 2015 16:52:04 +0800 Subject: [PATCH 12/51] =?UTF-8?q?=E5=BB=BA=E7=AB=8Bforge=5Fmessages?= =?UTF-8?q?=E8=A1=A8=20=E5=BB=BA=E7=AB=8Buser=E3=80=81project=E5=85=B3?= =?UTF-8?q?=E8=81=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/forge_message.rb | 20 +++++++++++++++++++ .../20150811083322_create_forge_messages.rb | 13 ++++++++++++ spec/factories/forge_messages.rb | 10 ++++++++++ spec/models/forge_message_spec.rb | 5 +++++ 4 files changed, 48 insertions(+) create mode 100644 app/models/forge_message.rb create mode 100644 db/migrate/20150811083322_create_forge_messages.rb create mode 100644 spec/factories/forge_messages.rb create mode 100644 spec/models/forge_message_spec.rb diff --git a/app/models/forge_message.rb b/app/models/forge_message.rb new file mode 100644 index 000000000..1543fab58 --- /dev/null +++ b/app/models/forge_message.rb @@ -0,0 +1,20 @@ +class ForgeMessage < ActiveRecord::Base + # 公共表中活动类型,命名规则:TYPE_OF_{类名}_ACT + TYPE_OF_ISSUE_ACT = "Issue" + TYPE_OF_MESSAGE_ACT = "Message" + TYPE_OF_ATTACHMENT_ACT = "Attachment" + TYPE_OF_DOCUMENT_ACT = "Document" + TYPE_OF_JOURNAL_ACT = "Journal" + TYPE_OF_WIKI_ACT = "Wiki" + TYPE_OF_NEWS_ACT = "News" + + attr_accessible :forge_message_id, :forge_message_type, :project_id, :user_id, :viewed + + belongs_to :forge_message ,:polymorphic => true + belongs_to :project + belongs_to :user + validates :user_id,presence: true + validates :project_id,presence: true + validates :forge_message_id,presence: true + validates :forge_message_type, presence: true +end diff --git a/db/migrate/20150811083322_create_forge_messages.rb b/db/migrate/20150811083322_create_forge_messages.rb new file mode 100644 index 000000000..f81b68712 --- /dev/null +++ b/db/migrate/20150811083322_create_forge_messages.rb @@ -0,0 +1,13 @@ +class CreateForgeMessages < ActiveRecord::Migration + def change + create_table :forge_messages do |t| + t.integer :user_id + t.integer :project_id + t.integer :forge_message_id + t.string :forge_message_type + t.integer :viewed + + t.timestamps + end + end +end diff --git a/spec/factories/forge_messages.rb b/spec/factories/forge_messages.rb new file mode 100644 index 000000000..05bc84cc1 --- /dev/null +++ b/spec/factories/forge_messages.rb @@ -0,0 +1,10 @@ +FactoryGirl.define do + factory :forge_message do + user_id 1 +project_id 1 +forge_message_id 1 +forge_message_type "MyString" +viewed 1 + end + +end diff --git a/spec/models/forge_message_spec.rb b/spec/models/forge_message_spec.rb new file mode 100644 index 000000000..ce6cd7e26 --- /dev/null +++ b/spec/models/forge_message_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe ForgeMessage, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From ce763088647626e57072d37503696ca58c40c509 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 11 Aug 2015 17:02:52 +0800 Subject: [PATCH 13/51] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81?= =?UTF-8?q?=EF=BC=8C=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE=E7=9A=84=E8=BF=81?= =?UTF-8?q?=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course_activity.rb | 2 +- .../20150811080754_course_activities.rb | 39 +++++++++++++++++++ ...50811083234_update_course_activity_time.rb | 22 +++++++++++ db/schema.rb | 2 +- 4 files changed, 63 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20150811080754_course_activities.rb create mode 100644 db/migrate/20150811083234_update_course_activity_time.rb diff --git a/app/models/course_activity.rb b/app/models/course_activity.rb index 1b05e876d..02b6dacf1 100644 --- a/app/models/course_activity.rb +++ b/app/models/course_activity.rb @@ -1,7 +1,7 @@ class CourseActivity < ActiveRecord::Base attr_accessible :user_id, :course_act_id,:course_act_type,:course_id # 虚拟关联 - belongs_to :act ,:polymorphic => true + belongs_to :course_act ,:polymorphic => true belongs_to :course belongs_to :user end diff --git a/db/migrate/20150811080754_course_activities.rb b/db/migrate/20150811080754_course_activities.rb new file mode 100644 index 000000000..bdb8e19c0 --- /dev/null +++ b/db/migrate/20150811080754_course_activities.rb @@ -0,0 +1,39 @@ +#encoding=UTF-8 +class CourseActivities < ActiveRecord::Migration + def up + Course.all.each do |course| + transaction do + #作业 + course.homework_commons.each do |homework_common| + homework_common.course_acts << CourseActivity.new(:user_id => homework_common.user_id,:course_id => course.id) + end + #通知 + course.news.each do |new| + new.course_acts << CourseActivity.new(:user_id => new.author_id,:course_id => course.id) + end + #资源 + course.attachments.each do |attachment| + attachment.course_acts << CourseActivity.new(:user_id => attachment.author_id,:course_id => course.id) + end + #讨论区 + if course.boards.first + course.boards.first.messages.each do |message| + message.course_acts << CourseActivity.new(:user_id => message.author_id,:course_id => course.id) + end + end + #留言 + course.journals_for_messages.each do |jour| + jour.course_acts << CourseActivity.new(:user_id => jour.user_id,:course_id => course.id) + end + #问卷 + Poll.where("polls_type = 'Course' and polls_group_id = #{course.id}").each do |poll| + poll.course_acts << CourseActivity.new(:user_id => poll.user_id,:course_id => course.id) + end + end + end + end + + def down + CourseActivity.destroy_all + end +end diff --git a/db/migrate/20150811083234_update_course_activity_time.rb b/db/migrate/20150811083234_update_course_activity_time.rb new file mode 100644 index 000000000..9ba8140d8 --- /dev/null +++ b/db/migrate/20150811083234_update_course_activity_time.rb @@ -0,0 +1,22 @@ +class UpdateCourseActivityTime < ActiveRecord::Migration + def up + count = CourseActivity.all.count / 10 + 1 + transaction do + for i in 1 ... count do i + CourseActivity.page(i).per(10).each do |activity| + if activity.course_act + if activity.course_act.respond_to?("created_at") + activity.created_at = activity.course_act.created_at + elsif activity.course_act.respond_to?("created_on") + activity.created_at = activity.course_act.created_on + end + activity.save + end + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index ac1bb987c..1488ca365 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 => 20150811065543) do +ActiveRecord::Schema.define(:version => 20150811083234) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 053587bd53713880e75cfa26a9204529f2faf01b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Tue, 11 Aug 2015 17:11:10 +0800 Subject: [PATCH 14/51] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E8=AF=BE=E7=A8=8B=E5=88=9B=E5=BB=BA=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E7=9A=84=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 9 ++++++++- db/migrate/20150811080754_course_activities.rb | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/models/course.rb b/app/models/course.rb index 6d71ad967..a56ea5949 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -33,6 +33,8 @@ class Course < ActiveRecord::Base has_many :student_works, :through => :homework_commons, :dependent => :destroy has_many :course_groups, :dependent => :destroy + # 课程动态 + has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy acts_as_taggable acts_as_nested_set :order => 'name', :dependent => :destroy @@ -44,7 +46,7 @@ class Course < ActiveRecord::Base validates_format_of :name,:with =>/^[^ ]+[a-zA-Z0-9_\u4e00-\u9fa5\s\S]+$/ validates_length_of :description, :maximum => 10000 before_save :self_validate - after_create :create_board_sync + after_create :create_board_sync, :act_as_course_activity before_destroy :delete_all_members safe_attributes 'extra', @@ -310,6 +312,11 @@ class Course < ActiveRecord::Base end end + #课程动态公共表记录 + def act_as_course_activity + self.course_acts << CourseActivity.new(:user_id => self.tea_id,:course_id => self.id) + end + #项目与课程分离后,很多课程的名称等信息为空,这些数据信息存储在项目表中!!就是数据兼容的问题 #def name # read_attribute('name') || Project.find_by_identifier(self.extra).try(:name) diff --git a/db/migrate/20150811080754_course_activities.rb b/db/migrate/20150811080754_course_activities.rb index bdb8e19c0..a4cae915d 100644 --- a/db/migrate/20150811080754_course_activities.rb +++ b/db/migrate/20150811080754_course_activities.rb @@ -3,6 +3,7 @@ class CourseActivities < ActiveRecord::Migration def up Course.all.each do |course| transaction do + course.course_acts << CourseActivity.new(:user_id => course.tea_id,:course_id => course.id) #作业 course.homework_commons.each do |homework_common| homework_common.course_acts << CourseActivity.new(:user_id => homework_common.user_id,:course_id => course.id) From d67d21eb428d27c9bbd9ea4ac2fa5d9a6bbb78a4 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 12 Aug 2015 11:28:51 +0800 Subject: [PATCH 15/51] =?UTF-8?q?1=E3=80=81=E8=A7=A3=E5=86=B3=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=90=9C=E7=B4=A0=20=E5=88=86=E9=A1=B5=E5=BC=82?= =?UTF-8?q?=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 6 ++++++ app/views/projects/search.html.erb | 8 ++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 3dfae3432..f042bba50 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -86,8 +86,14 @@ class ProjectsController < ApplicationController @project_pages = Project.project_entities.visible.like(params[:name]).page(params[:page]).per(10) else @project_pages = Project.project_entities.visible.page(params[:page] ).per(10) + @project_pages = Project.project_entities.visible.page(params[:page] ).per(10) end @projects = @project_pages.order("created_on desc") + @limit = 10#per_page_option + + @project_count = Project.project_entities.visible.like(params[:name]).page(params[:page]).count + @project_pages = Paginator.new @project_count, @limit, params['page'] + respond_to do |format| format.html { render :layout => 'base' diff --git a/app/views/projects/search.html.erb b/app/views/projects/search.html.erb index b77b3fda6..3f2a61306 100644 --- a/app/views/projects/search.html.erb +++ b/app/views/projects/search.html.erb @@ -104,9 +104,13 @@
    <% end %> + - -<%= paginate @project_pages %> +<%#= paginate @project_pages %> From 2f77adfe9cdb3f194bbd3475f2d466e77dd9a0e7 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Wed, 12 Aug 2015 16:24:27 +0800 Subject: [PATCH 16/51] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E5=85=AC=E5=85=B1=E8=A1=A8=E7=9A=84=E5=AE=8C=E6=88=90=EF=BC=8C?= =?UTF-8?q?=E5=8E=BB=E6=8E=89=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E4=B8=8E=E6=88=91=E7=9B=B8=E5=85=B3=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E5=8A=A8=E6=80=81=E7=9A=84=E9=A1=B5=E9=9D=A2=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 89 +------------------- app/helpers/courses_helper.rb | 53 ++++++++++++ app/models/course.rb | 2 + app/views/courses/show.html.erb | 104 +++++++----------------- app/views/layouts/base_courses.html.erb | 2 +- public/stylesheets/courses.css | 2 +- 6 files changed, 89 insertions(+), 163 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index d9980e286..aa66dd7a0 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -663,92 +663,9 @@ class CoursesController < ApplicationController end def show - if params[:jump] && redirect_to_course_menu_item(@course, params[:jump]) - return - end - @users_by_role = @course.users_by_role - if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id))) - @user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id) - end - @key = User.current.rss_key - #新增内容 - @days = Setting.activity_days_default.to_i - if params[:from] - begin; @date_to = params[:from].to_date + 1; rescue; end - end - has = { - "show_course_files" => true, - "show_course_news" => true, - "show_course_messages" => true, - #"show_course_journals_for_messages" => true, - # "show_bids" => true, - # "show_homeworks" => true, - "show_polls" => true - } - @date_to ||= Date.today + 1 - @date_from = (@date_to - @days) > @course.created_at.to_date ? (@date_to - @days) : @course.created_at.to_date - @author = (params[:user_id].blank? ? nil : User.active.find(params[:user_id])) - if @author.nil? - # 显示老师和助教的活动 - # @authors = searchTeacherAndAssistant(@course) - @authors = course_all_member(@course) - events = [] - key = "course_events_#{@course.id}".to_sym - if Rails.env.production? && Setting.course_cahce_enabled? - events = Rails.cache.read(key) || [] - end - if events.empty? - @authors.each do |author| - @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course, - :with_subprojects => false, - :author => author.user) - - @activity.scope_select {|t| has["show_#{t}"]} - # modify by nwb - # 添加私密性判断 - if User.current.member_of_course?(@course)|| User.current.admin? - events += @activity.events(@days, @course.created_at) - else - events += @activity.events(@days, @course.created_at, :is_public => 1) - end - end - Rails.cache.write(key, events) if Rails.env.production? && Setting.course_cahce_enabled? - end - else - # @author = @course.teacher - @activity = Redmine::Activity::Fetcher.new(User.current, :course => @course, - :with_subprojects => false, - :author => @author) - - @activity.scope_select {|t| has["show_#{t}"]} - # modify by nwb - # 添加私密性判断 - if User.current.member_of_course?(@course)|| User.current.admin? - events = @activity.events(@days, @course.created_at) - else - events = @activity.events(@days, @course.created_at, :is_public => 1) - end - end - - # 无新动态时,显示老动态 - if events.count == 0 - if User.current.member_of_course?(@course)|| User.current.admin? - events = @activity.events - else - events = @activity.events(:is_public => 1) - end - end - @sort_by = %w(category date title author).include?(params[:sort_by]) ? params[:sort_by] : 'category' - if(User.find_by_id(CourseInfos.find_by_course_id(@course.id).try(:user_id))) - @user = User.find_by_id(CourseInfos.find_by_course_id(@course.id).user_id) - end - - sorted_events = sort_activity_events_course(events) - events = paginateHelper sorted_events,10 - @events_by_day = events.group_by {|event| User.current.time_to_date(event.event_datetime)} - # documents - - + course_activities = @course.course_activities.order("created_at desc") + @canShowRealName = User.current.member_of_course? @course + @course_activities = paginateHelper course_activities,10 respond_to do |format| format.html{render :layout => 'base_courses'} format.api diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 597d5749c..da7a34a98 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -676,4 +676,57 @@ module CoursesHelper end result end + + #生成课程相关动态的链接 + def course_activity_link activity + # activity = CourseActivity.first + title = "" + url = "" + case activity.course_act_type + when "Course" + title = activity.course_act.name + url = course_path activity.course + when "HomeworkCommon" + title = "作业 " + activity.course_act.name + url = student_work_index_path(:homework => activity.course_act.id) + when "News" + title = "通知公告 " + activity.course_act.title + url = course_news_index_path(activity.course) + when "Attachment" + title = "课件 " + activity.course_act.filename + url = course_files_path(activity.course) + when "Message" + title = "课程讨论区 " + activity.course_act.subject + url = course_boards_path(activity.course,:parent_id => activity.course_act.parent_id ? activity.course_act.parent_id : activity.course_act.id, :topic_id => activity.course_act.id) + when "JournalsForMessage" + title = "留言 " + activity.course_act.notes + url = course_feedback_path(activity.course) + when "Poll" + title = "问卷 " + activity.course_act.polls_name + url = poll_index_path(:polls_type => "Course", :polls_group_id => activity.course_id) + end + link_to title.gsub(/<(?!img)[^>]*>/,'').html_safe, url, :class => "problem_tit c_dblue fl fb" + end + + #课程动态的描述 + def course_activity_desc activity + desc = "" + case activity.course_act_type + when "Course" + desc = "" + when "HomeworkCommon" + desc = activity.course_act.description + when "News" + desc = activity.course_act.description + when "Attachment" + desc = "" + when "Message" + desc = activity.course_act.content + when "JournalsForMessage" + desc = "" + when "Poll" + desc = activity.course_act.polls_description + end + desc.html_safe + end end diff --git a/app/models/course.rb b/app/models/course.rb index a56ea5949..89990dd48 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -36,6 +36,8 @@ class Course < ActiveRecord::Base # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy + has_many :course_activities + acts_as_taggable acts_as_nested_set :order => 'name', :dependent => :destroy acts_as_attachable :view_permission => :view_course_files, diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 654c25a42..7159c3c83 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -1,83 +1,37 @@
    -<% if @controller_name=='ActivityNotifys' %> - <%= l(:label_activity)%> -

    与我相关 - -

    - -<% else %>

    <%= l(:label_activity)%>

    - <% if User.current.logged? %> - 与我相关 - - - <% end %> -<% end %>
    -<% if @events_by_day != nil && @events_by_day.size >0 %> - <% @events_by_day.keys.sort.reverse.each do |day| %> - <% sort_activity_events(@events_by_day[day]).each do |e, in_group| -%> -
    - - <%= image_tag(url_to_avatar(e.event_author), :width => "42", :height => "42") %> - -
    - <%= link_to_user_header(e.event_author,false,:class => 'problem_name c_orange fl') if e.respond_to?(:event_author) %> - <%= link_to_user_header("(#{e.event_author})", @canShowRealName,:class => 'problem_name c_orange fl') if @canShowRealName && e.respond_to?(:event_author) %> -   - <%= l(:label_new_activity) %>: - <% - link = (e.event_type.eql?("attachment")&&e.container.kind_of?(Course)) ? course_files_path(e.container) : - (e.event_type.eql?("bid") ? homework_course_path(@course) : - (e.event_type.eql?("message") || e.event_type.eql?("reply") ? - course_boards_path(@course,:topic_id => e.id,:parent_id=>(e.parent_id ? e.parent_id : e.id)) : e.event_url)) - %> - <%= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), link, - :class => "problem_tit c_dblue fl fb",'data-type'=>e.event_type, - 'data-notify-id'=>(e.respond_to?('get_notify_id') ? e.get_notify_id : ''),:nhname=>"nh_act_link", - 'data-href'=>(course_activity_notifys_path(@course)+"/chang_read_flag?an_id="+(e.respond_to?('get_notify_id') ? e.get_notify_id : '').to_s)%> - <%if @controller_name=='ActivityNotifys' && e.get_notify_is_read!=1%> - - <%end%> -
    -

    <%= e.event_description.html_safe %> -
    -

    - <%= l :label_activity_time %> : <%= format_activity_day(day) %> <%= format_time(e.event_datetime, false) %> -

    - <%= link_to_attachments_course(e) if e.class.to_s == "News" %> -
    -
    -
    - <% end%> - <% end%> -<% elsif @controller_name=='ActivityNotifys' %> -

    <%= l(:label_no_data) %>

    -<% end%> -<% if @obj_pages.next_page.nil? && @controller_name!='ActivityNotifys' %> -
    - - <%= image_tag(url_to_avatar(@user), :width => "42", :height => "42") %> - -
    - <%= link_to_user_header(@user,false,:class => 'problem_name c_orange fl') %> - <%= link_to_user_header("(#{@user})", @canShowRealName,:class => 'problem_name c_orange fl') if @canShowRealName %> - <%= l(:label_user_create_project) %>: - <%= link_to @course.name,course_path(@course),:class => "problem_tit c_dblue fl fb"%> -
    -

    -
    - <%= l :label_create_time %> : <%= format_time(@course.created_at) %> -

    -
    -
    -
    +<%@course_activities.each do |activity|%> +
    + + <%= image_tag(url_to_avatar(activity.user), :width => "42", :height => "42") %> + +
    + <%= link_to_user_header(activity.user,false,:class => 'problem_name c_orange fl') %> +   + <%= activity.course_act_type == "Course" ? "创建了课程" : l(:label_new_activity) %>: + <%#= link_to "#{eventToLanguageCourse(e.event_type, @course)} "<< format_activity_title(e.event_title), link, + :class => "problem_tit c_dblue fl fb",'data-type'=>e.event_type, + 'data-notify-id'=>(e.respond_to?('get_notify_id') ? e.get_notify_id : ''),:nhname=>"nh_act_link", + 'data-href'=>(course_activity_notifys_path(@course)+"/chang_read_flag?an_id="+(e.respond_to?('get_notify_id') ? e.get_notify_id : '').to_s)%> + <%#if @controller_name=='ActivityNotifys' && e.get_notify_is_read!=1%> + + <%#end%> + <%= link_to course_activity_link activity%> +
    +

    + <%= course_activity_desc activity%> +
    +

    + <%= l :label_activity_time %> : <%= format_time(activity.created_at) %> +

    + <%= link_to_attachments_course(activity.course_act) if activity.course_act_type.to_s == "News" %> +
    +
    +
    <% end%> + diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb index 7a32cb67d..3242d79e9 100644 --- a/app/views/layouts/base_courses.html.erb +++ b/app/views/layouts/base_courses.html.erb @@ -113,7 +113,7 @@ <% end -%> diff --git a/app/views/layouts/_new_header.html.erb b/app/views/layouts/_new_header.html.erb index a756009f0..e650d43ca 100644 --- a/app/views/layouts/_new_header.html.erb +++ b/app/views/layouts/_new_header.html.erb @@ -53,6 +53,45 @@ + + +
  • + <%= link_to "#{l(:label_forge_message)}".html_safe %> + +
  • + <% end -%> <%= header_render_menu :account_menu -%> diff --git a/config/locales/projects/zh.yml b/config/locales/projects/zh.yml index e47cd476c..bd3815375 100644 --- a/config/locales/projects/zh.yml +++ b/config/locales/projects/zh.yml @@ -67,6 +67,13 @@ zh: label_project_mail_upload: 上传了资源 label_invite: 邀请 + + # 项目消息通知 + label_forge_message: 消息 + label_issue_message: 问题 + label_course_message: 课程消息 + label_project_message: 项目消息 + label_issue_tracking: 问题跟踪 label_release_issue: 发布问题 diff --git a/public/javascripts/header.js b/public/javascripts/header.js index 06748d726..d33b80e3d 100644 --- a/public/javascripts/header.js +++ b/public/javascripts/header.js @@ -46,6 +46,54 @@ $(document).ready(function () { addCourseSlipMenu(); }); +//消息提醒 +function MessageAddSlipMenu () { + var loggedas = $('#current_message_li a:first'); + var sub_menu = $('#message_sub_menu'); + loggedas.mouseenter(function() { + sub_menu.show(); + $('#my_projects_message_ul').hide(); + $('#my_courses_message_ul').hide(); + }); + sub_menu.mouseleave(function() { + sub_menu.hide(); + $('#my_projects_message_ul').hide(); + $('#my_courses_message_ul').hide(); + }); +} + +function MessageAddProjectSlipMenu () { + var loggedas = $('#my_projects_message_li'); + var project_sub_menu = $('#my_projects_message_ul'); + var course_sub_menu = $('#my_courses_message_ul'); + loggedas.mouseenter(function() { + course_sub_menu.hide(); + project_sub_menu.show(); + }); + loggedas.mouseleave(function() { + project_sub_menu.hide(); + course_sub_menu.hide(); + }); +} +function MessageAddCourseSlipMenu () { + var loggedas = $('#my_courses_message_li'); + var project_sub_menu = $('#my_projects_message_ul'); + var course_sub_menu = $('#my_courses_message_ul'); + loggedas.mouseenter(function() { + project_sub_menu.hide(); + course_sub_menu.show(); + }); + loggedas.mouseleave(function() { + course_sub_menu.hide(); + project_sub_menu.hide(); + }); +} + +$(document).ready(function () { + MessageAddSlipMenu(); + MessageAddProjectSlipMenu (); + MessageAddCourseSlipMenu(); +}); //将右侧的最小高度设置成左侧高度,美化界面 $(document).ready(function () { $("#RSide").css("min-height",$("#LSide").height()-30); From 5dd2befe884e7f2f99dcc2d9a19a8c88c237a9df Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 13 Aug 2015 10:10:01 +0800 Subject: [PATCH 22/51] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=9C=8B=E8=BF=87=E5=90=8E=E5=8D=B3=E4=B8=8D=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 7 ++++++- app/models/user.rb | 9 ++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 539d84e65..9e8240b15 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -112,7 +112,12 @@ class IssuesController < ApplicationController end def show - + # 当前用户查看指派给他的缺陷消息,则设置消息为已读 + query = @issue.forge_messages + if User.current.id == @issue.assigned_to_id + query.update_all(:viewed => true) + end + # @journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all @journals.each_with_index {|j,i| j.indice = i+1} @journals.reject!(&:private_notes?) unless User.current.allowed_to?(:view_private_notes, @issue.project) diff --git a/app/models/user.rb b/app/models/user.rb index e62976658..d5b497563 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -109,7 +109,6 @@ class User < Principal has_many :contests, :foreign_key => 'author_id', :dependent => :destroy has_many :softapplications, :foreign_key => 'user_id', :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy - has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" has_many :journal_replies, :dependent => :destroy has_many :activities, :dependent => :destroy has_many :students_for_courses @@ -131,6 +130,9 @@ class User < Principal # 关联虚拟表 has_many :forge_messages # end +# 虚拟转换 + has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" + has_many :issue_assigns, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Issue"' # 邮件邀请状态 # has_many :invite_lists @@ -246,10 +248,7 @@ class User < Principal # 查询指派给我的缺陷记录 def count_new_issue_assign_to - # count = self.forge_messages.where("viewed=? and forge_message_type=?", 0,Issue).count - - self.forge_messages(:conditions => ["viewed=? and forge_message_type=?", 0,Issue]) - #issue_assign_count = issue_assign_messages.count + self.issue_assigns end # end From fbf21fc51b072d9b7eb71ce03d718f1a27ba2805 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 13 Aug 2015 10:12:19 +0800 Subject: [PATCH 23/51] =?UTF-8?q?=E6=B8=85=E9=99=A4=E6=97=A7=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E6=B6=88=E6=81=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_base_header.html.erb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index 73ae40a28..278faae3b 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -37,11 +37,7 @@ {:controller=> 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.host_user}, {:class => 'my-message'} if User.current.logged?%> -
  • - <%=link_to l(:label_issue_message)+'('+User.current.count_new_issue_assign_to.to_s+')', - {:controller=> 'users', :action => 'user_newfeedback', id: User.current.id, host: Setting.host_user}, - {:class => 'my-message'} if User.current.logged?%> -
  • +
    <% end -%> From b036d5b63daf595113067bb385596a735fae88b9 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 13 Aug 2015 11:08:02 +0800 Subject: [PATCH 24/51] =?UTF-8?q?=E7=BD=91=E7=AB=99=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E3=80=81=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5=E3=80=81=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E3=80=81=E8=AF=BE=E7=A8=8B=E7=AD=89=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?header=E9=A1=B9=E7=9B=AE/=E8=AF=BE=E7=A8=8B=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=E6=8C=89=E7=85=A7=E6=9C=80=E6=96=B0=E7=9A=84=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/application_helper.rb | 2 +- app/views/layouts/_base_header.html.erb | 2 +- app/views/layouts/_base_header_new.html.erb | 10 +++++++--- app/views/layouts/_new_header.html.erb | 4 ++-- app/views/layouts/_user_courses_list.html.erb | 2 +- app/views/layouts/_user_project_list.html.erb | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d82db77b2..9b9bf5f76 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1812,7 +1812,7 @@ module ApplicationHelper #获取用户未过期的课程 def get_user_course user courses_doing = [] - user.courses.each do |course| + user.courses.select("courses.*,(SELECT MAX(created_at) FROM `course_activities` WHERE course_activities.course_id = courses.id) AS a").order("a desc").each do |course| if !course_endTime_timeout?(course) courses_doing.push course end diff --git a/app/views/layouts/_base_header.html.erb b/app/views/layouts/_base_header.html.erb index 49c8b5499..c6ba7cf10 100644 --- a/app/views/layouts/_base_header.html.erb +++ b/app/views/layouts/_base_header.html.erb @@ -18,7 +18,7 @@
    <% end -%> From 4b5022bfc6d994ecc65cd9315504a4ba2863e079 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 13 Aug 2015 14:56:01 +0800 Subject: [PATCH 28/51] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index da7a34a98..27a973213 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -711,21 +711,23 @@ module CoursesHelper #课程动态的描述 def course_activity_desc activity desc = "" - case activity.course_act_type - when "Course" - desc = "" - when "HomeworkCommon" - desc = activity.course_act.description - when "News" - desc = activity.course_act.description - when "Attachment" - desc = "" - when "Message" - desc = activity.course_act.content - when "JournalsForMessage" - desc = "" - when "Poll" - desc = activity.course_act.polls_description + if activity.course_act + case activity.course_act_type + when "Course" + desc = "" + when "HomeworkCommon" + desc = activity.course_act.description + when "News" + desc = activity.course_act.description + when "Attachment" + desc = "" + when "Message" + desc = activity.course_act.content + when "JournalsForMessage" + desc = "" + when "Poll" + desc = activity.course_act.polls_description + end end desc.html_safe end From 3e9f3f4e709c9976ab0226fa34f7a4f16b27c061 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Thu, 13 Aug 2015 15:00:13 +0800 Subject: [PATCH 29/51] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8A=A8=E6=80=81?= =?UTF-8?q?=EF=BC=8C=E6=97=A0=E5=AF=B9=E5=BA=94=E6=95=B0=E6=8D=AE=E6=97=B6?= =?UTF-8?q?=E6=8A=A5=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 46 ++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index 27a973213..ac142f5a1 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -682,28 +682,30 @@ module CoursesHelper # activity = CourseActivity.first title = "" url = "" - case activity.course_act_type - when "Course" - title = activity.course_act.name - url = course_path activity.course - when "HomeworkCommon" - title = "作业 " + activity.course_act.name - url = student_work_index_path(:homework => activity.course_act.id) - when "News" - title = "通知公告 " + activity.course_act.title - url = course_news_index_path(activity.course) - when "Attachment" - title = "课件 " + activity.course_act.filename - url = course_files_path(activity.course) - when "Message" - title = "课程讨论区 " + activity.course_act.subject - url = course_boards_path(activity.course,:parent_id => activity.course_act.parent_id ? activity.course_act.parent_id : activity.course_act.id, :topic_id => activity.course_act.id) - when "JournalsForMessage" - title = "留言 " + activity.course_act.notes - url = course_feedback_path(activity.course) - when "Poll" - title = "问卷 " + activity.course_act.polls_name - url = poll_index_path(:polls_type => "Course", :polls_group_id => activity.course_id) + if activity.course_act + case activity.course_act_type + when "Course" + title = activity.course_act.name + url = course_path activity.course + when "HomeworkCommon" + title = "作业 " + activity.course_act.name + url = student_work_index_path(:homework => activity.course_act.id) + when "News" + title = "通知公告 " + activity.course_act.title + url = course_news_index_path(activity.course) + when "Attachment" + title = "课件 " + activity.course_act.filename + url = course_files_path(activity.course) + when "Message" + title = "课程讨论区 " + activity.course_act.subject + url = course_boards_path(activity.course,:parent_id => activity.course_act.parent_id ? activity.course_act.parent_id : activity.course_act.id, :topic_id => activity.course_act.id) + when "JournalsForMessage" + title = "留言 " + activity.course_act.notes + url = course_feedback_path(activity.course) + when "Poll" + title = "问卷 " + activity.course_act.polls_name + url = poll_index_path(:polls_type => "Course", :polls_group_id => activity.course_id) + end end link_to title.gsub(/<(?!img)[^>]*>/,'').html_safe, url, :class => "problem_tit c_dblue fl fb" end From c9033253528ac690755863bedf1c2c44cfe3dc48 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 13 Aug 2015 16:55:25 +0800 Subject: [PATCH 30/51] =?UTF-8?q?=E7=BC=BA=E9=99=B7=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92=20?= =?UTF-8?q?=E7=95=99=E8=A8=80=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 7 +++++++ app/models/journal.rb | 11 ++++++++++- app/models/user.rb | 8 +++++++- app/views/layouts/_new_header.html.erb | 7 ++++++- 4 files changed, 30 insertions(+), 3 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 9e8240b15..0995d1304 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -117,6 +117,13 @@ class IssuesController < ApplicationController if User.current.id == @issue.assigned_to_id query.update_all(:viewed => true) end + # 缺陷状态更新 + query_journals = @issue.journals + if User.current.id == @issue.author_id + query_journals.each do |query_journal| + query_journal.forge_messages.update_all(:viewed => true) + end + end # @journals = @issue.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all @journals.each_with_index {|j,i| j.indice = i+1} diff --git a/app/models/journal.rb b/app/models/journal.rb index 14eecc9cd..c705b1a09 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -29,6 +29,8 @@ class Journal < ActiveRecord::Base has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy # 被ForgeActivity虚拟关联 has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy + # 被ForgeMessage虚拟关联 + has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy # end attr_accessor :indice @@ -48,7 +50,7 @@ class Journal < ActiveRecord::Base before_create :split_private_notes # fq - after_save :act_as_activity,:be_user_score,:act_as_forge_activity + after_save :act_as_activity,:be_user_score,:act_as_forge_activity, :act_as_forge_message # end #after_destroy :down_user_score #before_save :be_user_score @@ -167,6 +169,13 @@ class Journal < ActiveRecord::Base end + # 缺陷状态更改,消息提醒 + def act_as_forge_message + self.forge_messages << ForgeMessage.new(:user_id => self.issue.author_id, + :project_id => self.issue.project_id, + :viewed => false) + end + # 更新用户分数 -by zjc def be_user_score #新建了缺陷留言且留言不为空,不为空白 diff --git a/app/models/user.rb b/app/models/user.rb index d5b497563..3cd248c8a 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -130,10 +130,11 @@ class User < Principal # 关联虚拟表 has_many :forge_messages # end + # 虚拟转换 has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" has_many :issue_assigns, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Issue"' - + has_many :status_updates, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Journal"' # 邮件邀请状态 # has_many :invite_lists # end @@ -250,6 +251,11 @@ class User < Principal def count_new_issue_assign_to self.issue_assigns end + + # 查询指派给我的缺陷记录 + def issue_status_update + self.status_updates + end # end def extensions diff --git a/app/views/layouts/_new_header.html.erb b/app/views/layouts/_new_header.html.erb index e650d43ca..ad1db88d0 100644 --- a/app/views/layouts/_new_header.html.erb +++ b/app/views/layouts/_new_header.html.erb @@ -79,10 +79,15 @@ <%= "#{l(:label_project_message)}"+"("+User.current.count_new_issue_assign_to.count.to_s+")" %> <% end %> From 2c865069d31c3268a10af30000c6cdc878ef6491 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 13 Aug 2015 22:33:08 +0800 Subject: [PATCH 31/51] =?UTF-8?q?=E6=89=80=E6=9C=89=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 14 ++- app/views/layouts/_base_header_new.html.erb | 5 + app/views/users/user_messages.html.erb | 117 ++++++++++++++++++++ config/routes.rb | 2 + 4 files changed, 136 insertions(+), 2 deletions(-) create mode 100644 app/views/users/user_messages.html.erb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 410bd44e1..f2b5b1af0 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -28,6 +28,7 @@ class UsersController < ApplicationController # menu_item :requirement_focus, :only => :watch_bids menu_item :requirement_focus, :only => :watch_contests menu_item :user_newfeedback, :only => :user_newfeedback + menu_item :user_messages, :only => :user_messages #Ended by young @@ -40,14 +41,14 @@ class UsersController < ApplicationController :user_watchlist, :user_fanslist,:update, :user_courses, :user_homeworks, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_new_score_index, :influence_new_score_index, :score_new_index,:update_score,:user_activities,:user_projects_index, - :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist] + :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages] #edit has been deleted by huang, 2013-9-23 before_filter :find_user, :only => [:user_fanslist, :user_watchlist, :show, :edit, :update, :destroy, :edit_membership, :user_courses, :user_homeworks, :destroy_membership, :user_activities, :user_projects, :user_newfeedback, :user_comments, :watch_contests, :info, :watch_projects, :show_score, :topic_score_index, :project_score_index, :activity_score_index, :influence_score_index, :score_index,:show_new_score, :topic_new_score_index, :project_new_score_index, :activity_new_score_index, :influence_new_score_index, :score_new_index,:user_projects_index, - :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist] + :user_courses4show,:user_projects4show,:user_course_activities,:user_project_activities,:user_feedback4show,:user_visitorlist,:user_messages] before_filter :auth_user_extension, only: :show #before_filter :rest_user_score, only: :show #before_filter :select_entry, only: :user_projects @@ -95,6 +96,15 @@ class UsersController < ApplicationController end end + # 用户消息 + def user_messages + #@user_messges = User.current.forge_messages + respond_to do |format| + format.html{render :layout=>'base_users_new'} + format.api + end + end + def user_projects_index if User.current.admin? memberships = @user.memberships.all(conditions: "projects.project_type = #{Project::ProjectType_project}").first diff --git a/app/views/layouts/_base_header_new.html.erb b/app/views/layouts/_base_header_new.html.erb index 67c750fe4..a3b5702c1 100644 --- a/app/views/layouts/_base_header_new.html.erb +++ b/app/views/layouts/_base_header_new.html.erb @@ -71,6 +71,11 @@ +
  • + <%=link_to l(:label_my_message)+'('+User.current.count_new_jour.to_s+')', + {:controller=> 'users', :action => 'user_messages', id: User.current.id, host: Setting.host_user}, + {:class => 'my-message'} if User.current.logged?%> +
  • <% end %> diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb new file mode 100644 index 000000000..463381db8 --- /dev/null +++ b/app/views/users/user_messages.html.erb @@ -0,0 +1,117 @@ +
    + + + 新建课程 + +
    + + +
    + +
    + +
    + + + + + diff --git a/config/routes.rb b/config/routes.rb index cdcb1126c..d139864b2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -322,6 +322,7 @@ RedmineApp::Application.routes.draw do match 'user_visitorlist', :to => 'users#user_visitorlist', :via => :get match 'user_homeworks', :to => 'users#user_homeworks', :via => :get match 'watch_projects', :to => 'users#watch_projects', :via => :get + # added by bai match 'show_score', :to => 'users#show_score', :via => :get match 'topic_score_index', :to => 'users#topic_score_index', :via => [:get, :post] @@ -349,6 +350,7 @@ RedmineApp::Application.routes.draw do end match 'users/:id/user_newfeedback', :to => 'users#user_newfeedback', :via => :get, :as => "feedback" match 'users/:id/user_projects', :to => 'users#user_projects', :via => :get + match 'users/:id/user_messages', :to => 'users#user_messages', :via => :get #end match 'my/account', :via => [:get, :post] From 5cf6b7e76afc83018bd71e5e5905418db210d73d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 09:38:24 +0800 Subject: [PATCH 32/51] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E6=97=B6=E9=97=B4--->=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/courses/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/courses/show.html.erb b/app/views/courses/show.html.erb index 7159c3c83..6eb722981 100644 --- a/app/views/courses/show.html.erb +++ b/app/views/courses/show.html.erb @@ -24,7 +24,7 @@ <%= course_activity_desc activity%>
    - <%= l :label_activity_time %> : <%= format_time(activity.created_at) %> + <%= activity.course_act_type == "Course" ? l(:label_create_time) : l(:label_activity_time) %> : <%= format_time(activity.created_at) %>

    <%= link_to_attachments_course(activity.course_act) if activity.course_act_type.to_s == "News" %> From a5c941f48caa1baf42f933f023487cdf1096bf38 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 14 Aug 2015 10:19:59 +0800 Subject: [PATCH 33/51] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E9=80=9A=E7=9F=A5=E6=B6=88=E6=81=AF=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 1 + app/models/course_message.rb | 12 ++++++++++++ app/models/news.rb | 19 +++++++++++++++++-- .../20150814011838_create_course_messages.rb | 13 +++++++++++++ spec/factories/course_messages.rb | 10 ++++++++++ 5 files changed, 53 insertions(+), 2 deletions(-) create mode 100644 app/models/course_message.rb create mode 100644 db/migrate/20150814011838_create_course_messages.rb create mode 100644 spec/factories/course_messages.rb diff --git a/app/models/course.rb b/app/models/course.rb index 89990dd48..26220f245 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -37,6 +37,7 @@ class Course < ActiveRecord::Base has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy has_many :course_activities + has_many :course_messages acts_as_taggable acts_as_nested_set :order => 'name', :dependent => :destroy diff --git a/app/models/course_message.rb b/app/models/course_message.rb new file mode 100644 index 000000000..59089829d --- /dev/null +++ b/app/models/course_message.rb @@ -0,0 +1,12 @@ +class CourseMessage < ActiveRecord::Base + attr_accessible :course_id, :course_message_id, :course_message_type, :user_id, :viewed + + # 多态 虚拟关联 + belongs_to :course_message ,:polymorphic => true + belongs_to :course + belongs_to :user + validates :user_id,presence: true + validates :course_id,presence: true + validates :course_message_id,presence: true + validates :course_message_type, presence: true +end diff --git a/app/models/news.rb b/app/models/news.rb index e5c1d192a..99d26d456 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -31,6 +31,9 @@ class News < ActiveRecord::Base # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy # end + # 课程消息 + has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy + #end has_many :ActivityNotifies,:as => :activity, :dependent => :destroy @@ -51,7 +54,7 @@ class News < ActiveRecord::Base :author_key => :author_id acts_as_watchable - after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:add_author_as_watcher, :send_mail + after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_course_messge, :add_author_as_watcher, :send_mail after_destroy :delete_kindeditor_assets @@ -130,6 +133,18 @@ class News < ActiveRecord::Base end end + #课程通知 消息发送 + #消息发送原则:除了消息的发布者,课程的其它成员都能收到消息提醒 + def act_as_course_messge + if self.course + self.course.members.each do |m| + if m.user_id != self.author_id + self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) + end + end + end + end + # Time 2015-03-31 13:50:54 # Author lizanle # Description 删除news后删除对应的资源 @@ -141,4 +156,4 @@ class News < ActiveRecord::Base Mailer.run.news_added(self) if Setting.notified_events.include?('news_added') end -end +end \ No newline at end of file diff --git a/db/migrate/20150814011838_create_course_messages.rb b/db/migrate/20150814011838_create_course_messages.rb new file mode 100644 index 000000000..266f2b075 --- /dev/null +++ b/db/migrate/20150814011838_create_course_messages.rb @@ -0,0 +1,13 @@ +class CreateCourseMessages < ActiveRecord::Migration + def change + create_table :course_messages do |t| + t.integer :user_id + t.integer :course_id + t.integer :course_message_id + t.string :course_message_type + t.integer :viewed + + t.timestamps + end + end +end diff --git a/spec/factories/course_messages.rb b/spec/factories/course_messages.rb new file mode 100644 index 000000000..7b2523adc --- /dev/null +++ b/spec/factories/course_messages.rb @@ -0,0 +1,10 @@ +FactoryGirl.define do + factory :course_message do + user_id 1 +course_id 1 +course_message_id 1 +course_message_type "MyString" +viewed 1 + end + +end From 35d6c76a8e99ba2a9d5487e29ba1726501f6a935 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 13:55:46 +0800 Subject: [PATCH 34/51] =?UTF-8?q?=E9=83=A8=E5=88=86=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4=E4=B8=8D?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...50811083234_update_course_activity_time.rb | 22 ------------------- .../20150814024425_change_attachment_time.rb | 13 +++++++++++ ...50814031258_update_course_activity_time.rb | 22 +++++++++++++++++++ db/schema.rb | 2 +- 4 files changed, 36 insertions(+), 23 deletions(-) delete mode 100644 db/migrate/20150811083234_update_course_activity_time.rb create mode 100644 db/migrate/20150814024425_change_attachment_time.rb create mode 100644 db/migrate/20150814031258_update_course_activity_time.rb diff --git a/db/migrate/20150811083234_update_course_activity_time.rb b/db/migrate/20150811083234_update_course_activity_time.rb deleted file mode 100644 index 9ba8140d8..000000000 --- a/db/migrate/20150811083234_update_course_activity_time.rb +++ /dev/null @@ -1,22 +0,0 @@ -class UpdateCourseActivityTime < ActiveRecord::Migration - def up - count = CourseActivity.all.count / 10 + 1 - transaction do - for i in 1 ... count do i - CourseActivity.page(i).per(10).each do |activity| - if activity.course_act - if activity.course_act.respond_to?("created_at") - activity.created_at = activity.course_act.created_at - elsif activity.course_act.respond_to?("created_on") - activity.created_at = activity.course_act.created_on - end - activity.save - end - end - end - end - end - - def down - end -end diff --git a/db/migrate/20150814024425_change_attachment_time.rb b/db/migrate/20150814024425_change_attachment_time.rb new file mode 100644 index 000000000..fd1ffb7a7 --- /dev/null +++ b/db/migrate/20150814024425_change_attachment_time.rb @@ -0,0 +1,13 @@ +class ChangeAttachmentTime < ActiveRecord::Migration + def up + Attachment.where("container_type = 'Course'").each do |attachment| + if attachment.container && attachment.container.created_at.to_i > attachment.created_on.to_i + attachment.created_on = attachment.container.created_at + 3600 * 24 + attachment.save + end + end + end + + def down + end +end diff --git a/db/migrate/20150814031258_update_course_activity_time.rb b/db/migrate/20150814031258_update_course_activity_time.rb new file mode 100644 index 000000000..155e212a3 --- /dev/null +++ b/db/migrate/20150814031258_update_course_activity_time.rb @@ -0,0 +1,22 @@ +class UpdateCourseActivityTime < ActiveRecord::Migration + def up + count = CourseActivity.all.count / 10 + 1 + transaction do + for i in 1 ... count do i + CourseActivity.page(i).per(10).each do |activity| + if activity.course_act + if activity.course_act.respond_to?("created_at") + activity.created_at = activity.course_act.created_at + elsif activity.course_act.respond_to?("created_on") + activity.created_at = activity.course_act.created_on + end + activity.save + end + end + end + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 1488ca365..2014bf1ef 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 => 20150811083234) do +ActiveRecord::Schema.define(:version => 20150814031258) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 50fa03d00cd0a2bdfd6184a68945ee5fb6d94a6b Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 14:44:31 +0800 Subject: [PATCH 35/51] =?UTF-8?q?=E5=8F=91=E5=B8=83=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E8=AF=A5=E9=97=AE=E5=8D=B7=E6=89=8D=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E5=9C=A8=E5=8A=A8=E6=80=81=EF=BC=8C=E5=8F=96=E6=B6=88?= =?UTF-8?q?=E5=8F=91=E5=B8=83=E5=90=8E=E5=8F=96=E6=B6=88=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E8=AF=A5=E5=8A=A8=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/poll.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/models/poll.rb b/app/models/poll.rb index 34a381246..3adbbb791 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -10,7 +10,7 @@ class Poll < ActiveRecord::Base has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy - after_create :act_as_activity, :act_as_course_activity + before_save :act_as_activity, :act_as_course_activity acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" }, :description => :polls_description, @@ -32,7 +32,11 @@ class Poll < ActiveRecord::Base #课程动态公共表记录 def act_as_course_activity if self.polls_type == "Course" - self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id) + if self.polls_status == 2 #问卷是发布状态 + self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id) + elsif self.polls_status == 1 #问卷是新建状态 + self.course_acts.destroy_all + end end end end From a8283a28617d18113b45e511ad22c43bd7b0174c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 14:46:14 +0800 Subject: [PATCH 36/51] =?UTF-8?q?=E7=82=B9=E5=87=BB=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E5=8A=A8=E6=80=81=EF=BC=8C=E8=B7=B3=E8=BD=AC=E5=88=B0=E7=AD=94?= =?UTF-8?q?=E9=A2=98=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/courses_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb index ac142f5a1..f9fb31969 100644 --- a/app/helpers/courses_helper.rb +++ b/app/helpers/courses_helper.rb @@ -704,7 +704,7 @@ module CoursesHelper url = course_feedback_path(activity.course) when "Poll" title = "问卷 " + activity.course_act.polls_name - url = poll_index_path(:polls_type => "Course", :polls_group_id => activity.course_id) + url = poll_path(activity.course_act_id) end end link_to title.gsub(/<(?!img)[^>]*>/,'').html_safe, url, :class => "problem_tit c_dblue fl fb" From 16aea5ef4291b6c7371315f33730e2a5a4b7755c Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 15:44:54 +0800 Subject: [PATCH 37/51] =?UTF-8?q?=E8=BF=9F=E4=BA=A4=E6=89=A3=E5=88=860-50?= =?UTF-8?q?=E5=88=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_homework_detail_manual_form.html.erb | 3 ++- .../_homework_detail_programing_form.html.erb | 3 ++- public/javascripts/course.js | 18 ++++++++++++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/app/views/homework_common/_homework_detail_manual_form.html.erb b/app/views/homework_common/_homework_detail_manual_form.html.erb index ffec93e73..3af12973a 100644 --- a/app/views/homework_common/_homework_detail_manual_form.html.erb +++ b/app/views/homework_common/_homework_detail_manual_form.html.erb @@ -48,7 +48,8 @@
    • - <%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %> + <%#= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %> +  分
    • diff --git a/app/views/homework_common/_homework_detail_programing_form.html.erb b/app/views/homework_common/_homework_detail_programing_form.html.erb index 8c589c040..829905327 100644 --- a/app/views/homework_common/_homework_detail_programing_form.html.erb +++ b/app/views/homework_common/_homework_detail_programing_form.html.erb @@ -43,7 +43,8 @@
    • - <%= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %> + <%#= select_tag :late_penalty,options_for_select(late_penalty_option,homework.late_penalty), {:class => "fl mb10 h26 w70"} %> +  分
    • diff --git a/public/javascripts/course.js b/public/javascripts/course.js index 6ba202b28..be29fdc30 100644 --- a/public/javascripts/course.js +++ b/public/javascripts/course.js @@ -412,6 +412,24 @@ function regex_homework_name() } } +//处理迟交扣分 +function check_late_penalty() +{ + var obj = $("input[name='late_penalty']"); + var regex = /^\d+$/; + if(regex.test(obj.val())) + { + if(obj.val() > 50) + { + obj.val("50"); + } + } + else + { + obj.val("0"); + } +} + //验证匿评数量 function regex_evaluation_num() { From 7ea0fac7741aa7bd154b5abad1014d5d2c7527f4 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 14 Aug 2015 15:48:23 +0800 Subject: [PATCH 38/51] =?UTF-8?q?1=E3=80=82=E5=8F=91=E5=B8=83=E4=BD=9C?= =?UTF-8?q?=E4=B8=9A=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92=202=E3=80=81?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E9=97=AE=E5=8D=B7=E6=B6=88=E6=81=AF=E6=8F=90?= =?UTF-8?q?=E9=86=92=203=E3=80=81=E6=B6=88=E6=81=AF=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=EF=BC=88=E6=9C=AA=E5=AE=8C=E6=88=90=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 2 +- app/models/homework_common.rb | 15 +- app/models/poll.rb | 16 +- app/views/users/user_messages.html.erb | 186 +++++++----------- .../stylesheets/images/resource_icon_list.png | Bin 0 -> 2476 bytes public/stylesheets/public_new.css | 151 ++++++++++++++ spec/models/course_message_spec.rb | 5 + 7 files changed, 258 insertions(+), 117 deletions(-) create mode 100644 public/stylesheets/images/resource_icon_list.png create mode 100644 spec/models/course_message_spec.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index f2b5b1af0..1579a23c4 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -98,7 +98,7 @@ class UsersController < ApplicationController # 用户消息 def user_messages - #@user_messges = User.current.forge_messages + @user_messges = @user.forge_messages respond_to do |format| format.html{render :layout=>'base_users_new'} format.api diff --git a/app/models/homework_common.rb b/app/models/homework_common.rb index 5fe01db96..217c7d770 100644 --- a/app/models/homework_common.rb +++ b/app/models/homework_common.rb @@ -15,12 +15,14 @@ class HomeworkCommon < ActiveRecord::Base has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy #用户活动 # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy + # 课程消息 + has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy acts_as_attachable acts_as_event :title => Proc.new {|o| "#{l(:label_course_homework)} ##{o.id}: #{o.name}" }, :description => :description, :author => :author, :url => Proc.new {|o| {:controller => 'student_work', :action => 'index', :homework => o.id}} - after_create :act_as_activity, :send_mail, :act_as_course_activity + after_create :act_as_activity, :send_mail, :act_as_course_activity, :act_as_course_message after_destroy :delete_kindeditor_assets def act_as_activity @@ -34,6 +36,17 @@ class HomeworkCommon < ActiveRecord::Base end end + #课程作业消息记录 + def act_as_course_message + if self.course + self.course.members.each do |m| + if m.user_id != self.user_id + self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.course_id, :viewed => false) + end + end + end + end + #删除对应的图片 def delete_kindeditor_assets delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::HOMEWORKCOMMON diff --git a/app/models/poll.rb b/app/models/poll.rb index 34a381246..c5a6a294d 100644 --- a/app/models/poll.rb +++ b/app/models/poll.rb @@ -10,7 +10,9 @@ class Poll < ActiveRecord::Base has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy - after_create :act_as_activity, :act_as_course_activity + # 课程消息 + has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy + after_create :act_as_activity, :act_as_course_activity, :act_as_course_message acts_as_event :title => Proc.new {|o| "#{l(:label_course_poll)}: #{o.polls_name}" }, :description => :polls_description, @@ -35,4 +37,16 @@ class Poll < ActiveRecord::Base self.course_acts << CourseActivity.new(:user_id => self.user_id,:course_id => self.polls_group_id) end end + + # 发布问卷,出了发布者外,其他人都能收到消息通知 + def act_as_course_message + if self.polls_type == "Course" + Course.find(self.polls_group_id).members.each do |m| + if m.user_id != self.user_id + self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.polls_group_id, :viewed => false) + end + end + end + end + end diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 463381db8..e7fcb790a 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -1,117 +1,75 @@ -
      - - - 新建课程 - -
      - - -
      - diff --git a/public/stylesheets/images/resource_icon_list.png b/public/stylesheets/images/resource_icon_list.png new file mode 100644 index 0000000000000000000000000000000000000000..1b5bc6f58c73e58545a57fc4e29463d4ef7a0e9b GIT binary patch literal 2476 zcmaJ@eLR!>8sFo!6rNP_QkqFh*=%gt3}Iv~WT|;gv)vfBd$zIBybtNcOG3~2WX@BL zULGu+h+~m@Bzoc$oxCM_ColUDAy4PrD|(*K`5fo|T=)I^UBA!w`d-)XdtHCr*$2J$ zX=@p2!C)|LvImI@t=`a^yGjH4HVkB9pv6$&<|jA=h6#jp9sqM@f}sGM%%+C}RDjNm zk7)ylFqkTW`FS3MyMjCbjz!v7F|5&OI1YzI+hTDz^lmuD8jV3&Lx!_L+Y+!i0%i|< z=|Mo*c+4;YmE^vZ3-TNg5ds01fIu^ zW2|l6&{zz9kLz+Q31q~w0ghlfmib4l-HNfwQDAeS%p`!viUXMLJdh3ldSwD@S z@-4+OSFQ!OVk`RgqJ zIcgIryJ8*OHKtML-Wtnx^NEmA=Ueeqm3;;S-2FaqbClK=_ugx4OnZ&x7|LUIX2y+` ziN5%BN4w4G(GS+wuHS6=$D>_=hp*7zm=W(nc4<|v!jg8_zT?B>q|=6CyrM;MRbe-0 zKW8P1J#?t+tzN0kdy~>rvujnI6eD#N8Qwec*bW0)22L63vU06v?5i6-&A)5NQaaN+ zC9Wm3jv)d8KR10EroDcYiW1L7uGF@haFaJ--Lae?H>%{kI+UlUg&p-#2? zoy@!xc3Xd({KF^M{sDcte63@~E2918b-xFNeo2+a30mR|GWs5+P-b=5)7zT^_djqV z%R*?;S*D+oI#>Tpe&6kNX=Bngk4`ZW`R+ZN=0*#2`m5<;a{n3ahEjFA=`|?@kqg_1 zS{?0kx-8*`ifz{Fj`#BP48knbU@F`y7k?d;%R9xX=`YN2*5!HeqD@Jxpp}lW|Y zY>dA!dlaMgT~BTADO`wZ#r)XKLOVI7JOcL5SFiJjADQ(%7R_jiWsRk0Hp)%Y8ux~6 zSD+oirmGHf#rc)BgR?9Hg3-~D1Jgm|%QnUe0>b$0LTTTnEf03j?JMo296xtC+<7Fv z!~*R#6qg(q?#-Z7YlX`Xv$jQ z@mnAF9=mc{Ui|)Jn2LOFtE+0HM3z3;T@|Ep9<{!tvbGAS2ow$>_UGV=JX)Ve9%!`r47QmY$I58QOnvUUxcANK6Vjk_>h zpCa(Xn2n7-6w^0`*G}Z5Po~Ih<65p#tbQ3U*eI>oLR6c?nTZcvJxh^FytZ27q^P06 z^sSO&qXw_*p8b1Sy2T&-@~EPnE%V<@55Gv9 zDu21kTR)*(fBr&uY_GrKV)dH0RsmYUXR^)YtIa>&y|JpXy}tOUu-s5y`?)fEp;7-G z$}2aMcIPucqo(XmNTpOg{DS=R(6eEd&mv`L;?a$u7zZ7TlSF~Zg&FaLx5)k6@HkRs zLcOl`S51^+UhLgHRBv&+b<>sSPm0>`m4#k?QHos)0UA&E;`<3R9f|zzzsSqN!}2DF z3dj6eGiBqkLnRSohCMEQ#%~5|ZC+1~=3wM4gl1hzr@P@G?Y=blxsgKX5qrC}r=-04 z li > a { + display: block; + padding: 3px 20px; + clear: both; + font-weight: normal; + line-height: 1.5; + color:#616060; + white-space: nowrap; +} +.dropdown-menu > li > a:hover{ + color: #ffffff; + text-decoration: none; + background-color: #64bdd9; + outline:none; +} + +/*发送资源弹窗*/ +/*.resourceShareContainer {width:100%; height:100%; background:#666; filter:alpha(opacity=50); opacity:0.5; -moz-opacity:0.5; position:absolute; left:0; top:0; z-index:-999;}*/ +.resourceSharePopup {width:300px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-150px; z-index:1000;} +.sendText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;} +.resourcePopupClose {width:20px; height:20px; display:inline-block; float:right;} +.resourceClose {background:url(images/resource_icon_list.png) 0px -40px no-repeat; width:20px; height:20px; display:inline-block;} +.resourcesSearchBox {border:1px solid #e6e6e6; width:225px; height:25px; background-color:#ffffff; margin-top:12px; margin-bottom:15px;} +.searchResourcePopup {border:none; outline:none; background-color:#ffffff; width:184px; height:25px; padding-left:10px; display:inline-block; float:left;} +.searchIconPopup{width:31px; height:25px; background-color:#ffffff; background:url(images/resource_icon_list.png) -40px -18px no-repeat; display:inline-block; float:left;} +.courseSend {width:260px; height:15px; line-height:15px; margin-bottom:10px;} +.courseSendCheckbox {padding:0px; margin:0px; width:12px; height:12px; margin-right:10px; display:inline-block; margin-top:2px;} +.sendCourseName {font-size:12px; color:#5f6060;} +.courseSendSubmit {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#64bdd9; margin-right:25px; float:left;} +.courseSendCancel {width:50px; height:25px; line-height:25px; text-align:center; vertical-align:middle; background-color:#c1c1c1; float:left} +a.sendSourceText {font-size:14px; color:#ffffff;} + +/*上传资源弹窗*/ +.resourceUploadPopup {width:400px; height:auto; border:3px solid #15bccf; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;} +.uploadText {font-size:16px; color:#15bccf; line-height:16px; padding-top:20px; width:140px; display:inline-block;} +.uploadBoxContainer {height:33px; line-height:33px; margin-top:10px; position:relative;} +.uploadBox {width:100px; height:33px; line-height:33px; text-align:center; vertical-align:middle; background-color:#64bdd9; border-radius:3px; float:left; margin-right:12px;} +a.uploadIcon {background:url(images/resource_icon_list.png) 8px -60px no-repeat; width:100px; height:33px;} +.chooseFile {color:#ffffff; display:block; margin-left:32px;} +.uploadResourceIntr {width:250px; height:33px; float:left; line-height:33px; font-size:12px;} +.uploadResourceName {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444; margin-bottom:2px;} +.uploadResourceIntr2 {width:250px; display:inline-block; line-height:15px; font-size:12px; color:#444444;} +.uploadType {margin:10px 0; border:1px solid #e6e6e6; width:100px; height:30px; outline:none; font-size:12px; color:#888888;} +.uploadKeyword {margin-bottom:10px; outline:none; border:1px solid #e6e6e6; height:30px; width:280px;} + + +/*新个人主页框架css*/ +.navContainer {width:100%; margin:0 auto; background-color:#15bccf;} +.homepageContentContainer {width:100%; margin:0 auto; background-color:#eaebed;} +.homepageContent {width:1000px; background-color:#eaebed; margin:0 auto;} +.navHomepage {width:1000px; height:54px; background-color:#15bccf; margin:0 auto;} +.navHomepageLogo {width:60px; height:54px; line-height:54px; vertical-align:middle; margin-left:2px; margin-right:40px;} +.navHomepageMenu {margin-right:40px;display:inline-block;height:54px; line-height:54px; vertical-align:middle;} +.navHomepageSearchBox {width:380px; border:none; outline:none; height:32px; margin-top:11px; background-color:#ffffff;} +.navHomepageSearchInput {width:345px; height:32px; outline:none; border:none; float:left; padding-left:5px;; margin:0;} +.homepageSearchIcon {width:30px; height:32px; background:url(../images/nav_icon.png) -8px 3px no-repeat; float:left;} +a.homepageSearchIcon:hover {background:url(../images/nav_icon.png) -49px 3px no-repeat;} +.navHomepageNews {width:30px; display:block; float:right; margin-top:12px; position:relative;} +.homepageNewsIcon {background:url(../images/nav_icon.png) -5px -85px no-repeat; width:30px; height:29px; display:block;} +.newsActive {width:10px; height:10px; border-radius:50%; border:2px solid #ffffff; background-color:#ff0000; position:absolute; left:17px; top:5px;} +.navHomepageProfile {width:65px; display:block; float:right; margin-top:8px; margin-left:33px;} +.homepageProfileMenuIcon {background:url(../images/nav_icon.png) -8px -175px no-repeat; width:20px; height:25px; float:left; margin-top:15px;} +a.homepageProfileMenuIcon:hover {background:url(../images/nav_icon.png) -8px -175px no-repeat; width:12px; height:12px; float:left;} +.homepageLeft {width:240px; float:left; margin-right:10px;} +.homepageRight {width:750px; float:left;} +.homepagePortraitContainer {width:238px; height:348px; border:1px solid #dddddd; background-color:#ffffff; margin-top:15px;} +.homepagePortraitImage {width:208px; height:208px; margin:15px 16px 14px 16px;} +.homepageFollow {} +.homepageEditProfile {} +.homepageImageName {font-size:16px; color:#484848; margin-left:15px; display:inline-block; margin-right:8px;} +.homepageImageSex {float:left; top:116px; left:5px; width:14px; height:14px; display:inline-block;} +.homepageSignature {font-size:12px; color:#888888; margin-left:15px; margin-top:5px; margin-bottom:15px;} +.homepageImageBlock {margin:0 26px; float:left; text-align:center; display:inline-block;} +.homepageImageNumber {font-size:12px; color:#484848;} +.homepageImageText {width:26px; font-size:12px; color:#888888;} +.homepageVerDiv {height:28px; vertical-align:middle; width:1px; float:left; display:inline-block; background-color:#d1d1d1; margin-top:3px;} +.homepageLeftMenuContainer {width:238px; border:1px solid #dddddd; border-bottom:none; background-color:#ffffff; margin-top:10px;} +.homepageLeftMenuBlock {border-bottom:1px solid #dddddd; height:50px; line-height:50px; vertical-align:middle;} +a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;} +.homepageLeftLabelContainer {width:238px; border:1px solid #dddddd; background-color:#ffffff; margin-top:10px;} +.homepageRightBanner {} +.newsType {width:60px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:35px; padding:5px 10px; left:-40px; font-size:12px; color:#888888; display:none; line-height:2;} +.homepageRightBlock {} +.homepageNewsList {width:710px; height:39px; line-height:39px; vertical-align:middle; border-bottom:1px dashed #eaeaea; margin:0 auto;} +.homepageNewsPublisher {width:95px; font-size:12px; color:#15bccf; display:block;} +.homepageNewsType {width:95px; font-size:12px; color:#888888; display:block;} +.homepageNewsContent {width:445px; font-size:12px; color:#4b4b4b; display:block;} +.homepageNewsTime {width:75px; font-size:12px; color:#888888; display:block; text-align:right;} +a.homepageWhite {color:#ffffff;} +a.homepageWhite:hover {color:#a1ebff} +a.newsGrey {color:#4b4b4b;} +a.newsGrey:hover {color:#000000;} +a.newsBlue {color:#15bccf;} +a.newsBlue:hover {color:#0781b4;} \ No newline at end of file diff --git a/spec/models/course_message_spec.rb b/spec/models/course_message_spec.rb new file mode 100644 index 000000000..cddcdc0a1 --- /dev/null +++ b/spec/models/course_message_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe CourseMessage, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 6051d0797d4018af815c3d45b31a681641451a89 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 16:24:43 +0800 Subject: [PATCH 39/51] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E4=B8=8D=E6=AD=A3=E7=A1=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/courses_controller.rb | 67 ++------------------------- app/views/courses/search.html.erb | 12 ++--- 2 files changed, 11 insertions(+), 68 deletions(-) diff --git a/app/controllers/courses_controller.rb b/app/controllers/courses_controller.rb index 71715035e..29f2e00f4 100644 --- a/app/controllers/courses_controller.rb +++ b/app/controllers/courses_controller.rb @@ -106,74 +106,17 @@ class CoursesController < ApplicationController # 课程搜索 # add by nwb def search - courses_all = Course.all_course - name = params[:name] - if name.blank? - @courses = [] - @courses_all = [] - @course_count = 0 - @course_pages = Paginator.new @course_count, per_page_option, params['page'] + if params[:name].empty? + courses = Course.visible + @courses = paginateHelper courses,10 else - @courses = courses_all.visible - if params[:name].present? - @courses_all = @courses.like(params[:name]) - else - @courses_all = @courses; - end - @course_count = @courses_all.count - @course_pages = Paginator.new @course_count, per_page_option, params['page'] - - # 课程的动态数 - # @course_activity_count=Hash.new - # @courses_all.each do |course| - # @course_activity_count[course.id]=0 - # end - # - # case params[:course_sort_type] - # when '0' - # @courses = @courses_all.order("created_at desc") - # @s_type = 0 - # @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) - # - # @course_activity_count=get_course_activity @courses,@course_activity_count - # - # when '1' - # @courses = @courses_all.order("course_ac_para desc") - # @s_type = 1 - # @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) - # - # @course_activity_count=get_course_activity @courses,@course_activity_count - # - # when '2' - # @courses = @courses_all.order("watchers_count desc") - # @s_type = 2 - # @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) - # - # @course_activity_count=get_course_activity @courses,@course_activity_count - # - # when '3' - # @course_activity_count=get_course_activity @courses_all,@course_activity_count_array - # @courses=handle_course @courses_all,@course_activity_count - # @s_type = 3 - # @courses = @courses[@course_pages.offset, @course_pages.per_page] - # - # else - # @s_type = 0 - # @courses = @courses_all.order("created_at desc") - # @courses = @courses.offset(@course_pages.offset).limit(@course_pages.per_page) - # - # @course_activity_count=get_course_activity @courses,@course_activity_count - # - # end + courses = Course.visible.where("LOWER(name) like '%#{params[:name].to_s.downcase}%'") + @courses = paginateHelper courses,10 end respond_to do |format| format.html { render :layout => 'course_base' - scope = Course - unless params[:closed] - scope = scope.active - end } format.atom { courses = Course.visible.order('created_on DESC').limit(Setting.feeds_limit.to_i).all diff --git a/app/views/courses/search.html.erb b/app/views/courses/search.html.erb index 98b056487..c19f9821a 100644 --- a/app/views/courses/search.html.erb +++ b/app/views/courses/search.html.erb @@ -39,17 +39,17 @@ <% end %>
      -<% if @courses.size == 0 %> -<%= render :partial => 'layouts/no_content'%> +<% if @courses && !@courses.empty? %> +
      + <%= render_course_hierarchy(@courses)%> +
      <% else %> -
      - <%= render_course_hierarchy(@courses)%> -
      + <%= render :partial => 'layouts/no_content'%> <% end %> From 17fad1f2918c2e35f9f6cc99fdcb0761fde23b79 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 14 Aug 2015 17:05:27 +0800 Subject: [PATCH 40/51] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=EF=BC=88=E6=89=80?= =?UTF-8?q?=E6=9C=89=E6=B6=88=E6=81=AF=EF=BC=89--=E5=8F=91=E5=B8=83?= =?UTF-8?q?=E4=BD=9C=E4=B8=9A=E3=80=81=E6=96=B0=E9=97=BB=E3=80=81=E9=97=AE?= =?UTF-8?q?=E5=8D=B7=E7=95=8C=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 11 +-- app/models/user.rb | 1 + app/views/users/user_messages.html.erb | 117 ++++++++++--------------- 3 files changed, 54 insertions(+), 75 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 1579a23c4..bee68c419 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -98,11 +98,12 @@ class UsersController < ApplicationController # 用户消息 def user_messages - @user_messges = @user.forge_messages - respond_to do |format| - format.html{render :layout=>'base_users_new'} - format.api - end + @user_course_messages = @user.course_messages + @user_project_messges = @user.forge_messages + respond_to do |format| + format.html{render :layout=>'base_users_new'} + format.api + end end def user_projects_index diff --git a/app/models/user.rb b/app/models/user.rb index 3cd248c8a..bb9a6d0a1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -129,6 +129,7 @@ class User < Principal has_many :documents # 项目中关联的文档再次与人关联 # 关联虚拟表 has_many :forge_messages + has_many :course_messages # end # 虚拟转换 diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index e7fcb790a..1891a5a99 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -1,75 +1,52 @@
      -
      -
      - +
      +
      + - -
      - - - - - - - - +
      + <% @user_course_messages.each do |ucm| %> + <% if ucm.course_message_type == "News" %> + + <% end %> + <% if ucm.course_message_type == "HomeworkCommon" %> + + <% end %> + <% if ucm.course_message_type == "Poll" %> + + <% end %> + <% end %> +
      -
      From 9b424a5b17dcc285c6c0d8b25f1384a411d20d4d Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Fri, 14 Aug 2015 17:25:53 +0800 Subject: [PATCH 41/51] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E8=B0=83=E6=9F=A5----=E7=82=B9=E5=87=BB=E9=97=AE=E5=8D=B7?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=B8=AD=E5=A6=82=E5=9B=BE=E7=A9=BA=E7=99=BD?= =?UTF-8?q?=E5=A4=84=E4=B9=9F=E8=BF=94=E5=9B=9E=E7=9B=B8=E5=85=B3=E9=97=AE?= =?UTF-8?q?=E5=8D=B7=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/poll/_poll.html.erb | 12 +++++++----- public/stylesheets/polls.css | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/app/views/poll/_poll.html.erb b/app/views/poll/_poll.html.erb index b4d944220..1828ede6d 100644 --- a/app/views/poll/_poll.html.erb +++ b/app/views/poll/_poll.html.erb @@ -2,11 +2,13 @@ <% poll_name = poll.polls_name.empty? ? l(:label_poll_new) : poll.polls_name%> <% if @is_teacher%>
    • - <% if has_commit %> - <%= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_w fl c_dblue"%> - <% else %> - <%= link_to poll_name, poll_path(poll.id), :class => "polls_title polls_title_w fl c_dblue" %> - <% end %> +
      + <% if has_commit %> + <%= link_to poll_name, poll_result_poll_path(poll.id), :class => "polls_title polls_title_w fl c_dblue"%> + <% else %> + <%= link_to poll_name, poll_path(poll.id), :class => "polls_title polls_title_w fl c_dblue" %> + <% end %> +
    • <% if poll.polls_status == 1%> diff --git a/public/stylesheets/polls.css b/public/stylesheets/polls.css index 97faa0f57..9f7b2d021 100644 --- a/public/stylesheets/polls.css +++ b/public/stylesheets/polls.css @@ -130,7 +130,7 @@ a:hover.btn_de{ background:#ff5d31;} a.btn_pu{ border:1px solid #3cb761; color:#3cb761; } a:hover.btn_pu{ background:#3cb761;} .pollsbtn_grey{ border:1px solid #b1b1b1; color:#b1b1b1; padding:0px 9px; height:19px; padding-top:3px; } -.polls_title_w { width:280px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;} +.polls_title_w { max-width:280px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;} .polls_title_st { max-width:530px; overflow: hidden;white-space: nowrap;text-overflow: ellipsis;} .polls_de_grey{ color:#b1b1b1; margin-top:3px;} .ml5{ margin-left:5px;} From 4013ff486a5d59f39a66055c4fad87df5b160b89 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 14 Aug 2015 17:35:10 +0800 Subject: [PATCH 42/51] =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/message.rb | 5 ++++- app/views/users/user_messages.html.erb | 16 +++++++++++----- public/stylesheets/public_new.css | 3 ++- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/app/models/message.rb b/app/models/message.rb index de5cc3f9b..eb86d47d6 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -35,6 +35,9 @@ class Message < ActiveRecord::Base # 课程动态 has_many :course_acts, :class_name => 'CourseActivity',:as =>:course_act ,:dependent => :destroy # end + # 课程消息 + has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy + #end has_many :ActivityNotifies,:as => :activity, :dependent => :destroy @@ -70,7 +73,7 @@ class Message < ActiveRecord::Base after_update :update_messages_board after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets - after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :send_mail + after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_course_message, :send_mail #before_save :be_user_score scope :visible, lambda {|*args| diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 1891a5a99..84aace520 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -22,29 +22,35 @@
      <% @user_course_messages.each do |ucm| %> <% if ucm.course_message_type == "News" %> -
      diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index 31657eae1..5a4a4c195 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -586,9 +586,10 @@ a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;} .newsType {width:60px; background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:35px; padding:5px 10px; left:-40px; font-size:12px; color:#888888; display:none; line-height:2;} .homepageRightBlock {} .homepageNewsList {width:710px; height:39px; line-height:39px; vertical-align:middle; border-bottom:1px dashed #eaeaea; margin:0 auto;} +.homepageNewsPortrait {width:40px; display:block; margin-top:7px;} .homepageNewsPublisher {width:95px; font-size:12px; color:#15bccf; display:block;} .homepageNewsType {width:95px; font-size:12px; color:#888888; display:block;} -.homepageNewsContent {width:445px; font-size:12px; color:#4b4b4b; display:block;} +.homepageNewsContent {width:405px; font-size:12px; color:#4b4b4b; display:block;} .homepageNewsTime {width:75px; font-size:12px; color:#888888; display:block; text-align:right;} a.homepageWhite {color:#ffffff;} a.homepageWhite:hover {color:#a1ebff} From 2cb5292dc133766aa7ad87a7245df7f271a531fa Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 15 Aug 2015 00:08:05 +0800 Subject: [PATCH 43/51] =?UTF-8?q?=E5=AE=8C=E6=88=90=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E6=B6=88=E6=81=AF=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/message.rb | 48 ++++++++++++++++++++++++++ app/views/users/user_messages.html.erb | 9 +++++ 2 files changed, 57 insertions(+) diff --git a/app/models/message.rb b/app/models/message.rb index eb86d47d6..aa62cd625 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -197,6 +197,54 @@ class Message < ActiveRecord::Base self.course_acts << CourseActivity.new(:user_id => self.author_id,:course_id => self.board.course_id) end end + + # 课程讨论区添加消息 + # 老师发帖所有人都能收到消息 + # 学生发帖,有人回复则给该学生消息,没回复则不给其它人发送消息 + # 帖子被回复的可以收到消息通知 + def act_as_course_message + if self.course + if self.parent_id.nil? #主贴 + self.course.members.each do |m| + if self.author.allowed_to?(:as_teacher, self.course) # 老师 + if m.user_id != self.author_id # 自己的帖子不给自己发送消息 + self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) + end + end + end + else # 回帖 + #if self.author.allowed_to?(:as_teacher, self.course) # 老师 + self.course.members.each do |m| + if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 + self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) + end + end + #end + end + end + # if self.author.allowed_to?(:as_teacher, self.course) # 如果发帖人是老师 + # self.course.members.each do |m| + # if self.parent_id.nil? # 主贴 + # if m.user_id != self.author_id # 自己的帖子不给自己发送消息 + # self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) + # end + # else # 回帖只针对主贴发送消息 + # if m.user_id == Message.find(self.parent_id).author_id + # self.course_messages << CourseMessage.new(:user_id => self.parent_id, :course_id => self.board.course_id, :viewed => false) + # end + # end + # end + # else # 学生只针对主贴回复 + # unless self.parent_id.nil? + # self.course.members.each do |m| + # if m.user_id == Message.find(self.parent_id).author_id && m.user_id != self.author_id # 只针对主贴回复,回复自己的帖子不发消息 + # self.course_messages << CourseMessage.new(:user_id => m.user_id, :course_id => self.board.course_id, :viewed => false) + # end + # end + # end + # end + #end + end #更新用户分数 -by zjc def be_user_score diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 84aace520..204ed2c08 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -50,6 +50,15 @@
    • <%= time_tag(ucm.course_message.created_at).html_safe %>
    <% end %> + <% if ucm.course_message_type == "Message" %> + + <% end %>
    <% end %> From ed8c4ac906f864b3c5fd1118954be0dc4f229da4 Mon Sep 17 00:00:00 2001 From: huang Date: Sat, 15 Aug 2015 02:11:18 +0800 Subject: [PATCH 44/51] =?UTF-8?q?=E4=B8=8D=E5=90=8C=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E5=8F=91=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 26 +++++++++++--- app/models/user.rb | 20 +++++++++++ app/views/users/user_messages.html.erb | 40 ++++++++++++++-------- public/stylesheets/public_new.css | 47 +++++++++++++++++++++++++- 4 files changed, 113 insertions(+), 20 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index bee68c419..c6dfb9b54 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -98,12 +98,28 @@ class UsersController < ApplicationController # 用户消息 def user_messages - @user_course_messages = @user.course_messages - @user_project_messges = @user.forge_messages - respond_to do |format| - format.html{render :layout=>'base_users_new'} - format.api + if @user.course_messages + if params[:type].nil? + @user_course_messages = @user.course_messages + @user_project_messges = @user.forge_messages + else + case params[:type] + when 'homework' + @user_course_messages = @user.course_messages + #@user_course_messages = ForgeMessage.find_by_sql("select * from course_messages where user_id='#{@user.id}' and course_message_type = 'HomeworkCommon' order by created_at desc;") + when 'message' + @user_course_messages = @user.course_message_message + when 'news' + @user_course_messages = @user.course_message_new + when 'poll' + @user_course_messages = @user.course_message_poll end + end + respond_to do |format| + format.html{render :layout=>'base_users_new'} + format.api + end + end end def user_projects_index diff --git a/app/models/user.rb b/app/models/user.rb index bb9a6d0a1..4bc249673 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -134,6 +134,10 @@ class User < Principal # 虚拟转换 has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" + has_many :course_messages_homeworks, :class_name => 'ForgeMessage', :conditions => 'forge_message_type="HomeworkCommon"' + has_many :course_messages_polls, :class_name => 'ForgeMessage', :conditions => 'forge_message_type="Poll"' + has_many :course_messages_messages, :class_name => 'ForgeMessage', :conditions => 'forge_message_type="Message"' + has_many :course_messages_news, :class_name => 'ForgeMessage', :conditions => 'forge_message_type="News"' has_many :issue_assigns, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Issue"' has_many :status_updates, :class_name => 'ForgeMessage', :conditions => 'viewed=0 and forge_message_type="Journal"' # 邮件邀请状态 @@ -248,6 +252,22 @@ class User < Principal # count = self.journals_for_messages(:conditions => ["status=? and is_readed = ? " ,1, 0]).count end + def course_message_homework user + user.course_messages_homeworks + end + + def course_message_poll + self.course_messages_polls + end + + def course_message_new + self.course_messages_news + end + + def course_message_message + self.course_messages_messages + end + # 查询指派给我的缺陷记录 def count_new_issue_assign_to self.issue_assigns diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index 204ed2c08..687a694bb 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -6,20 +6,20 @@
    + <% if !@user_course_messages.nil? %> <% @user_course_messages.each do |ucm| %> <% if ucm.course_message_type == "News" %> <% end %> @@ -37,7 +37,7 @@
  • <%= ucm.course_message.user %>
  • 发布作业
  • - <%= link_to format_activity_title("#{ucm.course_message.name}"), {:controller => 'news', :action => 'show', :id => ucm.course_message.id} %>
  • + <%= link_to ("#{ucm.course_message.name}"), student_work_index_path(:homework => ucm.course_message.id) %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -46,7 +46,8 @@
  • <%= ucm.course_message.user %>
  • 发布问卷
  • -
  • <%= ucm.course_message.polls_name %>
  • +
  • + <%= link_to format_activity_title(" #{ucm.course_message.polls_name}"), poll_index_path(:polls_type => "Course", :polls_group_id => ucm.course_id) %>
  • <%= time_tag(ucm.course_message.created_at).html_safe %>
  • <% end %> @@ -54,13 +55,24 @@ <% end %>
    <% end %> + <% else %> +
    你没有新消息!
    + <% end %>
    diff --git a/public/stylesheets/public_new.css b/public/stylesheets/public_new.css index 5a4a4c195..a14aa6759 100644 --- a/public/stylesheets/public_new.css +++ b/public/stylesheets/public_new.css @@ -596,4 +596,49 @@ a.homepageWhite:hover {color:#a1ebff} a.newsGrey {color:#4b4b4b;} a.newsGrey:hover {color:#000000;} a.newsBlue {color:#15bccf;} -a.newsBlue:hover {color:#0781b4;} \ No newline at end of file +a.newsBlue:hover {color:#0781b4;} + +/***** Flash & error messages ****/ +#errorExplanation, div.flash, .nodata, .warning, .conflict { + padding: 4px 4px 4px 30px; + margin-bottom: 12px; + font-size: 1.1em; + border: 2px solid; +} + +div.flash {margin-top: 8px;} + +div.flash.error, #errorExplanation { + background: url(../images/exclamation.png) 8px 50% no-repeat; + background-color: #ffe3e3; + border-color: #dd0000; + color: #880000; +} + +div.flash.notice { + background: url(../images/true.png) 8px 5px no-repeat; + background-color: #dfffdf; + border-color: #9fcf9f; + color: #005f00; +} + +div.flash.warning, .conflict { + background: url(../images/warning.png) 8px 5px no-repeat; + background-color: #FFEBC1; + border-color: #FDBF3B; + color: #A6750C; + text-align: left; +} + +.nodata, .warning { + text-align: center; + background-color: #FFEBC1; + border-color: #FDBF3B; + color: #A6750C; +} + +#errorExplanation ul { font-size: 0.9em;} +#errorExplanation h2, #errorExplanation p { display: none; } + +.conflict-details {font-size:80%;} +/***** end Flash & error messages ****/ \ No newline at end of file From ac4d529ebc5ab9eb0b1039514948dd72cd144251 Mon Sep 17 00:00:00 2001 From: sw <939547590@qq.com> Date: Sat, 15 Aug 2015 10:45:56 +0800 Subject: [PATCH 45/51] =?UTF-8?q?=E7=BC=96=E7=A8=8B=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E5=8F=96=E6=B6=88=EF=BC=8C=E5=B9=B6=E8=AE=BE=E5=AE=9A=E5=8C=BF?= =?UTF-8?q?=E8=AF=84=E4=B8=BA=E5=86=85=E7=BD=AE=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/homework_common_controller.rb | 44 +++++++-------- app/views/boards/_form.html.erb | 2 +- app/views/boards/show.html.erb | 55 ++----------------- .../_homework_detail_manual_form.html.erb | 2 +- app/views/homework_common/new.html.erb | 28 +++------- config/locales/my/zh.yml | 1 - config/locales/projects/zh.yml | 1 - 7 files changed, 37 insertions(+), 96 deletions(-) diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index 21f781a1a..87c1e288b 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -19,28 +19,28 @@ class HomeworkCommonController < ApplicationController end def new - # @homework_type = "1" - # - # @homework = HomeworkCommon.new - # @homework.safe_attributes = params[:homework_common] - # @homework.late_penalty = 2 - # @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') - # @homework.publish_time = Time.now.strftime('%Y-%m-%d') - # - # if @homework_type == "1" - # #匿评作业相关属性 - # @homework_detail_manual = HomeworkDetailManual.new - # @homework_detail_manual.ta_proportion = 0.6 - # @homework_detail_manual.absence_penalty = 2 - # @homework_detail_manual.evaluation_num = 3 - # @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d') - # @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d') - # @homework.homework_detail_manual = @homework_detail_manual - # elsif @homework_type == "2" - # #编程作业相关属性 - # @homework_detail_programing = HomeworkDetailPrograming.new - # @homework.homework_detail_programing = @homework_detail_programing - # end + @homework_type = "1" + + @homework = HomeworkCommon.new + @homework.safe_attributes = params[:homework_common] + @homework.late_penalty = 2 + @homework.end_time = (Time.now + 3600 * 24).strftime('%Y-%m-%d') + @homework.publish_time = Time.now.strftime('%Y-%m-%d') + + if @homework_type == "1" + #匿评作业相关属性 + @homework_detail_manual = HomeworkDetailManual.new + @homework_detail_manual.ta_proportion = 0.6 + @homework_detail_manual.absence_penalty = 2 + @homework_detail_manual.evaluation_num = 3 + @homework_detail_manual.evaluation_start = Time.now.strftime('%Y-%m-%d') + @homework_detail_manual.evaluation_end = (Time.now + 3600 * 24).strftime('%Y-%m-%d') + @homework.homework_detail_manual = @homework_detail_manual + elsif @homework_type == "2" + #编程作业相关属性 + @homework_detail_programing = HomeworkDetailPrograming.new + @homework.homework_detail_programing = @homework_detail_programing + end respond_to do |format| format.html end diff --git a/app/views/boards/_form.html.erb b/app/views/boards/_form.html.erb index 47ae0672d..a4f58dcc3 100644 --- a/app/views/boards/_form.html.erb +++ b/app/views/boards/_form.html.erb @@ -1,7 +1,7 @@ <%= error_messages_for @board %>
    -

    +

    <%= f.text_field :name, :required => true %>

    diff --git a/app/views/boards/show.html.erb b/app/views/boards/show.html.erb index 5520f526d..609294161 100644 --- a/app/views/boards/show.html.erb +++ b/app/views/boards/show.html.erb @@ -1,12 +1,5 @@