|
|
|
@ -39,11 +39,10 @@ class WordsController < ApplicationController
|
|
|
|
|
#format.api { render_api_ok }
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_reply
|
|
|
|
|
# deny api. api useless
|
|
|
|
|
user_id = request.headers["Referer"].match((%r|/([0-9]{1,})/|))[1]
|
|
|
|
|
@user = User.find(user_id)
|
|
|
|
|
parent_id = params[:reference_id]
|
|
|
|
|
author_id = User.current.id
|
|
|
|
|
reply_user_id = params[:reference_user_id]
|
|
|
|
@ -55,7 +54,8 @@ class WordsController < ApplicationController
|
|
|
|
|
:reply_id => reply_user_id,
|
|
|
|
|
:notes => content,
|
|
|
|
|
:is_readed => false}
|
|
|
|
|
@jfm = @user.add_jour(nil, nil, nil, options)
|
|
|
|
|
@obj = obj_distinguish_url_origin
|
|
|
|
|
@jfm = add_reply_adapter @obj, options
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
# format.html {
|
|
|
|
@ -74,21 +74,8 @@ class WordsController < ApplicationController
|
|
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
|
@journal_destroyed = JournalsForMessage.delete_message(params[:object_id])
|
|
|
|
|
@jours = @user.journals_for_messages.where('m_parent_id IS NULL').reverse
|
|
|
|
|
@limit = 10
|
|
|
|
|
@feedback_count = @jours.count
|
|
|
|
|
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
|
|
|
|
@offset ||= @feedback_pages.offset
|
|
|
|
|
@jour = @jours[@offset, @limit]
|
|
|
|
|
# if a_message.size > 5
|
|
|
|
|
# @message = a_message[-5, 5]
|
|
|
|
|
# else
|
|
|
|
|
# @message = a_message
|
|
|
|
|
# end
|
|
|
|
|
# @message_count = a_message.count
|
|
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
|
format.html { redirect_to :back }
|
|
|
|
|
format.js
|
|
|
|
|
#format.api { render_api_ok }
|
|
|
|
|
end
|
|
|
|
@ -187,5 +174,27 @@ class WordsController < ApplicationController
|
|
|
|
|
render_404
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def obj_distinguish_url_origin
|
|
|
|
|
referer = request.headers["Referer"]
|
|
|
|
|
obj_id = referer.match((%r|/([0-9]{1,})/|))[1]
|
|
|
|
|
if referer.match(/project/)
|
|
|
|
|
obj = Project.find_by_id(obj_id)
|
|
|
|
|
elsif referer.match(/user/)
|
|
|
|
|
obj = User.find_by_id(obj_id)
|
|
|
|
|
else
|
|
|
|
|
raise 'create reply obj unknow type.'
|
|
|
|
|
end
|
|
|
|
|
obj
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
def add_reply_adapter obj, options
|
|
|
|
|
if obj.kind_of? User
|
|
|
|
|
obj.add_jour(nil, nil, nil, options)
|
|
|
|
|
elsif obj.kind_of? Project
|
|
|
|
|
Project.add_new_jour(nil, nil, obj.id, options)
|
|
|
|
|
else
|
|
|
|
|
raise 'create reply obj unknow type.'
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
#######end of message
|
|
|
|
|
end
|