增加竞赛删除评论的功能

This commit is contained in:
sw 2014-08-04 15:01:39 +08:00
parent 209c1aeaab
commit 9cb026ed39
4 changed files with 34 additions and 4 deletions

View File

@ -1,4 +1,7 @@
class NotificationcommentsController < ApplicationController
def show
end
# default_search_scope :contestnotifications
# model_object Contestnotifications
# before_filter :authorize
@ -20,8 +23,14 @@ class NotificationcommentsController < ApplicationController
end
def destroy
@contestnotifications.notificaioncomments.find(params[:notificaioncomment_id]).destroy
redirect_to contest_contestnotification_path(@contestnotifications)
@contest = Contest.find(params[:contest_id])
@contestnotification = Contestnotification.find(params[:contestnotification_id])
notificaioncomments = Notificationcomment.find(params[:id])
notificaioncomments.destroy if notificaioncomments
#@contestnotifications = notificaioncomments.Contestnotification
#@contest = @contestnotifications.contest
#@contestnotifications.notificaioncomments.find(params[:notificaioncomment_id]).destroy
redirect_to contest_contestnotification_path(@contest,@contestnotification)
end
end

View File

@ -4,6 +4,7 @@ class Notificationcomment < ActiveRecord::Base
include Redmine::SafeAttributes
belongs_to :notificationcommented, :polymorphic => true#, :counter_cache => true
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
belongs_to :Contestnotification
validates_presence_of :notificationcommented, :author, :notificationcomments

View File

@ -69,7 +69,21 @@
<td>
<table width="580px" border="0">
<tr>
<td colspan="2" valign="top"><strong><%= link_to_user(notificationcomment.author) if notificationcomment.respond_to?(:author) %> </strong><span class="font_lighter"><%= l(:label_project_newadd) %></span><%= l(:label_comment_plural) %></td>
<td colspan="2" valign="top">
<strong>
<%= link_to_user(notificationcomment.author) if notificationcomment.respond_to?(:author) %>
</strong>
<span class="font_lighter">
<%= l(:label_project_newadd) %>
</span>
<%= l(:label_comment_plural) %>
</td>
<td>
<% if notificationcomment.author==User.current|| User.current.admin? %>
<%= link_to(l(:label_bid_respond_delete), contest_contestnotification_notificationcomment_path(@contest, @contestnotification,notificationcomment),
:method => :delete,:confirm => l(:text_are_you_sure), :title => l(:button_delete)) %>
<% end %>
</td>
</tr>
<tr>
<td colspan="2" width="580px" >

View File

@ -83,6 +83,10 @@ RedmineApp::Application.routes.draw do
end
end
#resources :notificationcomments do
#
#end
#resources :contestnotifications, :only => [:index, :show, :edit, :update, :destroy]
# match '/contestnotifications/:id/notificationcomments', :to => 'notificationcomments#create', :via => :post
# match '/contestnotifications/:id/notificationcomments/:notificationcomment_id', :to => 'notificationcomments#destroy', :via => :delete
@ -91,7 +95,9 @@ RedmineApp::Application.routes.draw do
resources :contests, only: [:index] do
resources :contestnotifications do
# get 'preview', on: :collection
resources :notificationcomments
resources :notificationcomments do
end
end
collection do