Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
edf2a84072
|
@ -1,4 +1,4 @@
|
|||
<html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>
|
||||
|
@ -8,15 +8,15 @@ Client
|
|||
|
||||
<body>
|
||||
<hr />
|
||||
<h2>这是一张图片</h2>
|
||||
<h2>这是一张图片</h2>
|
||||
<p>photo<a href="http://10.0.47.15:3000/shares/new?access_token='2d3dda45dsd'&comment='verygood'&title=davide&share_type=1&url=http://www.baidu.com"> Share A </a></p>
|
||||
<hr />
|
||||
|
||||
<h2>这是一段视频</h2>
|
||||
<h2>这是一段视频</h2>
|
||||
<p>Text<a href="http://10.0.47.15:3000/shares/new?access_token=2d3dda45dsd&comment=verygood&title=kaka&share_type=2&url=http://www.sina.com"> Share B </a></p>
|
||||
<hr />
|
||||
|
||||
<h2>这是一篇文章</h2>
|
||||
<h2>这是一篇文章</h2>
|
||||
<p>Text<a href="http://10.0.47.15:3000/shares/new?access_token=2d3dda45dsd&comment=verygood&title=pepe&share_type=3&url=http://www.sina.com"> Share C </a></p>
|
||||
<hr />
|
||||
|
||||
|
|
|
@ -26,6 +26,13 @@ class HomeworkAttachController < ApplicationController
|
|||
#删除留言
|
||||
def destroy
|
||||
@journal_destroyed = JournalsForMessage.delete_message(params[:object_id])
|
||||
@homework = HomeworkAttach.find(params[:id])
|
||||
@jours = @homework.journals_for_messages.order("created_on DESC")
|
||||
@limit = 10
|
||||
@feedback_count = @jours.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
@offset ||= @feedback_pages.offset
|
||||
@jour = @jours[@offset, @limit]
|
||||
respond_to do |format|
|
||||
format.js
|
||||
end
|
||||
|
@ -57,5 +64,27 @@ class HomeworkAttachController < ApplicationController
|
|||
#result = percent * 1.0 / stars_reates_count
|
||||
#result
|
||||
end
|
||||
|
||||
#添加回复
|
||||
def add_jour_reply
|
||||
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[:user_notes]
|
||||
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 = JournalsForMessage.new(options)
|
||||
@jfm.save
|
||||
respond_to do |format|
|
||||
format.js{
|
||||
@save_succ = true if @jfm.errors.empty?
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -193,7 +193,9 @@ class WordsController < ApplicationController
|
|||
elsif ( referer.match(/contests/) || referer.match(/contests/) ) #new added
|
||||
obj = Contest.find_by_id(obj_id)
|
||||
elsif ( referer.match(/softapplications/) || referer.match(/softapplications/) ) #new added
|
||||
obj = Softapplication.find_by_id(obj_id)
|
||||
obj = Softapplication.find_by_id(obj_id)
|
||||
elsif ( referer.match(/homework_attach/) || referer.match(/homework_attach/) ) #new added
|
||||
obj = HomeworkAttach.find_by_id(obj_id)
|
||||
else
|
||||
raise 'create reply obj unknow type.'
|
||||
end
|
||||
|
@ -211,7 +213,9 @@ class WordsController < ApplicationController
|
|||
elsif obj.kind_of? Contest
|
||||
obj.add_jour(nil, nil, obj.id, options) #new added
|
||||
elsif obj.kind_of? Softapplication
|
||||
obj.add_jour(nil, nil, obj.id, options) #new added
|
||||
obj.add_jour(nil, nil, obj.id, options) #new added
|
||||
elsif obj.kind_of? HomeworkAttach
|
||||
obj.add_jour(nil, nil, obj.id, options) #new added
|
||||
else
|
||||
raise 'create reply obj unknow type.'
|
||||
end
|
||||
|
|
|
@ -24,4 +24,10 @@ class HomeworkAttach < ActiveRecord::Base
|
|||
result = percent * 1.0 / stars_reates.count
|
||||
result
|
||||
end
|
||||
|
||||
def add_jours options
|
||||
jfm = self.journals_for_messages.build(options)
|
||||
jfm.save
|
||||
jfm
|
||||
end
|
||||
end
|
||||
|
|
|
@ -74,7 +74,8 @@ class JournalsForMessage < ActiveRecord::Base
|
|||
|
||||
def self.reference_message(user_id)
|
||||
@user = User.find(user_id)
|
||||
message = JournalsForMessage.find_by_sql("select * from journals_for_messages where reply_id = #{@user.id} or (jour_type = 'Bid' and jour_id in (select id from bids where author_id = #{@user.id}))")
|
||||
message = JournalsForMessage.find_by_sql("select * from journals_for_messages where reply_id = #{@user.id}
|
||||
or (jour_type = 'Bid' and jour_id in (select id from bids where author_id = #{@user.id}))")
|
||||
message
|
||||
end
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
<%= form_tag({:controller => 'homework_attach', :action => 'add_jour_reply'}, :remote => true) do %>
|
||||
<%= text_area_tag 'user_notes', "", :class => 'noline',
|
||||
:style => "resize: none;", :rows => 4,
|
||||
:placeholder => l(:label_projects_feedback_respond_content),
|
||||
:maxlength => 250 %>
|
||||
<span style="float: left; margin-top: 1px; margin-right: 4px;"></span>
|
||||
<%= hidden_field_tag 'reference_id', params[:reference_id], :value => journal.id %>
|
||||
<%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => m_reply_id.user.id %>
|
||||
<%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => m_reply_id.id %>
|
||||
<%= submit_tag l(:button_projects_feedback_respond),
|
||||
:name => nil , :class => "enterprise", :style => "float: right; margin-top: 1px; margin-right: 4px;"%>
|
||||
|
||||
<% end %>
|
|
@ -0,0 +1,6 @@
|
|||
<% id = "journal_reply_ul_" + journal.id.to_s%>
|
||||
<ul class="messages-for-user-reply" id = '<%= id %>' >
|
||||
<% journal.children.each do |reply|%>
|
||||
<%= render :partial => "journal_reply_items", :locals => {:reply => reply, :journal => journal, :m_reply_id => reply} %>
|
||||
<% end %>
|
||||
</ul>
|
|
@ -0,0 +1,34 @@
|
|||
<% reply_allow = JournalsForMessage.create_by_user? User.current %>
|
||||
<% ids_r = 'reply_respond_form_'+ reply.id.to_s %>
|
||||
<li id='word_li_<%=reply.id.to_s%>' onmouseover="$('#<%= ids_r %>').show()" onmouseout="$('#<%= ids_r %>').hide()">
|
||||
<span class="portrait">
|
||||
<%= image_tag url_to_avatar(reply.user), :class => "avatar-3" %>
|
||||
</span>
|
||||
<div class="message-body">
|
||||
<% id = 'project_respond_form_'+ reply.id.to_s %>
|
||||
<p>
|
||||
<span><%= link_to reply.user.name, user_path(reply.user) %>: </span>
|
||||
<span class="message-notes"> <%= reply.notes %></span>
|
||||
</p>
|
||||
<p>
|
||||
<span class="time"><%= format_time reply.created_on %></span>
|
||||
<span style="display: none; margin-left: 4px;" id='<%=ids_r%>' >
|
||||
<% if reply_allow %>
|
||||
<%= link_to l(:label_projects_feedback_respond),'',
|
||||
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{id}'), $('##{id} textarea'), '#{l(:label_reply_plural)} #{m_reply_id.user.name}: '); return false;"}
|
||||
%>
|
||||
<% end %>
|
||||
<% if @user == User.current || User.current.admin? || reply.user.id == User.current.id %>
|
||||
<%= link_to(l(:label_newfeedback_delete), {:controller => 'homework_attach', :action => 'destroy', :object_id => reply, :user_id => reply.user},
|
||||
:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %>
|
||||
<% end %>
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
<div id='<%=id %>' class="respond-form">
|
||||
<% if reply_allow %>
|
||||
<%= render :partial => "add_jour_reply", :locals => {:journal => journal, :m_reply_id => m_reply_id} %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
</li>
|
|
@ -40,24 +40,33 @@
|
|||
<% for journal in jour%>
|
||||
<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"><% label = l(:label_contest_requirement) %></span>
|
||||
<div> <%= textilizable journal.notes%> </div>
|
||||
<span class="font_lighter"><%= l(:label_bids_published) %>
|
||||
<%= time_tag(journal.created_on).html_safe %>
|
||||
<%= l(:label_bids_published_ago) %>
|
||||
<span class="body">
|
||||
<span class="user"><%= link_to journal.user, user_path(journal.user)%></span>
|
||||
<span class="font_lighter"><% label = l(:label_contest_requirement) %></span>
|
||||
<div> <%= textilizable journal.notes%> </div>
|
||||
<span class="font_lighter"><%= l(:label_bids_published) %>
|
||||
<%= time_tag(journal.created_on).html_safe %>
|
||||
<%= l(:label_bids_published_ago) %>
|
||||
</span>
|
||||
<% ids = 'project_respond_form_'+ journal.id.to_s%>
|
||||
<span>
|
||||
<%= link_to l(:label_projects_feedback_respond),'',
|
||||
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.name}: '); $('##{ids} textarea') ;return false;"}
|
||||
%>
|
||||
<% if journal.user==User.current|| User.current.admin? %>
|
||||
<%= link_to(l(:label_bid_respond_delete), {:controller => 'homework_attach', :action => 'destroy', :object_id => journal, :user_id => journal.user},
|
||||
:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %>
|
||||
<% end %>
|
||||
</span>
|
||||
</span>
|
||||
<% ids = 'project_respond_form_'+ journal.id.to_s%>
|
||||
<span>
|
||||
|
||||
<% if journal.user==User.current|| User.current.admin? %>
|
||||
<%= link_to(l(:label_bid_respond_delete), {:controller => 'homework_attach', :action => 'destroy', :object_id => journal, :user_id => journal.user},
|
||||
:remote => true, :confirm => l(:text_are_you_sure), :method => 'delete', :class => "delete", :title => l(:button_delete)) %>
|
||||
<% end %>
|
||||
</span>
|
||||
</span>
|
||||
<div style="clear: both;"></div>
|
||||
<div id='<%= ids %>' class="respond-form">
|
||||
<%= render :partial => 'add_jour_reply', :locals => {:journal => journal, :m_reply_id => journal} %>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
<div>
|
||||
<%= render :partial => "jour_reply", :locals => {:journal => journal } %>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<% if @save_succ %>
|
||||
var pre_append = $('<%= j(
|
||||
render :partial => "journal_reply_items",
|
||||
:locals => {:reply => @jfm, :journal => @jfm.parent, :m_reply_id => @jfm}
|
||||
) %>').hide();
|
||||
$('#journal_reply_ul_<%=@jfm.m_parent_id%>').append(pre_append);
|
||||
pre_append.fadeIn(600);
|
||||
var textarea = $('#project_respond_form_<%=@jfm.m_reply_id.to_s%> textarea');
|
||||
textarea.val('');
|
||||
$('#project_respond_form_<%=@jfm.m_reply_id.to_s%>').hide();
|
||||
setMaxLengthItem(pre_append.find('textarea')[0]);
|
||||
<% else %>
|
||||
alert("<%= l(:label_feedback_fail) %>");
|
||||
<% end %>
|
|
@ -6,6 +6,7 @@
|
|||
destroyedItem.remove();
|
||||
});
|
||||
<% else %>
|
||||
$('#message').html('<%= escape_javascript(render(:partial => 'showjour', :locals => {:jour => @jour, :state => false})) %>');
|
||||
|
||||
$('#message').html('<%= escape_javascript(render(:partial => 'showjour', :locals => {:jour => @jours, :state => false})) %>');
|
||||
$('#new_form_reference_user_id').val("");
|
||||
<% end %>
|
||||
|
|
|
@ -24,6 +24,8 @@ RedmineApp::Application.routes.draw do
|
|||
|
||||
resources :homework_attach
|
||||
match 'homework_attach/addjours', :controller => 'homework_attach', :action => 'addjours', :via => [:get,:post]
|
||||
match 'homework_attach/add_jour_reply', :controller => 'homework_attach', :action => 'add_jour_reply', :via => [:get,:post]
|
||||
|
||||
resources :open_source_projects do
|
||||
collection do
|
||||
match 'search', via: [:get, :post]
|
||||
|
|
Loading…
Reference in New Issue