parent
2e11d76652
commit
d06488c10d
@ -0,0 +1,3 @@
|
||||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
|
@ -0,0 +1,3 @@
|
||||
// Place all the styles related to the notificationcomments controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
@ -0,0 +1,35 @@
|
||||
class NotificationcommentsController < ApplicationController
|
||||
default_search_scope :contestnotifications
|
||||
model_object Contestnotifications
|
||||
before_filter :find_model_object
|
||||
before_filter :find_contest_from_association
|
||||
before_filter :authorize
|
||||
|
||||
def create
|
||||
raise Unauthorized unless @contestnotifications.commentable?
|
||||
|
||||
@notificaioncomment = Notificaioncomment.new
|
||||
@notificaioncomment.safe_attributes = params[:notificaioncomment]
|
||||
@notificaioncomment.author = User.current
|
||||
if @contestnotifications.notificaioncomments << @notificaioncomment
|
||||
flash[:notice] = l(:label_comment_added)
|
||||
end
|
||||
|
||||
redirect_to contest_contestnotification_path(@contestnotifications)
|
||||
end
|
||||
|
||||
def destroy
|
||||
@contestnotifications.notificaioncomments.find(params[:notificaioncomment_id]).destroy
|
||||
redirect_to contest_contestnotification_path(@contestnotifications)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def find_model_object
|
||||
super
|
||||
@contestnotifications = @object
|
||||
@notificaioncomment = nil
|
||||
@contestnotifications
|
||||
end
|
||||
|
||||
end
|
@ -0,0 +1,2 @@
|
||||
module NotificationcommentsHelper
|
||||
end
|
@ -0,0 +1,11 @@
|
||||
class Notificationcomments < ActiveRecord::Base
|
||||
attr_accessible :author_id, :notificationcommented_id, :notificationcommented_type, :notificationcomments
|
||||
|
||||
include Redmine::SafeAttributes
|
||||
belongs_to :notificationcommented, :polymorphic => true, :counter_cache => true
|
||||
belongs_to :author, :class_name => 'User', :foreign_key => 'author_id'
|
||||
|
||||
validates_presence_of :notificationcommented, :author, :comments
|
||||
|
||||
safe_attributes 'notificationcomments'
|
||||
end
|
@ -0,0 +1,12 @@
|
||||
class CreateNotificationcomments < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :notificationcomments do |t|
|
||||
t.string :notificationcommented_type
|
||||
t.integer :notificationcommented_id
|
||||
t.integer :author_id
|
||||
t.text :notificationcomments
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,13 @@
|
||||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
|
||||
|
||||
one:
|
||||
notificationcommented_type: MyString
|
||||
notificationcommented_id: 1
|
||||
author_id: 1
|
||||
notificationcomments: MyText
|
||||
|
||||
two:
|
||||
notificationcommented_type: MyString
|
||||
notificationcommented_id: 1
|
||||
author_id: 1
|
||||
notificationcomments: MyText
|
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class NotificationcommentsControllerTest < ActionController::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
@ -0,0 +1,4 @@
|
||||
require 'test_helper'
|
||||
|
||||
class NotificationcommentsHelperTest < ActionView::TestCase
|
||||
end
|
@ -0,0 +1,7 @@
|
||||
require 'test_helper'
|
||||
|
||||
class NotificationcommentsTest < ActiveSupport::TestCase
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
Loading…
Reference in new issue