竞赛众包的留言修改
This commit is contained in:
parent
6d82d2ce17
commit
90a37a5f4e
|
@ -18,6 +18,7 @@ class BidsController < ApplicationController
|
|||
helper :attachments
|
||||
include AttachmentsHelper
|
||||
helper :projects
|
||||
helper :words
|
||||
def index
|
||||
@project_type = params[:project_type]
|
||||
# Modified by nie
|
||||
|
@ -186,7 +187,7 @@ class BidsController < ApplicationController
|
|||
|
||||
def show
|
||||
@user = @bid.author
|
||||
@jours = @bid.journals_for_messages.reverse
|
||||
@jours = @bid.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
@limit = 10
|
||||
@feedback_count = @jours.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
|
@ -195,21 +196,19 @@ class BidsController < ApplicationController
|
|||
@state = false
|
||||
|
||||
respond_to do |format|
|
||||
if @bid.reward_type == 3
|
||||
format.html {
|
||||
render :layout => 'base_homework'
|
||||
}
|
||||
elsif @bid.reward_type == 1
|
||||
format.html {
|
||||
render :layout => 'base_bids'
|
||||
}
|
||||
layout_file = ''
|
||||
case @bid.reward_type
|
||||
when 3
|
||||
layout_file = 'base_homework'
|
||||
when 1
|
||||
layout_file = 'base_bids'
|
||||
else
|
||||
format.html {
|
||||
render :layout => 'base_contest'
|
||||
}
|
||||
layout_file = 'base_contest'
|
||||
end
|
||||
format.html {
|
||||
render :layout => layout_file
|
||||
}
|
||||
format.api
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -280,7 +280,7 @@ class ProjectsController < ApplicationController
|
|||
#Ended by young
|
||||
|
||||
def feedback
|
||||
@jours = @project.journals_for_messages.where('m_parent_id IS NULL').reverse
|
||||
@jours = @project.journals_for_messages.where('m_parent_id IS NULL').order('created_on DESC')
|
||||
@limit = 10
|
||||
@feedback_count = @jours.count
|
||||
@feedback_pages = Paginator.new @feedback_count, @limit, params['page']
|
||||
|
|
|
@ -175,11 +175,13 @@ class WordsController < ApplicationController
|
|||
|
||||
def obj_distinguish_url_origin
|
||||
referer = request.headers["Referer"]
|
||||
obj_id = referer.match((%r|/([0-9]{1,})/|))[1]
|
||||
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)
|
||||
elsif ( referer.match(/bids/) || referer.match(/calls/) )
|
||||
obj = Bid.find_by_id(obj_id)
|
||||
else
|
||||
raise 'create reply obj unknow type.'
|
||||
end
|
||||
|
@ -192,6 +194,8 @@ class WordsController < ApplicationController
|
|||
obj.add_jour(nil, nil, nil, options)
|
||||
elsif obj.kind_of? Project
|
||||
Project.add_new_jour(nil, nil, obj.id, options)
|
||||
elsif obj.kind_of? Bid
|
||||
obj.add_jour(nil, nil, nil, options)
|
||||
else
|
||||
raise 'create reply obj unknow type.'
|
||||
end
|
||||
|
|
|
@ -77,8 +77,14 @@ class Bid < ActiveRecord::Base
|
|||
# safe_attributes 'name',
|
||||
# 'description',
|
||||
# 'deadline'
|
||||
def add_jour(user, notes, reference_user_id = 0)
|
||||
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id)
|
||||
def add_jour(user, notes, reference_user_id = 0, options = {})
|
||||
if options.count == 0
|
||||
self.journals_for_messages << JournalsForMessage.new(:user_id => user.id, :notes => notes, :reply_id => reference_user_id)
|
||||
else
|
||||
jfm = self.journals_for_messages.build(options)
|
||||
jfm.save
|
||||
jfm
|
||||
end
|
||||
end
|
||||
|
||||
def self.creat_bids(budget, deadline, name, description=nil, reward_type)
|
||||
|
|
|
@ -4,41 +4,52 @@
|
|||
<div id='leave-message'>
|
||||
<%= render :partial => 'new', :locals => {:bid => @bid, :sta => @state} %>
|
||||
</div>
|
||||
<% label = '';
|
||||
case @bid.reward_type
|
||||
when 1
|
||||
label = l(:label_respond_requirement)
|
||||
when 2
|
||||
label = l(:label_contest_requirement)
|
||||
when 3
|
||||
label = l(:label_question_requirement)
|
||||
else
|
||||
end
|
||||
%>
|
||||
|
||||
|
||||
<% if journals.size >0 %>
|
||||
<ul class="message-for-user">
|
||||
<% for journal in journals%>
|
||||
<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>
|
||||
<% label = '';
|
||||
case @bid.reward_type
|
||||
when 1
|
||||
label = l(:label_respond_requirement)
|
||||
when 2
|
||||
label = l(:label_contest_requirement)
|
||||
when 3
|
||||
label = l(:label_question_requirement)
|
||||
else
|
||||
end
|
||||
%>
|
||||
<% for journal in journals%>
|
||||
<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 %></span>
|
||||
<%= textilizable journal.notes%>
|
||||
<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>
|
||||
<span><% if @user==User.current|| User.current.admin? %>
|
||||
<%= link_to(l(:label_bid_respond_quote), {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, :remote => true,
|
||||
:method => 'post', :title => l(:button_quote))%>
|
||||
<%= link_to(l(:label_bid_respond_delete), {:controller => 'bids', :action => 'destroy', :object_id => journal, :id => bid},:confirm => l(:label_delete_confirm),
|
||||
<% ids = 'project_respond_form_'+ journal.id.to_s%>
|
||||
<span>
|
||||
<%= link_to(l(:button_quote), {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, :remote => true,
|
||||
:method => 'post', :title => l(:button_quote))%>
|
||||
<%= link_to l(:label_bid_respond_quote),'',
|
||||
{:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}: '); $('##{ids} textarea') ;return false;"}
|
||||
%>
|
||||
<% if @user==User.current|| User.current.admin? %>
|
||||
<%#= link_to(l(:label_bid_respond_delete), {:controller => 'bids', :action => 'destroy', :object_id => journal, :id => bid},:confirm => l(:label_delete_confirm),
|
||||
:remote => true, :method => 'delete', :class => "delete", :confirm => l(:text_are_you_sure), :title => l(:button_delete)) %>
|
||||
<% else %>
|
||||
<%= link_to(l(:label_bid_respond_quote), {:controller => 'bids', :action => 'new', :id => bid, :journal_id => journal}, :remote => true,
|
||||
:method => 'post', :title => l(:button_quote))%>
|
||||
<% end %>
|
||||
<%= link_to(l(:label_bid_respond_delete), {:controller => 'words', :action => 'destroy', :object_id => journal, :user_id => 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>
|
||||
<% ids = 'project_respond_form_'+ journal.id.to_s%>
|
||||
<div id='<%= ids %>' class="respond-form">
|
||||
<%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal} %>
|
||||
</div>
|
||||
<div style="clear: both;"></div>
|
||||
<div>
|
||||
<%= render :partial => "words/journal_reply", :locals => {:journal => journal } %>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue