diff --git a/app/controllers/bids_controller.rb b/app/controllers/bids_controller.rb index 01c35ce7..c4f350fc 100644 --- a/app/controllers/bids_controller.rb +++ b/app/controllers/bids_controller.rb @@ -40,13 +40,18 @@ class BidsController < ApplicationController end def show - @state = false @user = @bid.author - @jour = @bid.journals_for_messages - @jour.each_with_index {|j,i| j.indice = i+1} + @jours = @bid.journals_for_messages.reverse + @limit = 10 + @feedback_count = @jours.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @jour = @jours[@offset, @limit] + @state = false + # # @journals = @bid.journals.includes(:user, :details).reorder("#{Journal.table_name}.id ASC").all - #@journals.each_with_index {|j,i| j.indice = i+1} + # @journals.each_with_index {|j,i| j.indice = i+1} respond_to do |format| format.html { render :layout => 'base_bids' @@ -99,8 +104,12 @@ class BidsController < ApplicationController ## 新建留言 def create - if params[:bid_message].size>0 - message = params[:bid_message][:message] + if params[:bid_message][:message].size>0 + if params[:reference_content] + message = params[:reference_content] + params[:bid_message][:message] + else + message = params[:bid_message][:message] + end refer_user_id = params[:bid_message][:reference_user_id].to_i @bid.add_jour(User.current, message, refer_user_id) # if a_message.size > 5 @@ -110,9 +119,14 @@ class BidsController < ApplicationController # end # @message_count = a_message.count end - @jour = @bid.journals_for_messages - @jour.each_with_index {|j,i| j.indice = i+1} - @bid.set_commit(@jour.count) + @user = @bid.author + @jours = @bid.journals_for_messages.reverse + @limit = 10 + @feedback_count = @jours.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @jour = @jours[@offset, @limit] + @bid.set_commit(@feedback_count) respond_to do |format| format.js @@ -124,9 +138,15 @@ class BidsController < ApplicationController ##删除留言 def destroy JournalsForMessage.delete_message(params[:object_id]) - @jour = @bid.journals_for_messages - @jour.each_with_index {|j,i| j.indice = i+1} - @bid.set_commit(@jour.count) + @user = @bid.author + @jours = @bid.journals_for_messages.reverse + @limit = 10 + @feedback_count = @jours.count + @feedback_pages = Paginator.new @feedback_count, @limit, params['page'] + @offset ||= @feedback_pages.offset + @jour = @jours[@offset, @limit] + + @bid.set_commit(@feedback_count) # if a_message.size > 5 # @message = a_message[-5, 5] # else @@ -153,7 +173,7 @@ class BidsController < ApplicationController end # Replaces pre blocks with [...] text = text.to_s.strip.gsub(%r{
((.|\s)*?)}m, '[...]') - @content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> " + @content = "> #{ll(Setting.default_language, :text_user_wrote, user)}\n> " @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" @id = user.id rescue ActiveRecord::RecordNotFound diff --git a/app/controllers/journals_controller.rb b/app/controllers/journals_controller.rb index 24784d26..1908213c 100644 --- a/app/controllers/journals_controller.rb +++ b/app/controllers/journals_controller.rb @@ -67,7 +67,7 @@ class JournalsController < ApplicationController end # Replaces pre blocks with [...] text = text.to_s.strip.gsub(%r{
((.|\s)*?)}m, '[...]') - @content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> " + @content = "> #{ll(Setting.default_language, :text_user_wrote, user)}\n> " @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" @id = user.id rescue ActiveRecord::RecordNotFound diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index b67deb89..5ae6d3bb 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -112,7 +112,7 @@ class MessagesController < ApplicationController @subject = @message.subject @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:') - @content = "#{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> " + @content = "> #{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> " @content << @message.content.to_s.strip.gsub(%r{
((.|\s)*?)}m, '[...]').gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" end diff --git a/app/controllers/test_controller.rb b/app/controllers/test_controller.rb index a123f3b5..e668a234 100644 --- a/app/controllers/test_controller.rb +++ b/app/controllers/test_controller.rb @@ -9,27 +9,27 @@ def index # @message.each do |m| # Activity.create(:act_id => m.id, :act_type => 'Message', :user_id => m.author_id) # end - activity = Message.all - activity += News.all - activity += Journal.all - activity += Issue.all - activity += Bid.all - @activity = activity.sort {|x,y| x.created_on <=> y.created_on} - @activity.each do |act| - if act.instance_of?(Bid) - act.acts << Activity.new(:user_id => act.author_id) - elsif act.instance_of?(News) - act.acts << Activity.new(:user_id => act.author_id) - elsif act.instance_of?(Message) - act.acts << Activity.new(:user_id => act.author_id) - elsif act.instance_of?(Journal) - act.acts << Activity.new(:user_id => act.user_id) - elsif act.instance_of?(Issue) - act.acts << Activity.new(:user_id => act.author_id) - elsif act.instance_of?(Changeset) - act.acts << Activity.new(:user_id => act.user_id) - end - end + # activity = Message.all + # activity += News.all + # activity += Journal.all + # activity += Issue.all + # activity += Bid.all + # @activity = activity.sort {|x,y| x.created_on <=> y.created_on} + # @activity.each do |act| + # if act.instance_of?(Bid) + # act.acts << Activity.new(:user_id => act.author_id) + # elsif act.instance_of?(News) + # act.acts << Activity.new(:user_id => act.author_id) + # elsif act.instance_of?(Message) + # act.acts << Activity.new(:user_id => act.author_id) + # elsif act.instance_of?(Journal) + # act.acts << Activity.new(:user_id => act.user_id) + # elsif act.instance_of?(Issue) + # act.acts << Activity.new(:user_id => act.author_id) + # elsif act.instance_of?(Changeset) + # act.acts << Activity.new(:user_id => act.user_id) + # end + # end #@watchers_of_projects = WatchersOfProjects.new diff --git a/app/controllers/words_controller.rb b/app/controllers/words_controller.rb index 1f05b0e8..60b7d8bd 100644 --- a/app/controllers/words_controller.rb +++ b/app/controllers/words_controller.rb @@ -5,7 +5,11 @@ class WordsController < ApplicationController def create if params[:new_form][:user_message].size>0 unless params[:user_id].nil? - message = params[:new_form][:user_message] + if params[:reference_content] + message = params[:reference_content] + params[:new_form][:user_message] + else + message = params[:new_form][:user_message] + end refer_user_id = params[:new_form][:reference_user_id].to_i @user.add_jour(User.current, message, refer_user_id) @@ -64,7 +68,7 @@ class WordsController < ApplicationController end # Replaces pre blocks with [...] text = text.to_s.strip.gsub(%r{
((.|\s)*?)}m, '[...]') - @content = "#{ll(Setting.default_language, :text_user_wrote, user)}\n> " + @content = "> #{ll(Setting.default_language, :text_user_wrote, user)}\n> " @content << text.gsub(/(\r?\n|\r\n?)/, "\n> ") + "\n\n" @id = user.id rescue ActiveRecord::RecordNotFound diff --git a/app/views/bids/_history.html.erb b/app/views/bids/_history.html.erb index c33013d9..00ad850f 100644 --- a/app/views/bids/_history.html.erb +++ b/app/views/bids/_history.html.erb @@ -1,24 +1,7 @@
<%=l(:label_user_response)%>(<%= journals.count%>) | -<% if journals.size > 5 %>
-<% unless state%>
-
-<%= link_to l(:button_more),
- {:controller => 'bids', :action => 'more', :id => bid},
- :remote => true,
- :method => 'get' %>
-
-<% else %>
-
-<%= link_to l(:button_back),
- {:controller => 'bids', :action => 'back', :id => bid},
- :remote => true,
- :method => 'get' %>
-
-<% end %>
-<% end %> | + | <%=l(:label_user_response)%> |
<%= textilizable content %> | +
<%= hidden_field_tag 'reference_content', params[:reference_content], :value => content%> | +
<%= textilizable content %> | +
<%= hidden_field_tag 'reference_content', params[:reference_content], :value => content%> | +