Nuevo plugin Redmine Questions 0.0.7 light
This commit is contained in:
parent
c5b56fffec
commit
7de6fb4627
51 changed files with 2162 additions and 0 deletions
16
plugins/redmine_questions/lib/acts_as_votable_vote_patch.rb
Normal file
16
plugins/redmine_questions/lib/acts_as_votable_vote_patch.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module RedmineQuestions
|
||||
module Patches
|
||||
module ActsAsVotableVotePatch
|
||||
def self.included(base) # :nodoc:
|
||||
base.class_eval do
|
||||
unloadable # Send unloadable so it will not be unloaded in development
|
||||
attr_accessible :votable, :voter, :vote_scope
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless RedmineCrm::ActsAsVotable::Vote.included_modules.include?(RedmineQuestions::Patches::ActsAsVotableVotePatch)
|
||||
RedmineCrm::ActsAsVotable::Vote.send(:include, RedmineQuestions::Patches::ActsAsVotableVotePatch)
|
||||
end
|
7
plugins/redmine_questions/lib/redmine_questions.rb
Normal file
7
plugins/redmine_questions/lib/redmine_questions.rb
Normal file
|
@ -0,0 +1,7 @@
|
|||
require_dependency 'redmine_questions/hooks/views_layouts_hook'
|
||||
|
||||
# require_dependency 'redmine_questions/patches/boards_controller_patch'
|
||||
require_dependency 'redmine_questions/patches/message_patch'
|
||||
require_dependency 'redmine_questions/patches/user_patch'
|
||||
require_dependency 'redmine_questions/patches/messages_controller_patch'
|
||||
require_dependency 'acts_as_votable_vote_patch' if ActiveRecord::VERSION::MAJOR >= 4
|
|
@ -0,0 +1,9 @@
|
|||
module RedmineQuestions
|
||||
module Hooks
|
||||
class ViewsLayoutsHook < Redmine::Hook::ViewListener
|
||||
def view_layouts_base_html_head(context={})
|
||||
return stylesheet_link_tag(:questions, :plugin => 'redmine_questions')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,21 @@
|
|||
require_dependency 'boards_controller'
|
||||
require_dependency 'board'
|
||||
|
||||
module RedmineQuestions
|
||||
module Patches
|
||||
|
||||
module BoardsControllerPatch
|
||||
def self.included(base) # :nodoc:
|
||||
base.class_eval do
|
||||
helper :questions
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
unless MessagesController.included_modules.include?(RedmineQuestions::Patches::BoardsControllerPatch)
|
||||
MessagesController.send(:include, RedmineQuestions::Patches::BoardsControllerPatch)
|
||||
end
|
|
@ -0,0 +1,44 @@
|
|||
module RedmineQuestions
|
||||
module Patches
|
||||
module MessagePatch
|
||||
def self.included(base) # :nodoc:
|
||||
base.send(:include, InstanceMethods)
|
||||
|
||||
base.class_eval do
|
||||
unloadable # Send unloadable so it will not be unloaded in development
|
||||
rcrm_acts_as_taggable
|
||||
rcrm_acts_as_votable
|
||||
rcrm_acts_as_viewed
|
||||
|
||||
safe_attributes 'tag_list',
|
||||
:if => lambda {|message, user|
|
||||
user.allowed_to?(:edit_messages_tags, message.project)
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
def to_param
|
||||
"#{id}-#{ActiveSupport::Inflector.transliterate(subject).parameterize}"
|
||||
end
|
||||
|
||||
def like(user)
|
||||
liked_by(user)
|
||||
end
|
||||
|
||||
def dislike(user)
|
||||
unvote(:voter => user)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless Message.included_modules.include?(RedmineQuestions::Patches::MessagePatch)
|
||||
Message.send(:include, RedmineQuestions::Patches::MessagePatch)
|
||||
end
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
module RedmineQuestions
|
||||
module Patches
|
||||
|
||||
module MessagesControllerPatch
|
||||
|
||||
module InstanceMethods
|
||||
|
||||
def view_message
|
||||
@message.view(request.env['HTTP_X_FORWARDED_FOR'] || request.remote_ip || request.remote_addr, User.current.logged? ? User.current : nil) unless @message.author == User.current
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def self.included(base) # :nodoc:
|
||||
base.send(:include, InstanceMethods)
|
||||
|
||||
base.class_eval do
|
||||
after_filter :view_message, :only => :show
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
unless MessagesController.included_modules.include?(RedmineQuestions::Patches::MessagesControllerPatch)
|
||||
MessagesController.send(:include, RedmineQuestions::Patches::MessagesControllerPatch)
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
module RedmineQuestions
|
||||
module Patches
|
||||
module UserPatch
|
||||
def self.included(base) # :nodoc:
|
||||
base.class_eval do
|
||||
unloadable # Send unloadable so it will not be unloaded in development
|
||||
rcrm_acts_as_voter
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
unless User.included_modules.include?(RedmineQuestions::Patches::UserPatch)
|
||||
User.send(:include, RedmineQuestions::Patches::UserPatch)
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue