项目留言.
This commit is contained in:
parent
36289eba41
commit
ebc803a88a
|
@ -181,9 +181,7 @@ class ProjectsController < ApplicationController
|
|||
@s_type = 2
|
||||
end
|
||||
else
|
||||
logger.debug("-------------------------------------------------")
|
||||
@projects = Project.visible.where("project_type = ?", 1).order("created_on desc").offset(@project_pages.offset).limit(@limit).all
|
||||
logger.debug("-------------------------------------------------")
|
||||
@s_type = 0
|
||||
end
|
||||
respond_to do |format|
|
||||
|
@ -316,7 +314,6 @@ class ProjectsController < ApplicationController
|
|||
|
||||
# flash[:notice]=l(:label_projects_feedback_respond_success)
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to :back }
|
||||
format.js
|
||||
|
|
|
@ -40,10 +40,9 @@ class WordsController < ApplicationController
|
|||
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
|
|
@ -14,22 +14,22 @@
|
|||
<% if @jour.size >0 %>
|
||||
<ul class="message-for-user">
|
||||
<% for journal in @jour%>
|
||||
<li class="outer-message-for-user">
|
||||
<li id='word_li_<%=journal.id.to_s%>' class="outer-message-for-user">
|
||||
<span class="portrait"><%= image_tag(url_to_avatar(journal.user), :class => "avatar") %></span>
|
||||
<span class="body">
|
||||
<span class="user"><%= link_to journal.user, user_path(journal.user)%></span>
|
||||
<span class="font_lighter"><%= l(:label_projects_feedback) %></span>
|
||||
<p >
|
||||
<%= textilizable journal.notes%>
|
||||
</p>
|
||||
<span class="font_lighter"> <%= l :label_update_time %>: <%= format_time journal.created_on %></span>
|
||||
<% id = 'project_respond_form_'+journal.id.to_s%>
|
||||
<span><%= link_to l(:label_projects_feedback_respond),'',
|
||||
<span>
|
||||
<%= link_to l(:label_projects_feedback_respond),'',
|
||||
{:focus => 'project_respond',
|
||||
:onclick => "toggleAndSettingWordsVal($('##{id}'),
|
||||
$('##{id} textarea'),
|
||||
'#{l(:label_reply_plural)} #{m_reply_id.user.show_name}: ');
|
||||
return false;"} %></span>
|
||||
'#{l(:label_reply_plural)} #{journal.user.show_name}: ');
|
||||
return false;"} %>
|
||||
</span>
|
||||
</span>
|
||||
<div style="clear: both;"></div>
|
||||
<div id='<%= id %>' class="respond-form">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<% if @journal_destroyed.nil? %>
|
||||
alert('<%=l(:notice_failed_delete)%>');
|
||||
<% elsif (@journal_destroyed.jour_type == 'Principal')%>
|
||||
<% elsif (['Principal','Project'].include? @journal_destroyed.jour_type)%>
|
||||
var destroyedItem = $('#word_li_<%=@journal_destroyed.id%>')
|
||||
destroyedItem.fadeOut(600,function(){
|
||||
destroyedItem.remove();
|
||||
|
|
Loading…
Reference in New Issue