From eafbb208073dc78458b6e37cdb341b64dfaa2bc9 Mon Sep 17 00:00:00 2001 From: yanxd Date: Mon, 6 Jan 2014 21:11:20 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8C=BF=E5=90=8D=E7=94=A8=E6=88=B7=E7=A6=81?= =?UTF-8?q?=E6=AD=A2=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 10 +++++- app/views/bids/_history.html.erb | 5 +++ app/views/bids/show.html.erb | 1 + app/views/projects/feedback.html.erb | 32 +++++++++++++------ app/views/words/_journal_reply_items.html.erb | 7 +++- app/views/words/_message.html.erb | 8 +++-- 6 files changed, 50 insertions(+), 13 deletions(-) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 550197889..9ca8236d0 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -28,7 +28,15 @@ class JournalsForMessage < ActiveRecord::Base # default_scope { where('m_parent_id IS NULL') } - def remove_by_user? user + def self.create_by_user? user + if user.anonymous? + return false + else + return true + end + end + + def self.remove_by_user? user if( self.user == user || ( self.jour.kind_of?(User) && self.jour== user ) ) diff --git a/app/views/bids/_history.html.erb b/app/views/bids/_history.html.erb index a3560fc00..e8fced1fd 100644 --- a/app/views/bids/_history.html.erb +++ b/app/views/bids/_history.html.erb @@ -1,3 +1,4 @@ +<% reply_allow = JournalsForMessage.create_by_user? User.current %> <% tip1 = (@bid.reward_type == 3) ? l(:label_student_response) : l(:label_user_response) %>

<%=tip1%>

@@ -29,11 +30,13 @@ <%= l(:label_bids_published) %> <%= time_tag(journal.created_on).html_safe %> <%= l(:label_bids_published_ago) %> <% ids = 'project_respond_form_'+ journal.id.to_s%> + <% if reply_allow %> <%= 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;"} %> + <% end %> <% 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)) %> @@ -43,9 +46,11 @@
<% ids = 'project_respond_form_'+ journal.id.to_s%> + <% if reply_allow %>
<%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal} %>
+ <% end %>
<%= render :partial => "words/journal_reply", :locals => {:journal => journal } %> diff --git a/app/views/bids/show.html.erb b/app/views/bids/show.html.erb index aec3bb7ee..46b05c292 100644 --- a/app/views/bids/show.html.erb +++ b/app/views/bids/show.html.erb @@ -1,3 +1,4 @@ +<% reply_allow = JournalsForMessage.create_by_user? User.current %>
<%= image_tag(url_to_avatar(@bid.author), :class => "avatar")%> diff --git a/app/views/projects/feedback.html.erb b/app/views/projects/feedback.html.erb index 027132cda..a4e0a3a79 100644 --- a/app/views/projects/feedback.html.erb +++ b/app/views/projects/feedback.html.erb @@ -36,17 +36,27 @@ function checkMaxLength() { +<% reply_allow = JournalsForMessage.create_by_user? User.current %> +

<%= l(:label_user_response) %>

+<% if !User.current.logged?%> +
+ <%= l(:label_user_login_tips) %> + <%= link_to l(:label_user_login_new), signin_path %> +
+
+<% else %>
-<%= form_for('new_form', :method => :post, - :url => {:controller => 'words', :action => 'leave_project_message'}) do |f|%> - <%= f.text_area 'project_message', :rows => 3, :cols => 65, - :placeholder => "#{l(:label_welcome_my_respond)}", - :style => "resize: none; width: 98%", - :class => 'noline'%> - <%= submit_tag l(:button_leave_meassge), :name => nil , :class => "enterprise" , :style => "display: block; float: right; margin-right: 1%; margin-top: 1px;"%> -<% end %> + <%= form_for('new_form', :method => :post, + :url => {:controller => 'words', :action => 'leave_project_message'}) do |f|%> + <%= f.text_area 'project_message', :rows => 3, :cols => 65, + :placeholder => "#{l(:label_welcome_my_respond)}", + :style => "resize: none; width: 98%", + :class => 'noline'%> + <%= submit_tag l(:button_leave_meassge), :name => nil , :class => "enterprise" , :style => "display: block; float: right; margin-right: 1%; margin-top: 1px;"%> + <% end %>
+<% end %>
<% if @jour.size >0 %>
    @@ -59,18 +69,22 @@ function checkMaxLength() { <%= l :label_update_time %>: <%= format_time journal.created_on %> <% id = 'project_respond_form_'+journal.id.to_s%> - <%= link_to l(:label_projects_feedback_respond),'', + <% if reply_allow %> + <%= link_to l(:label_projects_feedback_respond),'#', {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{id}'), $('##{id} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}: '); return false;"} %> + <% end %>
    + <% if reply_allow %>
    <%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal} %>
    + <% end %>
    <%= render :partial => "words/journal_reply", :locals => {:journal => journal } %> diff --git a/app/views/words/_journal_reply_items.html.erb b/app/views/words/_journal_reply_items.html.erb index 0cc3e1709..a70a555aa 100644 --- a/app/views/words/_journal_reply_items.html.erb +++ b/app/views/words/_journal_reply_items.html.erb @@ -1,3 +1,4 @@ +<% reply_allow = JournalsForMessage.create_by_user? User.current %> <% ids_r = 'reply_respond_form_'+ reply.id.to_s %>
  • @@ -12,10 +13,12 @@

    <%= format_time reply.created_on %>

  • + <% if reply_allow %> <%= render :partial => "words/new_respond", :locals => {:journal => journal, :m_reply_id => m_reply_id} %> + <% end %>
    \ No newline at end of file diff --git a/app/views/words/_message.html.erb b/app/views/words/_message.html.erb index 7c7ae4acd..03547aa8d 100644 --- a/app/views/words/_message.html.erb +++ b/app/views/words/_message.html.erb @@ -35,6 +35,7 @@ function checkMaxLength() { } +<% reply_allow = JournalsForMessage.create_by_user? User.current %> <% if jour.size >0 %> <% remove_allowed = (User.current.id == jour.first.user_id) %>
      @@ -49,10 +50,11 @@ function checkMaxLength() { <%= l :label_comment_time %>:  <%= format_time journal.created_on %> <% ids = 'project_respond_form_'+ journal.id.to_s%> - <%= link_to l(:label_projects_feedback_respond),'', + <% if reply_allow %> + <%= link_to l(:label_projects_feedback_respond),'', {:focus => 'project_respond', :onclick => "toggleAndSettingWordsVal($('##{ids}'), $('##{ids} textarea'), '#{l(:label_reply_plural)} #{journal.user.show_name}: '); $('##{ids} textarea') ;return false;"} %> - + <% end %> <% if @user == User.current || User.current.admin? || journal.user.id == User.current.id %> <%= link_to(l(:label_newfeedback_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)) %> @@ -61,7 +63,9 @@ function checkMaxLength() {
      + <% if reply_allow %> <%= render :partial => 'words/new_respond', :locals => {:journal => journal, :m_reply_id => journal} %> + <% end %>