From 594ce8a3040ec34bcdb2ca7849865bfb59ac7ef0 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 21 Jan 2016 16:57:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=87=A0=E4=B8=AAbug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 21 ++++++++++++++----- app/views/news/_project_news.html.erb | 2 +- app/views/news/_project_news_new.html.erb | 2 +- app/views/news/_project_show.html.erb | 2 +- app/views/news/edit.html.erb | 2 +- .../organizations/_org_subfield_news.html.erb | 16 +++++++++++++- app/views/users/_course_news.html.erb | 16 +++++++++++++- app/views/users/_project_news.html.erb | 20 +++++++++++++++--- 8 files changed, 67 insertions(+), 14 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index b1c384ae4..38d148907 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1791,13 +1791,24 @@ class UsersController < ApplicationController def share_news_to_project news = News.find(params[:send_id]) project_ids = params[:project_ids] + # project_ids.each do |project_id| + # if Project.find(project_id).news.map(&:id).exclude?(news.id) + # project_news = News.create(:project_id => project_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now) + # news.attachments.each do |attach| + # project_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, + # :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, + # :is_public => attach.is_public, :quotes => 0) + # end + # end + # end project_ids.each do |project_id| - if Project.find(project_id).news.map(&:id).exclude?(news.id) - project_news = News.create(:project_id => project_id.to_i, :title => news.title, :summary => news.summary, :description => news.description,:author_id => User.current.id, :created_on => Time.now) + project = Project.find(project_id) + if project.news.map(&:id).exclude?(news.id) + message = Message.create(:board_id => project.boards.first.id, :subject => news.title, :content => news.description, :author_id => User.current.id) news.attachments.each do |attach| - project_news.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, - :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, - :is_public => attach.is_public, :quotes => 0) + message.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, + :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, + :is_public => attach.is_public, :quotes => 0) end end end diff --git a/app/views/news/_project_news.html.erb b/app/views/news/_project_news.html.erb index fa2a99cd7..1b4c51cd0 100644 --- a/app/views/news/_project_news.html.erb +++ b/app/views/news/_project_news.html.erb @@ -23,7 +23,7 @@
- 项目通知 + 新闻
<% if @project && User.current.allowed_to?(:manage_news, @project) %> diff --git a/app/views/news/_project_news_new.html.erb b/app/views/news/_project_news_new.html.erb index 0e9b03c6f..e3d63ba9c 100644 --- a/app/views/news/_project_news_new.html.erb +++ b/app/views/news/_project_news_new.html.erb @@ -6,7 +6,7 @@
- +

<%end%>
diff --git a/app/views/news/edit.html.erb b/app/views/news/edit.html.erb index 76259f5d7..116000a8e 100644 --- a/app/views/news/edit.html.erb +++ b/app/views/news/edit.html.erb @@ -11,7 +11,7 @@
- 编辑通知 + 编辑<%= @news.project_id != -1 ? '新闻':'通知' %>
<%= labelled_form_for :news, @news, :url => news_path(@news), diff --git a/app/views/organizations/_org_subfield_news.html.erb b/app/views/organizations/_org_subfield_news.html.erb index 074d15a42..1e7ae72df 100644 --- a/app/views/organizations/_org_subfield_news.html.erb +++ b/app/views/organizations/_org_subfield_news.html.erb @@ -35,7 +35,21 @@
  • <% if User.current.logged? %>
      -
    • <%= link_to("发       送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}','#{User.current.id}','news')") %>
    • +
    • <%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}',#{User.current.id},'news')") %>
    • +
    • + <%= link_to( + l(:button_edit), + {:action => 'edit', :id => activity}, + :class => 'postOptionLink' + ) if activity.author == User.current %> +
    • +
    • + <%= delete_link( + news_path(activity), + :data => {:confirm => l(:text_are_you_sure)}, + :class => 'postOptionLink' + ) if activity.author == User.current %> +
    <% end %>
  • diff --git a/app/views/users/_course_news.html.erb b/app/views/users/_course_news.html.erb index 67d09d365..30053f6c6 100644 --- a/app/views/users/_course_news.html.erb +++ b/app/views/users/_course_news.html.erb @@ -40,7 +40,21 @@
  • <% if User.current.logged? %>
      -
    • <%= link_to("发       送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}',#{User.current.id},'news')") %>
    • +
    • <%= link_to("发送", 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{activity.id}',#{User.current.id},'news')") %>
    • +
    • + <%= link_to( + l(:button_edit), + {:action => 'edit', :id => activity}, + :class => 'postOptionLink' + ) if User.current.allowed_to?(:manage_news, activity.course) %> +
    • +
    • + <%= delete_link( + news_path(activity), + :data => {:confirm => l(:text_are_you_sure)}, + :class => 'postOptionLink' + ) if User.current.allowed_to?(:manage_news, activity.course) %> +
    <% end %>
  • diff --git a/app/views/users/_project_news.html.erb b/app/views/users/_project_news.html.erb index eb4941668..f7a779eb6 100644 --- a/app/views/users/_project_news.html.erb +++ b/app/views/users/_project_news.html.erb @@ -10,8 +10,8 @@ <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> <% else %> <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> - <% end %> TO - <%= link_to activity.project.name.to_s+" | 项目通知", project_news_index_path(activity.project), :class => "newsBlue ml15" %> + <% end %> TO + <%= link_to activity.project.name.to_s+" | 新闻", project_news_index_path(activity.project), :class => "newsBlue ml15" %>