Actualizar plugin Questions a 1.0.2 light

This commit is contained in:
Manuel Cillero 2020-11-22 21:40:10 +01:00
parent b9e569d03f
commit b37d1305f1
64 changed files with 394 additions and 229 deletions

View file

@ -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
@ -34,9 +34,11 @@ class QuestionsAnswersController < ApplicationController
end
def edit
(render_403; return false) unless @answer.editable_by?(User.current)
end
def update
(render_403; return false) unless @answer.editable_by?(User.current) || User.current.allowed_to?(:accept_answers, @project)
@answer.safe_attributes = params[:answer]
@answer.save_attachments(params[:attachments])
if @answer.save
@ -87,7 +89,7 @@ class QuestionsAnswersController < ApplicationController
private
def redirect_to_question
redirect_to question_path(@answer.question, :anchor => "question_item_#{@answer.id}")
redirect_to question_path(@answer.question, :anchor => "questions_answer_#{@answer.id}")
end
def find_answer

View file

@ -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

View file

@ -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,6 +54,7 @@ class QuestionsController < ApplicationController
end
def update
(render_403; return false) unless @question_item.editable_by?(User.current)
@question_item.safe_attributes = params[:question]
@question_item.save_attachments(params[:attachments])
if @question_item.save
@ -133,6 +134,7 @@ class QuestionsController < ApplicationController
@text = (params[:question] ? params[:question][:content] : nil)
render :partial => 'common/preview'
end
private
def find_questions
@ -142,10 +144,10 @@ class QuestionsController < ApplicationController
scope = Question.visible
scope = scope.where(:section_id => @section) if @section
columns = ["subject", "content"]
tokens = seach.to_s.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).collect{|m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '')}.uniq.select {|w| w.length > 1 }
columns = ['subject', 'content']
tokens = seach.to_s.scan(%r{((\s|^)"[\s\w]+"(\s|$)|\S+)}).collect { |m| m.first.gsub(%r{(^\s*"\s*|\s*"\s*$)}, '') }.uniq.select { |w| w.length > 1 }
tokens = [] << tokens unless tokens.is_a?(Array)
token_clauses = columns.collect {|column| "(LOWER(#{column}) LIKE ?)"}
token_clauses = columns.collect { |column| "(LOWER(#{column}) LIKE ?)" }
sql = (['(' + token_clauses.join(' OR ') + ')'] * tokens.size).join(' AND ')
find_options = [sql, * (tokens.collect {|w| "%#{w.downcase}%"} * token_clauses.size).sort]
@ -166,9 +168,9 @@ class QuestionsController < ApplicationController
end
@limit = per_page_option
@offset = params[:page].to_i*@limit
@offset = params[:page].to_i * @limit
scope = scope.limit(@limit).offset(@offset)
scope = scope.tagged_with(params[:tag]) unless params[:tag].blank?
scope = scope.tagged_with(params[:tag]) if params[:tag].present?
@topic_count = scope.count
@topic_pages = Paginator.new @topic_count, @limit, params[:page]
@ -178,7 +180,7 @@ class QuestionsController < ApplicationController
def find_section
@section = QuestionsSection.find_by_id(params[:section_id] || (params[:question] && params[:question][:section_id]))
@section ||= @project.questions_sections.first
@section ||= @project.questions_sections.first if @project
rescue ActiveRecord::RecordNotFound
render_404
end

View file

@ -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
@ -58,6 +58,7 @@ class QuestionsSectionsController < ApplicationController
def update
@section.safe_attributes = params[:questions_section]
@section.insert_at(@section.position) if @section.position_changed?
if @section.save
respond_to do |format|
format.html do

View file

@ -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
@ -39,12 +39,13 @@ class QuestionsStatusesController < ApplicationController
end
def create
@questions_status = QuestionsStatus.new(params[:questions_status])
@questions_status = QuestionsStatus.new
@questions_status.safe_attributes = params[:questions_status]
if request.post? && @questions_status.save
flash[:notice] = l(:notice_successful_create)
redirect_to :action => "plugin", :id => "redmine_questions", :controller => "settings", :tab => 'questions_statuses'
redirect_to action: 'plugin', id: 'redmine_questions', controller: 'settings', tab: 'questions_statuses'
else
render :action => 'new'
render action: 'new'
end
end
@ -54,17 +55,18 @@ class QuestionsStatusesController < ApplicationController
def update
@questions_status = QuestionsStatus.find(params[:id])
if @questions_status.update_attributes(params[:questions_status])
@questions_status.safe_attributes = params[:questions_status]
if @questions_status.save
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_update)
redirect_to :action => 'plugin', :id => 'redmine_questions', :controller => 'settings', :tab => 'questions_statuses'
redirect_to action: 'plugin', id: 'redmine_questions', controller: 'settings', tab: 'questions_statuses'
}
format.js { head 200 }
end
else
respond_to do |format|
format.html { render :action => 'edit' }
format.html { render action: 'edit' }
format.js { head 422 }
end
end
@ -72,11 +74,9 @@ class QuestionsStatusesController < ApplicationController
def destroy
QuestionsStatus.find(params[:id]).destroy
redirect_to :action =>"plugin", :id => "redmine_questions", :controller => "settings", :tab => 'questions_statuses'
redirect_to action: 'plugin', id: 'redmine_questions', controller: 'settings', tab: 'questions_statuses'
rescue
flash[:error] = l(:error_products_unable_delete_questions_status)
redirect_to :action =>"plugin", :id => "redmine_questions", :controller => "settings", :tab => 'questions_statuses'
redirect_to action: 'plugin', id: 'redmine_questions', controller: 'settings', tab: 'questions_statuses'
end
end