资源引用消息通知
This commit is contained in:
parent
f3f75a57bd
commit
99cbf0b54e
|
@ -315,20 +315,18 @@ class UsersController < ApplicationController
|
|||
# status
|
||||
def deal_with_apply_resource
|
||||
@msg = CourseMessage.find(params[:msg_id])
|
||||
ah = ApplyHomework.where("user_id = ? and homework_common_id = ?",@msg.apply_user_id, @msg.course_message_id)
|
||||
case params[:agree]
|
||||
when 'Y'
|
||||
unless ah.empty?
|
||||
ah.first.update_column('status', 2)
|
||||
CourseMessage.create(:user_id => @msg.apply_user_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>@msg.course_message_id,:content=>@msg.content,:course_message_type=>'HomeworkCommon',:status=>6,:apply_result=>1)
|
||||
@msg.update_attributes(:apply_result=>1,:viewed=>1)
|
||||
end
|
||||
when 'N'
|
||||
unless ah.empty?
|
||||
ah.first.update_column('status', 3)
|
||||
CourseMessage.create(:user_id => @msg.apply_user_id, :course_id => @msg.course_id, :viewed => false,:content=> @msg.content,:course_message_id=>@msg.course_message_id,:content=>@msg.content,:course_message_type=>'HomeworkCommon',:status=>6,:apply_result=>2)
|
||||
@msg.update_attributes(:apply_result=>2,:viewed=>1)
|
||||
end
|
||||
ar = ApplyResource.where("id = ?", @msg.course_message_id).first
|
||||
unless ar.nil?
|
||||
case params[:agree]
|
||||
when 'Y'
|
||||
ar.update_column('status', 2)
|
||||
@msg.update_attributes(:apply_result => 1, :viewed => 1)
|
||||
ar.course_messages << CourseMessage.new(:user_id => ar.user_id, :course_id => -1, :viewed => false, :apply_result => 2, :status => 1)
|
||||
when 'N'
|
||||
ar.update_column('status', 3)
|
||||
@msg.update_attributes(:apply_result => 2, :viewed => 1)
|
||||
ar.course_messages << CourseMessage.new(:user_id => ar.user_id, :course_id => -1, :viewed => false, :apply_result => 3, :status => 1)
|
||||
end
|
||||
end
|
||||
respond_to do |format|
|
||||
format.js
|
||||
|
|
|
@ -7,9 +7,13 @@ class ApplyResource < ActiveRecord::Base
|
|||
after_create :act_as_apply_resource_message
|
||||
|
||||
def act_as_apply_resource_message
|
||||
self.course_messages << CourseMessage.new(:user_id => self.apply_user_id, :course_id => self.container_id, :viewed => false, :status => 5)
|
||||
self.course_messages << CourseMessage.new(:user_id => self.apply_user_id, :course_id => -1, :viewed => false, :status => 0, )
|
||||
# REDO:发送邮件
|
||||
# Mailer.run.apply_for_resource_request(self.container_id, User.current)
|
||||
end
|
||||
|
||||
def find_attachment attachment_id
|
||||
Attachment.find(attachment_id)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
class CourseMessage < ActiveRecord::Base
|
||||
# status说明: status在课程不同的类型,区分不同的功能 status = 9 作品的提交记录
|
||||
# ApplyResource status:
|
||||
# 0: 发送申请 1:回复允许申请 2:拒绝申请消息
|
||||
# HomeworkCommon:status:
|
||||
# nil:发布了作业; 1:作业截止时间到了提醒!;2:开启匿评; 3:关闭匿评; 4:匿评开始失败; 5:申请引用作业, 6:申请结果
|
||||
# apply_user_id: 申请者的用户id
|
||||
|
|
|
@ -9,16 +9,16 @@
|
|||
</li>
|
||||
<li class="<%=(ma.apply_result == 0 || ma.apply_result.nil?) ? 'homepageHomeworkContent2' : 'homepageHomeworkContent' %> fl">
|
||||
<% content = ma.course_message.content.nil? ? '' : ':'+ ma.course_message.content.to_s %>
|
||||
<a title="<%= ma.course_message.user.show_name + "申请引用资源\""+"#{ma.course_message.attachment.try(:name)}"+"\"#{content}" %>" class = "<%= ma.viewed == 0 ? "newsBlack" : "newsGrey "%>">
|
||||
<%= ma.course_message.user.show_name + "申请引用资源\""+"#{ma.course_message.attachment.try(:name)}"+"\"#{content}" %>
|
||||
<a title="<%= ma.course_message.user.show_name + "申请引用资源\""+"#{ma.course_message.user.try(:name)}"+"\"#{content}" %>" class = "<%= ma.viewed == 0 ? "newsBlack" : "newsGrey "%>">
|
||||
<%= ma.course_message.user.show_name + "申请引用资源\""+"#{ma.course_message.user.try(:name)}"+"\"#{content}" %>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="<%=(ma.apply_result == 0 || ma.apply_result.nil?) ? 'homepageHomeworkContentWarn2' : 'homepageHomeworkContentWarn' %> fl">
|
||||
<span id="deal_info_<%=ma.id%>">
|
||||
<% if ma.apply_result == 0 || ma.apply_result.nil?%>
|
||||
<%= link_to '同意', dealwith_apply_homework_user_path(User.current,:agree => 'Y', :msg_id => ma.id), :remote => 'true' %> |
|
||||
<%= link_to '拒绝', dealwith_apply_homework_user_path(User.current, :agree => 'N', :msg_id => ma.id), :remote => 'true' %>
|
||||
<span id="deal_info_<%= ma.id %>">
|
||||
<% if ma.apply_result == 0 || ma.apply_result.nil? %>
|
||||
<%= link_to '同意', deal_with_apply_resource_user_path(User.current, :agree => 'Y', :msg_id => ma.id, :apply_user_id => ma.course_message.apply_user_id), :remote => 'true' %> |
|
||||
<%= link_to '拒绝', deal_with_apply_resource_user_path(User.current, :agree => 'N', :msg_id => ma.id, :apply_user_id => ma.course_message.apply_user_id), :remote => 'true' %>
|
||||
<% elsif ma.apply_result == 1 %>
|
||||
您已经同意了该申请
|
||||
<% elsif ma.apply_result == 2 %>
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl">
|
||||
<% owner = User.find(ma.course_message.apply_user_id) %>
|
||||
<div class="navHomepageLogo fl">
|
||||
<%= link_to image_tag(url_to_avatar(owner), :width => "30", :height => "30", class: "mt3"), user_path(owner) %>
|
||||
</div>
|
||||
</li>
|
||||
<li class="homepageNewsPubType fl">
|
||||
<%= link_to owner.show_name, user_path(owner), :class => "newsBlue homepageNewsPublisher" %>
|
||||
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>"><%= ma.apply_result == 1 ? '同意' : '拒绝'%>引用资源:</span>
|
||||
</li>
|
||||
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
|
||||
<% link_str = ma.apply_result == 1 ?
|
||||
'您申请引用资源"'+ ma.course_message.find_attachment(ma.course_message.apply_user_id).try(:filename) + '"的申请已通过'
|
||||
:
|
||||
'您申请引用资源"'+ ma.course_message.find_attachment(ma.course_message.apply_user_id).try(:filename) + '"的申请被婉拒' %>
|
||||
<%= link_to link_str, user_resource_user_path(User.current, :type => 2), :title => link_str,:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey "}" %>
|
||||
</a>
|
||||
</li>
|
||||
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
|
||||
</ul>
|
|
@ -235,11 +235,17 @@
|
|||
</ul>
|
||||
<% end %>
|
||||
<!--资源申请-->
|
||||
<% if ma.course_message_type == "ApplyResource" %>
|
||||
<ul class="homepageNewsList fl" id="course_message_homework_<%=ma.id %>">
|
||||
<% if ma.course_message_type == "ApplyResource" && ma.status == 0 %>
|
||||
<ul class="homepageNewsList fl" id="apply_resource_message_<%=ma.id %>">
|
||||
<%= render :partial => 'apply_resource_course_message', :locals => {:ma => ma} %>
|
||||
</ul>
|
||||
<% end %>
|
||||
<!--资源申请回复-->
|
||||
<% if ma.course_message_type == "ApplyResource" && ma.status == 1 %>
|
||||
<ul class="homepageNewsList fl" id="apply_resource_message_<%=ma.id %>">
|
||||
<%= render :partial => 'apply_resource_course_message_reply', :locals => {:ma => ma} %>
|
||||
</ul>
|
||||
<% end %>
|
||||
<% if ma.course_message_type == "HomeworkCommon" && ma.status == 6 %>
|
||||
<ul class="homepageNewsList fl">
|
||||
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><div class="navHomepageLogo fl"><%= image_tag(url_to_avatar(User.find(ma.apply_user_id)), width: "30px", height: "30px", class: "mt3") %></div></a></li>
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
$("#apply_resource_message_<%= @msg.id %>").html('<%= escape_javascript(render :partial => 'users/apply_resource_course_message', :locals => {:ma => @msg}) %>');
|
|
@ -56,7 +56,7 @@
|
|||
<a href="<%= user_resource_user_path(@user, :type => '1', :status => 6) %>" class="resource-tab" id="my_resource_list" data-remote="true">我的资源</a>
|
||||
</li>
|
||||
<li class="fl resource-switch">
|
||||
<a href="<%= user_resource_user_path(@user, :type => '1', :status => 6) %>" class="resource-tab" id="private_resource_list" data-remote="true">私有资源</a>
|
||||
<a href="<%= user_resource_user_path(@user, :type => '2', :status => 6) %>" class="resource-tab" id="private_resource_list" data-remote="true">私有资源</a>
|
||||
</li>
|
||||
<li class="fl w680 border-bottom h34"> </li>
|
||||
<li class="fr resource-banner-li border-bottom h34">
|
||||
|
|
|
@ -623,6 +623,7 @@ RedmineApp::Application.routes.draw do
|
|||
post 'import_resources_to_homework'
|
||||
get 'dealwith_apply_request'
|
||||
get 'dealwith_apply_homework'
|
||||
get 'deal_with_apply_resource'
|
||||
get 'store_selected_resource'
|
||||
get 'user_organizations'
|
||||
get 'search_user_orgs'
|
||||
|
|
Loading…
Reference in New Issue