From 4067a9c4a7867d91c3283850cce5fd236dd4a0e4 Mon Sep 17 00:00:00 2001 From: cxt Date: Sat, 24 Dec 2016 20:22:09 +0800 Subject: [PATCH] =?UTF-8?q?title=E4=BF=AE=E6=94=B9=E3=80=81=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E7=9A=84=E7=BC=96=E8=BE=91=E5=88=A0=E9=99=A4=E3=80=81?= =?UTF-8?q?=E9=99=84=E4=BB=B6=E4=B8=8B=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/comments_controller.rb | 2 +- app/controllers/users_controller.rb | 1 + app/helpers/application_helper.rb | 10 ++++++++++ app/views/news/_news_replies_detail.html.erb | 2 +- app/views/users/_news_replies.html.erb | 2 +- 5 files changed, 14 insertions(+), 3 deletions(-) diff --git a/app/controllers/comments_controller.rb b/app/controllers/comments_controller.rb index 193dbd407..99c9b9af7 100644 --- a/app/controllers/comments_controller.rb +++ b/app/controllers/comments_controller.rb @@ -21,7 +21,7 @@ class CommentsController < ApplicationController model_object News before_filter :find_model_object, :except => [:reply, :quote] before_filter :find_project_from_association, :except => [:reply, :quote] - before_filter :authorize + before_filter :authorize, :except => [:destroy] def create raise Unauthorized unless @news.commentable? diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 92b71b5b9..ad25b22a9 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -2246,6 +2246,7 @@ class UsersController < ApplicationController # 竞赛社区 def contest_community + @contest_community = "竞赛" shield_contest_ids = ShieldActivity.select("shield_id").where("container_type='User' and container_id=#{@user.id} and shield_type='Contest'").map(&:shield_id) @page = params[:page] ? params[:page].to_i + 1 : 0 user_contest_ids = (@user.favorite_contests.visible.where("is_delete = 0").map{|contest| contest.id}-shield_contest_ids).empty? ? "(-1)" : "(" + (@user.favorite_contests.visible.map{|contest| contest.id}-shield_contest_ids).join(",") + ")" diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5f40afdba..a2e69c846 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1317,6 +1317,8 @@ module ApplicationHelper title << @project.name elsif @course title << @course.name + elsif @contest + title << @contest.name elsif @organization title << @organization.name elsif @user @@ -1324,6 +1326,8 @@ module ApplicationHelper title << @project_community elsif !@course_community.blank? title << @course_community + elsif !@contest_community.blank? + title << @contest_community else title << @user.try(:realname) end @@ -2442,6 +2446,12 @@ module ApplicationHelper candown = true elsif attachment.container.class.to_s=="StudentWork" candown = true + elsif attachment.container.class.to_s=="Contest" + candown = true + elsif attachment.container.class.to_s=="Work" + candown = true + elsif attachment.container.class.to_s=="ContestantWork" + candown = true elsif attachment.container.class.to_s=="BlogComment" #博客资源允许下载 candown = true elsif attachment.container.class.to_s=="Memo" #论坛资源允许下载 diff --git a/app/views/news/_news_replies_detail.html.erb b/app/views/news/_news_replies_detail.html.erb index 0f4ede154..1507b366d 100644 --- a/app/views/news/_news_replies_detail.html.erb +++ b/app/views/news/_news_replies_detail.html.erb @@ -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.allowed_to?(:manage_news, object) : (User.current.admin_of_org?(object) || User.current == comment.author)) %> + ) 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))) %>
diff --git a/app/views/users/_news_replies.html.erb b/app/views/users/_news_replies.html.erb index aef4fb794..2491e6498 100644 --- a/app/views/users/_news_replies.html.erb +++ b/app/views/users/_news_replies.html.erb @@ -58,7 +58,7 @@ <% news = News.find(activity_id) %> <%= link_to('删除', {:controller => 'comments', :action => 'destroy', :id => activity_id, :comment_id => comment, :user_activity_id => user_activity_id}, - :id => "delete_reply_#{activity_id}_#{comment.id}",:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20 undis", :title => l(:button_delete)) if (User.current.allowed_to?(:manage_news, news.course) || User.current.allowed_to?(:manage_news, news.project)) %> + :id => "delete_reply_#{activity_id}_#{comment.id}",:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "fr mr20 undis", :title => l(:button_delete)) if (User.current.allowed_to?(:manage_news, news.course) || User.current.allowed_to?(:manage_news, news.project) || User.current == comment.author || User.current.admin_of_contest?(news.contest)) %> <% elsif type == 'Issue' %> <%= link_to(