Actualizar plugin Questions a 1.0.2 light
This commit is contained in:
parent
b9e569d03f
commit
b37d1305f1
64 changed files with 394 additions and 229 deletions
|
@ -1,7 +1,7 @@
|
|||
# This file is a part of Redmine Q&A (redmine_questions) plugin,
|
||||
# Q&A plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2011-2018 RedmineUP
|
||||
# Copyright (C) 2011-2020 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_questions is free software: you can redistribute it and/or modify
|
||||
|
@ -54,22 +54,22 @@ class Question < ActiveRecord::Base
|
|||
:author_key => :author_id,
|
||||
:timestamp => "#{table_name}.created_on",
|
||||
:scope => joins({:section => :project}, :author)
|
||||
acts_as_searchable :columns => ["#{table_name}.subject",
|
||||
"#{table_name}.content",
|
||||
acts_as_searchable :columns => ["#{table_name}.subject",
|
||||
"#{table_name}.content",
|
||||
"#{QuestionsAnswer.table_name}.content"],
|
||||
:scope => joins({:section => :project}, :answers),
|
||||
:project_key => "#{QuestionsSection.table_name}.project_id"
|
||||
:scope => joins({:section => :project}, :answers),
|
||||
:project_key => "#{QuestionsSection.table_name}.project_id"
|
||||
else
|
||||
acts_as_activity_provider :type => 'questions',
|
||||
:permission => :view_questions,
|
||||
:author_key => :author_id,
|
||||
:timestamp => "#{table_name}.created_on",
|
||||
:find_options => { :include => [{:section => :project}, :author] }
|
||||
acts_as_searchable :columns => ["#{table_name}.subject",
|
||||
"#{table_name}.content",
|
||||
acts_as_searchable :columns => ["#{table_name}.subject",
|
||||
"#{table_name}.content",
|
||||
"#{QuestionsAnswer.table_name}.content"],
|
||||
:include => [{:section => :project}, :answers],
|
||||
:project_key => "#{QuestionsSection.table_name}.project_id"
|
||||
:project_key => "#{QuestionsSection.table_name}.project_id"
|
||||
end
|
||||
|
||||
scope :solutions, lambda { joins(:section).where(:questions_sections => {:section_type => QuestionsSection::SECTION_TYPE_SOLUTIONS}) }
|
||||
|
@ -114,7 +114,7 @@ class Question < ActiveRecord::Base
|
|||
allowed_to_view_condition += projects_allowed_to_view_questions.empty? ? ' OR (0=1) ' : " OR (#{table_name}.project_id IN (#{projects_allowed_to_view_questions.join(',')}))"
|
||||
|
||||
user.admin? ? '(1=1)' : allowed_to_view_condition
|
||||
end
|
||||
end
|
||||
|
||||
def self.related(question, limit)
|
||||
tokens = question.subject.strip.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).
|
||||
|
@ -127,7 +127,7 @@ class Question < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def commentable?(user = User.current)
|
||||
return false if locked?
|
||||
return false if locked?
|
||||
user.allowed_to?(:comment_question, project)
|
||||
end
|
||||
|
||||
|
@ -285,6 +285,6 @@ class Question < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def send_notification
|
||||
Mailer.question_question_added(self).deliver if Setting.notified_events.include?('question_added')
|
||||
Mailer.question_question_added(User.current, self).deliver if Setting.notified_events.include?('question_added')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# This file is a part of Redmine Q&A (redmine_questions) plugin,
|
||||
# Q&A plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2011-2018 RedmineUP
|
||||
# Copyright (C) 2011-2020 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_questions is free software: you can redistribute it and/or modify
|
||||
|
@ -97,6 +97,7 @@ class QuestionsAnswer < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def editable_by?(user)
|
||||
(author == user && user.allowed_to?(:edit_own_answers, project)) ||
|
||||
user.allowed_to?(:edit_questions, project)
|
||||
end
|
||||
|
||||
|
@ -107,7 +108,7 @@ class QuestionsAnswer < ActiveRecord::Base
|
|||
def votable_by?(user)
|
||||
user.allowed_to?(:vote_questions, project)
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def check_accepted
|
||||
question.answers.update_all(:accepted => false) if question &&
|
||||
|
@ -121,6 +122,6 @@ class QuestionsAnswer < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def send_notification
|
||||
Mailer.question_answer_added(self).deliver if Setting.notified_events.include?('question_answer_added')
|
||||
Mailer.question_answer_added(User.current, self).deliver if Setting.notified_events.include?('question_answer_added')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# This file is a part of Redmine Q&A (redmine_questions) plugin,
|
||||
# Q&A plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2011-2018 RedmineUP
|
||||
# Copyright (C) 2011-2020 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_questions is free software: you can redistribute it and/or modify
|
||||
|
@ -27,7 +27,12 @@ class QuestionsSection < ActiveRecord::Base
|
|||
attr_protected :id if ActiveRecord::VERSION::MAJOR <= 4
|
||||
safe_attributes 'name', 'project', 'position', 'description', 'section_type'
|
||||
|
||||
scope :with_questions_count, lambda { select("#{QuestionsSection.table_name}.*, count(#{QuestionsSection.table_name}.id) as questions_count").joins(:questions).order("project_id ASC").group("#{QuestionsSection.table_name}.id, #{QuestionsSection.table_name}.name, #{QuestionsSection.table_name}.project_id, #{QuestionsSection.table_name}.section_type") }
|
||||
scope :with_questions_count, lambda {
|
||||
select("#{QuestionsSection.table_name}.*, count(#{QuestionsSection.table_name}.id) as questions_count").
|
||||
joins(:questions).
|
||||
order("project_id ASC").
|
||||
group(QuestionsSection.column_names.map { |column| "#{QuestionsSection.table_name}.#{column}" }.join(', '))
|
||||
}
|
||||
scope :for_project, lambda { |project| where(:project_id => project) unless project.blank? }
|
||||
scope :visible, lambda {|*args|
|
||||
joins(:project).
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# This file is a part of Redmine Q&A (redmine_questions) plugin,
|
||||
# Q&A plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2011-2018 RedmineUP
|
||||
# Copyright (C) 2011-2020 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_questions is free software: you can redistribute it and/or modify
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# This file is a part of Redmine Q&A (redmine_questions) plugin,
|
||||
# Q&A plugin for Redmine
|
||||
#
|
||||
# Copyright (C) 2011-2018 RedmineUP
|
||||
# Copyright (C) 2011-2020 RedmineUP
|
||||
# http://www.redmineup.com/
|
||||
#
|
||||
# redmine_questions is free software: you can redistribute it and/or modify
|
||||
|
@ -26,7 +26,7 @@ class QuestionsStatus < ActiveRecord::Base
|
|||
attr_protected :id if ActiveRecord::VERSION::MAJOR <= 4
|
||||
safe_attributes 'name', 'is_closed', 'position', 'color'
|
||||
|
||||
validates :name, :presence => true, :uniqueness => true
|
||||
validates :name, presence: true, uniqueness: true
|
||||
|
||||
scope :sorted, lambda { order(:position) }
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue