竞赛通知和班级通知不能回复

This commit is contained in:
cxt 2017-02-24 20:00:31 +08:00
parent ca706f3df5
commit 6d3ab4f651
6 changed files with 19 additions and 5 deletions

View File

@ -24,7 +24,7 @@ class CommentsController < ApplicationController
before_filter :authorize, :except => [:destroy]
def create
raise Unauthorized unless @news.commentable?
#raise Unauthorized unless @news.commentable?
if !@news.org_subfield_id.nil?
@org_subfield = OrgSubfield.find(@news.org_subfield_id)
end

View File

@ -103,6 +103,19 @@ class News < ActiveRecord::Base
user.allowed_to?(:comment_news, project)
end
def news_object
object = self.project
if object == nil && self.has_attribute?('course_id')
object = self.course
if object.nil? && self.has_attribute?('contest_id')
object = self.contest
elsif object.nil? && self.has_attribute?('org_subfield_id')
object = self.org_subfield
end
end
object
end
def recipients
project.users.select {|user| user.notify_about?(self)}.map(&:mail)
end

View File

@ -8,7 +8,7 @@ class CommentService
if @course.nil?
raise 'news in unknown course'
end
raise Unauthorized unless @news.commentable?(current_user)
#raise Unauthorized unless @news.commentable?(current_user)
if current_user.nil? || !(current_user.admin? || @course.is_public == 1 || (@course.is_public == 0 && current_user.member_of_course?(@course)))
raise '403'
end

View File

@ -13,7 +13,7 @@
<% end %>
<div class="cl"></div>
<% if @news.commentable? %>
<% if User.current.admin? || ((object.kind_of? Contest) && User.current.member_of_contest?(object)) || ((object.kind_of? Course) && User.current.member_of_course?(object)) || ((object.kind_of? OrgSubfield) && User.current.member_of_org?(object.organization)) %>
<div class="talkWrapMsg" nhname="about_talk_reply">
<em class="talkWrapArrow"></em>
<div class="cl"></div>

View File

@ -41,7 +41,7 @@
:class => 'fr mr20 undis',
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete)
) if ((object.kind_of? Organization) ? (User.current.admin_of_org?(object) || User.current == comment.author) : (User.current.allowed_to?(:manage_news, object) || User.current == comment.author || User.current.admin_of_contest?(object))) %>
) if ((object.kind_of? OrgSubfield) ? (User.current.admin_of_org?(object.organization) || User.current == comment.author) : (User.current.allowed_to?(:manage_news, object) || User.current == comment.author || User.current.admin_of_contest?(object))) %>
</span>
<div class="cl"></div>
</div>

View File

@ -8,7 +8,8 @@
<%= render :partial => 'users/news_replies', :locals => {:comments => no_children_comments[:no_children_comments], :user_activity_id => user_activity_id, :type => 'News', :activity_id => activity.id} %>
</div>
<% end %>
<% if activity.commentable? %>
<% object = activity.news_object %>
<% if User.current.admin? || ((object.kind_of? Contest) && User.current.member_of_contest?(object)) || ((object.kind_of? Course) && User.current.member_of_course?(object)) || ((object.kind_of? OrgSubfield) && User.current.member_of_org?(object.organization)) %>
<div class="homepagePostReplyContainer borderBottomNone minHeight48">
<div class="homepagePostReplyPortrait mr15 imageFuzzy" id="reply_image_<%= user_activity_id%>"><%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(User.current), :alt => "用户头像" %></div>
<div class="homepagePostReplyInputContainer mb10">