notificationcomments
This commit is contained in:
parent
45e12c4bef
commit
c3865ab319
|
@ -8,14 +8,14 @@ class NotificationcommentsController < ApplicationController
|
||||||
@contest = Contest.find(params[:contest_id])
|
@contest = Contest.find(params[:contest_id])
|
||||||
@contestnotification = Contestnotification.find(params[:contestnotification_id])
|
@contestnotification = Contestnotification.find(params[:contestnotification_id])
|
||||||
|
|
||||||
@notificaioncomment = Notificationcomment.new
|
# @notificaioncomment = Notificationcomment.new
|
||||||
@notificaioncomment.safe_attributes = params[:notificaioncomment]
|
# @notificaioncomment.safe_attributes = params[:notificationcomment]
|
||||||
@notificaioncomment.author = User.current
|
# @notificaioncomment.author = User.current
|
||||||
if @contestnotification.notificationcomments << @notificaioncomment
|
comment = @contestnotification.notificationcomments.new(params[:notificationcomment].merge(author_id: User.current.id))
|
||||||
|
if comment.save
|
||||||
flash[:notice] = l(:label_comment_added)
|
flash[:notice] = l(:label_comment_added)
|
||||||
end
|
end
|
||||||
|
|
||||||
#redirect_to contest_contestnotification_notificationcomment_path(@contest, @contestnotification, @notificaioncomment)
|
|
||||||
redirect_to contest_contestnotification_path(@contest, @contestnotification)
|
redirect_to contest_contestnotification_path(@contest, @contestnotification)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ class Contestnotification < ActiveRecord::Base
|
||||||
#Contestnotification::Notificationcomment
|
#Contestnotification::Notificationcomment
|
||||||
belongs_to :contest
|
belongs_to :contest
|
||||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||||
has_many :notificationcomments, :dependent => :delete_all, :order => "created_at"
|
has_many :notificationcomments, as: :notificationcommented, :dependent => :delete_all, :order => "created_at"
|
||||||
# fq
|
# fq
|
||||||
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
has_many :acts, :class_name => 'Activity', :as => :act, :dependent => :destroy
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
<%= labelled_form_for @contestnotification, :url => contest_contestnotifications_path(@contest), :html => { :id => 'contestnotifications-form', :multipart => true } do |f| %>
|
<%= labelled_form_for @contestnotification, :url => contest_contestnotifications_path(@contest), :html => { :id => 'contestnotifications-form', :multipart => true } do |f| %>
|
||||||
<%= render :partial => 'contestnotifications/form', :locals => { :f => f } %>
|
<%= render :partial => 'contestnotifications/form', :locals => { :f => f } %>
|
||||||
<%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
|
<%= submit_tag l(:button_create), :class => "whiteButton m3p10 h30" %>
|
||||||
<%= preview_link preview_contestnotifications_path(:contest_id => @contest), 'contestnotifications-form' ,target='preview',{:class => 'whiteButton m3p10'}%>
|
<%= preview_link preview_contest_contestnotifications_path(:contest_id => @contest), 'contestnotifications-form' ,target='preview',{:class => 'whiteButton m3p10'}%>
|
||||||
<% end %>
|
<% end %>
|
||||||
<div id="preview" class="wiki"></div>
|
<div id="preview" class="wiki"></div>
|
||||||
|
|
|
@ -77,6 +77,7 @@ RedmineApp::Application.routes.draw do
|
||||||
## new added by linchun #新竞赛相关
|
## new added by linchun #新竞赛相关
|
||||||
resources :contests, only: [:index] do
|
resources :contests, only: [:index] do
|
||||||
resources :contestnotifications do
|
resources :contestnotifications do
|
||||||
|
get 'preview', on: :collection
|
||||||
resources :notificationcomments
|
resources :notificationcomments
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue