From ece9f9dc6fb65395719072d44b52a1d23975bda9 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Thu, 21 Jan 2016 10:33:53 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=96=B0=E9=97=BB=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=96=B9=E5=9D=97=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/news_controller.rb | 15 ++ app/views/news/_project_news.html.erb | 103 +++------ app/views/news/_project_news_detail.html.erb | 56 +++++ app/views/news/_project_news_new.html.erb | 60 +++++ app/views/news/_project_show.html.erb | 221 ++++++++++++++----- app/views/news/edit.html.erb | 4 +- app/views/users/_project_news.html.erb | 141 ++++++++++-- config/routes.rb | 2 + 8 files changed, 451 insertions(+), 151 deletions(-) create mode 100644 app/views/news/_project_news_detail.html.erb create mode 100644 app/views/news/_project_news_new.html.erb diff --git a/app/controllers/news_controller.rb b/app/controllers/news_controller.rb index 8d0309588..5c9c48904 100644 --- a/app/controllers/news_controller.rb +++ b/app/controllers/news_controller.rb @@ -155,6 +155,21 @@ class NewsController < ApplicationController #modify by nwb if @project @news = News.new(:project => @project, :author => User.current) + @news.safe_attributes = params[:news] + @news.save_attachments(params[:attachments]) + if @news.save + if params[:asset_id] + ids = params[:asset_id].split(',') + update_kindeditor_assets_owner ids,@news.id,OwnerTypeHelper::NEWS + end + render_attachment_warning_if_needed(@news) + #flash[:notice] = l(:notice_successful_create) + redirect_to project_news_index_url(@project) + else + redirect_to project_news_index_url(@project) + #layout_file = 'base_courses' + #render :action => 'new', :layout => layout_file + end elsif @course @news = News.new(:course => @course, :author => User.current) #render :layout => 'base_courses' diff --git a/app/views/news/_project_news.html.erb b/app/views/news/_project_news.html.erb index efbb74e46..fa2a99cd7 100644 --- a/app/views/news/_project_news.html.erb +++ b/app/views/news/_project_news.html.erb @@ -1,77 +1,36 @@ - -<% - btn_tips = l(:label_news_new) - label_tips = l(:label_news) -%> -
-

<%= label_tips %>

-
-
-

<%= l(:label_total_news) %><%= @news_count %><%= l(:label_project_new_list) %>

- <% if @project && User.current.allowed_to?(:manage_news, @project) %> - <%= link_to(btn_tips, new_project_news_path(@project), - :class => 'problem_new_btn fl c_dorange') %> -
- - <% end %> -
-
-
- <% if @newss.empty? %> -

- <%= l(:label_no_data) %> -

- <% else %> - <% @newss.each do |news| %> -
- <%= link_to image_tag(url_to_avatar(news.author),:width => 42,:height => 42), user_path(news.author), :class => "problem_pic fl" %> -
- <%= link_to_user_header(news.author,false,{:class=> 'problem_name c_orange fl'}) if news.respond_to?(:author) %> - <%= l(:label_add_news) %>:<%= link_to h(news.title), news_path(news),:class => 'problem_tit fl fb c_dblue' %> - <%=link_to "#{news.comments.all.count}".html_safe, news_path(news.id), :class => "pro_mes_w_news" %>
-
-

<%=textAreailizable news.description %>

- - <%= l(:label_create_time) %> :<%= format_time(news.created_on) %> -
-
-
+ +
+
+
+ 项目通知 +
+
+ <% if @project && User.current.allowed_to?(:manage_news, @project) %> + <%= labelled_form_for @news, :url =>{:controller=>'news',:action => 'new', :project_id => @project.id}, + :html => {:nhname=>'form',:multipart => true, :id => 'news-form'} do |f| %> + <%= render :partial => 'project_news_new', :locals => {:f => f, :news => @news, :edit_mode => false} %> <% end %> <% end %> + <%= render :partial=> 'project_news_detail',:locals =>{:all_news => @newss, :page => 0} %>
- - - - <% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => {:project_id => @project, :key => User.current.rss_key} %> - <% end %> - - <% content_for :header_tags do %> - <%= auto_discovery_link_tag(:atom, params.merge({:format => 'atom', :page => nil, :key => User.current.rss_key})) %> - <%= stylesheet_link_tag 'scm' %> - <% end %> - - <% html_title(l(:label_news_plural)) -%> - - diff --git a/app/views/news/_project_news_detail.html.erb b/app/views/news/_project_news_detail.html.erb new file mode 100644 index 000000000..fdb035bf5 --- /dev/null +++ b/app/views/news/_project_news_detail.html.erb @@ -0,0 +1,56 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false) %> + <%= javascript_include_tag "init_activity_KindEditor" %> +<% end %> + + +<% if all_news %> + <% all_news.each do |news| %> + + <% if news %> + <%= render :partial => 'users/project_news', :locals => {:activity => news, :user_activity_id => news.id} %> + <% end %> + <% end %> + + <% if all_news.count == 10 %> + <%= link_to "点击展开更多",news_index_path(:project_id => @project.id ,:page => page),:id => "show_more_project_news",:remote => "true",:class => "loadMore mt10 f_grey"%> + <% end %> +<% end%> + diff --git a/app/views/news/_project_news_new.html.erb b/app/views/news/_project_news_new.html.erb new file mode 100644 index 000000000..0e9b03c6f --- /dev/null +++ b/app/views/news/_project_news_new.html.erb @@ -0,0 +1,60 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: true, prettify: false) %> +<% end %> + +
+
+
+
+ +

+
+ +
+
+
\ No newline at end of file diff --git a/app/views/news/_project_show.html.erb b/app/views/news/_project_show.html.erb index 463b0f489..7a62ec314 100644 --- a/app/views/news/_project_show.html.erb +++ b/app/views/news/_project_show.html.erb @@ -1,72 +1,173 @@ -
-

<%= l(:label_news) %>

-
+<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> +<% end %> + + + -<% if authorize_for('news', 'edit') %> -