|
|
@ -282,7 +282,7 @@ class ProjectsController < ApplicationController
|
|
|
|
#Ended by young
|
|
|
|
#Ended by young
|
|
|
|
|
|
|
|
|
|
|
|
def feedback
|
|
|
|
def feedback
|
|
|
|
@jours = @project.journals_for_messages.reverse
|
|
|
|
@jours = @project.journals_for_messages.where('m_parent_id IS NULL').reverse
|
|
|
|
@limit = 10
|
|
|
|
@limit = 10
|
|
|
|
@feedback_count = @jours.count
|
|
|
|
@feedback_count = @jours.count
|
|
|
|
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
|
|
|
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
|
|
@ -297,39 +297,30 @@ class ProjectsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def project_respond
|
|
|
|
def project_respond
|
|
|
|
|
|
|
|
# will_reply = JournalsForMessage.find(params[:reference_id]) if params[:reference_id]
|
|
|
|
|
|
|
|
project_id = request.headers["Referer"].match((%r|/([0-9]{1,})/|))[1]
|
|
|
|
|
|
|
|
@project = Project.find(project_id)
|
|
|
|
|
|
|
|
parent_id = params[:reference_id]
|
|
|
|
|
|
|
|
author_id = User.current.id
|
|
|
|
|
|
|
|
reply_user_id = params[:reference_user_id]
|
|
|
|
|
|
|
|
reply_id = params[:reference_message_id]
|
|
|
|
|
|
|
|
content = params[:project_respond]
|
|
|
|
|
|
|
|
options = {:user_id => author_id,
|
|
|
|
|
|
|
|
:m_parent_id => parent_id,
|
|
|
|
|
|
|
|
:m_reply_id => reply_id,
|
|
|
|
|
|
|
|
:reply_id => reply_user_id,
|
|
|
|
|
|
|
|
:notes => content,
|
|
|
|
|
|
|
|
:is_readed => false}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@jfm = @project.add_new_jour(nil, nil, nil, options)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# flash[:notice]=l(:label_projects_feedback_respond_success)
|
|
|
|
|
|
|
|
|
|
|
|
if params[:project_respond].size>0
|
|
|
|
|
|
|
|
jour = JournalsForMessage.find(params[:reference_id]) if params[:reference_id]
|
|
|
|
|
|
|
|
if jour
|
|
|
|
|
|
|
|
user = jour.user
|
|
|
|
|
|
|
|
text = jour.notes
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
user = User.current
|
|
|
|
|
|
|
|
text = []
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
# Replaces pre blocks with [...]
|
|
|
|
|
|
|
|
text = text.to_s.strip.gsub(%r{<pre>((.|\s)*?)</pre>}m, '[...]')
|
|
|
|
|
|
|
|
reference_content = "> #{ll(Setting.default_language, :text_user_wrote, user)}\n> "
|
|
|
|
|
|
|
|
reference_content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n"
|
|
|
|
|
|
|
|
# reference_message = JournalForMessage.find(params[:reference_id])
|
|
|
|
|
|
|
|
message = params[:project_respond] + "\n" + reference_content
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
user.add_jour(User.current, message, user.id)
|
|
|
|
|
|
|
|
flash[:notice]=l(:label_projects_feedback_respond_success)
|
|
|
|
|
|
|
|
# if a_message.size > 5
|
|
|
|
|
|
|
|
# @message = a_message[-5, 5]
|
|
|
|
|
|
|
|
# else
|
|
|
|
|
|
|
|
# @message = a_message
|
|
|
|
|
|
|
|
# end
|
|
|
|
|
|
|
|
# @message_count = a_message.count
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html { redirect_to :back }
|
|
|
|
format.html { redirect_to :back }
|
|
|
|
#format.api { render_api_ok }
|
|
|
|
#format.api { render_api_ok }
|
|
|
|
end
|
|
|
|
end
|
|
|
|
# redirect_to project_feedback_path(@project)
|
|
|
|
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def new
|
|
|
|
def new
|
|
|
|