From 87564eceee8e98c0974c04a984a4e73a598e65ae Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Mon, 11 May 2015 15:25:16 +0800
Subject: [PATCH 1/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E4=B8=9A--->?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BD=9C=E5=93=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/homework_attach/edit.html.erb | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/app/views/homework_attach/edit.html.erb b/app/views/homework_attach/edit.html.erb
index 63c3051aa..e31c5008f 100644
--- a/app/views/homework_attach/edit.html.erb
+++ b/app/views/homework_attach/edit.html.erb
@@ -42,7 +42,7 @@
-
- 修改作业
+ 修改作品
-
成员
From f3b46c582393cfea59b7a59bb16800ac42484cd6 Mon Sep 17 00:00:00 2001
From: huang
Date: Mon, 11 May 2015 15:50:23 +0800
Subject: [PATCH 2/9] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E8=B5=84=E6=BA=90?=
=?UTF-8?q?=E5=BA=93=E6=9D=83=E9=99=90=E4=BC=98=E5=8C=96=EF=BC=9A=20?=
=?UTF-8?q?=E7=AE=A1=E7=90=86=E5=91=98=E3=80=81=E8=B5=84=E6=BA=90=E4=B8=8A?=
=?UTF-8?q?=E4=BC=A0=E8=80=85=E6=8B=A5=E6=9C=89=E8=AE=BE=E7=BD=AE=E5=85=AC?=
=?UTF-8?q?=E5=BC=80=E7=A7=81=E6=9C=89=E6=9D=83=E9=99=90=20=E7=A7=81?=
=?UTF-8?q?=E6=9C=89=E9=A1=B9=E7=9B=AE=E4=B8=8D=E6=8F=90=E4=BE=9B=E5=BC=95?=
=?UTF-8?q?=E7=94=A8=E5=85=B6=E5=AE=83=E9=A1=B9=E7=9B=AE=E5=92=8C=E5=85=AC?=
=?UTF-8?q?=E5=BC=80=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/files/_project_file_list.html.erb | 12 ++++--------
app/views/messages/edit.html.erb | 2 +-
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/app/views/files/_project_file_list.html.erb b/app/views/files/_project_file_list.html.erb
index 3dd5134d7..e11e4416b 100644
--- a/app/views/files/_project_file_list.html.erb
+++ b/app/views/files/_project_file_list.html.erb
@@ -20,20 +20,16 @@
<%= link_to_attachment file, :download => true,:text => truncate(file.filename,length: 35, omission: '...'), :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %>
<% if User.current.logged? %>
- <% if (manage_allowed || file.author_id == User.current.id) && project_contains_attachment?(project,file) %>
+
+
+ <% if project.is_public? %>
<%= link_to(l(:label_slected_to_other_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %>
-
- <% if manage_allowed && file.container_id == project.id && file.container_type == "Project" %>
+ <% if (Member.where(:user_id => User.current.id, :project_id => @project.id).first.roles.to_s.include?("Manager") || file.author_id == User.current.id) && project_contains_attachment?(project,file) && file.container_id == project.id && file.container_type == "Project" %>
<%= link_to (file.is_public? ? "公开":"私有"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"f_l re_open",:method => :post %>
- <% else %>
-
<% end %>
- <% else %>
- <%= link_to(l(:label_slected_to_project),quote_resource_show_project_project_file_path(project,file),:class => "f_l re_select",:remote => true) if has_project?(User.current,file) %>
<% end %>
- <% else %>
<% end %>
diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb
index 8fbeafcb9..d30aee45d 100644
--- a/app/views/messages/edit.html.erb
+++ b/app/views/messages/edit.html.erb
@@ -23,7 +23,7 @@
<% elsif @message.course %>
<%#= course_board_breadcrumb(@message) %>
-
+ 0
<%= form_for @message, {
:as => :message,
:url => {:action => 'edit'},
From c51794d7546aab016d8a51ce91f9d0acec9413af Mon Sep 17 00:00:00 2001
From: sw <939547590@qq.com>
Date: Mon, 11 May 2015 16:06:40 +0800
Subject: [PATCH 3/9] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E9=80=9A=E7=9F=A5?=
=?UTF-8?q?=E8=BF=9E=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/news/_course_form.html.erb | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/app/views/news/_course_form.html.erb b/app/views/news/_course_form.html.erb
index b757ab274..a76d84701 100644
--- a/app/views/news/_course_form.html.erb
+++ b/app/views/news/_course_form.html.erb
@@ -25,11 +25,11 @@
-
<% if is_new %>
- <%= link_to l(:button_create), "#", :onclick => 'submitNews();', :onmouseover => 'submitFocus(this);', :class => 'blue_btn fl c_white' %>
+ <%= link_to l(:button_create), "javascript:void(0)", :onclick => 'submitNews();', :onmouseover => 'submitFocus(this);', :class => 'blue_btn fl c_white' %>
<%= link_to l(:button_cancel), course_news_index_path(@course), :onclick => '$("#add-news").hide()', :class => 'blue_btn grey_btn fl c_white' %>
<% else %>
- <%= link_to l(:button_save), "#", :onclick => "submitNews();",:onmouseover => 'this.focus()',:class => 'blue_btn fl c_white' %>
- <%= link_to l(:button_cancel), "#", :onclick => '$("#edit-news").hide(); return false;',:class => 'blue_btn grey_btn fl c_white' %>
+ <%= link_to l(:button_save), "javascript:void(0)", :onclick => "submitNews();",:onmouseover => 'this.focus()',:class => 'blue_btn fl c_white' %>
+ <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => '$("#edit-news").hide(); return false;',:class => 'blue_btn grey_btn fl c_white' %>
<% end %>
From 25bcc676b975b26003f6b40bea1c16c35881b8f3 Mon Sep 17 00:00:00 2001
From: alan <547533434@qq.com>
Date: Mon, 11 May 2015 16:23:15 +0800
Subject: [PATCH 4/9] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E9=99=84=E4=BB=B6?=
=?UTF-8?q?=E5=8A=9F=E8=83=BD=E4=BB=A5=E5=8F=8A=E4=BF=AE=E6=94=B9=E8=B7=AF?=
=?UTF-8?q?=E7=94=B1=E8=B7=B3=E8=BD=AC=20Signed-off-by:=20alan=20<54753343?=
=?UTF-8?q?4@qq.com>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/boards_controller.rb | 2 +-
app/views/boards/_course_new.html.erb | 2 +-
app/views/boards/_course_show.html.erb | 3 +++
app/views/boards/_edit.html.erb | 7 ++++---
app/views/boards/_form_project.html.erb | 2 +-
app/views/boards/_project_new_topic.html.erb | 2 +-
app/views/boards/_project_show.html.erb | 8 ++++++--
public/stylesheets/pleft.css | 2 +-
8 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb
index f6ec09b2a..03581d0c2 100644
--- a/app/controllers/boards_controller.rb
+++ b/app/controllers/boards_controller.rb
@@ -27,7 +27,7 @@ class BoardsController < ApplicationController
include SortHelper
helper :watchers
helper :project_score
-
+ helper :attachments
def index
#modify by nwb
@flag = params[:flag] || false
diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb
index 94ba51529..e80ce8135 100644
--- a/app/views/boards/_course_new.html.erb
+++ b/app/views/boards/_course_new.html.erb
@@ -1,6 +1,6 @@
<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
- <%= render :partial => 'form_course', :locals => {:f => f} %>
+ <%= render :partial => 'form_course', :locals => {:f => f, :topic => @message} %>
-
<%= link_to l(:button_cancel), course_boards_path(@course), :class => 'grey_btn fr ml10' %>
<%= l(:button_submit)%>
diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb
index c55bb8336..34ce6e55f 100644
--- a/app/views/boards/_course_show.html.erb
+++ b/app/views/boards/_course_show.html.erb
@@ -57,6 +57,7 @@
+ <% if topic.content.size > 300 %>
<%= topic.content %>
@@ -66,6 +67,8 @@
+ <% end %>
+ <%= link_to_attachments_course topic, :author => false %>
<%= l(:label_activity_time)%>: <%= format_time topic.created_on %>
<%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => 'message_content',:class => ' c_dblue fr' %>
diff --git a/app/views/boards/_edit.html.erb b/app/views/boards/_edit.html.erb
index c41f723de..a4b2aff73 100644
--- a/app/views/boards/_edit.html.erb
+++ b/app/views/boards/_edit.html.erb
@@ -11,9 +11,10 @@
:method => :post}
} do |f| %>
<%= render :partial => 'form_project',
- :locals => {:f => f, :replying => !topic.parent.nil?} %>
+ :locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %>
<%= l(:button_submit)%>
- <%= link_to l(:button_cancel), board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "blue_btn grey_btn fl c_white" %>
+ <%= l(:button_cancel) %>
+ <%#= link_to l(:button_cancel), board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "blue_btn grey_btn fl c_white" %>
<% end %>
@@ -29,7 +30,7 @@
:method => :post}
} do |f| %>
<%= render :partial => 'form_course',
- :locals => {:f => f, :replying => !topic.parent.nil?} %>
+ :locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %>
<%= l(:button_submit)%>
<%= link_to l(:button_cancel), board_message_url(topic.board,topic.root, :r => (topic.parent_id &&topic.id)), :class => "blue_btn grey_btn fl c_white" %>
diff --git a/app/views/boards/_form_project.html.erb b/app/views/boards/_form_project.html.erb
index b42cabbeb..4e0ffe8e7 100644
--- a/app/views/boards/_form_project.html.erb
+++ b/app/views/boards/_form_project.html.erb
@@ -51,7 +51,7 @@
-
<% unless replying %>
- <%= render :partial => 'attachments/form_project', :locals => {:container => @message,:isReply => @isReply} %>
+ <%= render :partial => 'attachments/form_project', :locals => {:container => topic,:isReply => true} %>
<% end %>
diff --git a/app/views/boards/_project_new_topic.html.erb b/app/views/boards/_project_new_topic.html.erb
index 371007a72..2207c4b10 100644
--- a/app/views/boards/_project_new_topic.html.erb
+++ b/app/views/boards/_project_new_topic.html.erb
@@ -1,6 +1,6 @@
<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
- <%= render :partial => 'form_project', :locals => {:f => f} %>
+ <%= render :partial => 'form_project', :locals => {:f => f, :topic => @message} %>
-
<%= link_to l(:button_cancel), project_boards_path(@project), :class => 'grey_btn fr ml10' %>
<%= l(:button_submit)%>
diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb
index d0fd6215a..15237756a 100644
--- a/app/views/boards/_project_show.html.erb
+++ b/app/views/boards/_project_show.html.erb
@@ -61,6 +61,7 @@
<%= topic.content %>
+ <% if topic.content.size > 300 %>
@@ -68,14 +69,17 @@
-
-
+ <% end %>
+ <%= link_to_attachments_course topic, :author => false %>
<%= l(:label_activity_time)%>: <%= format_time topic.created_on %>
+
<%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => 'message_content',:class => ' c_dblue fr' %>
+
+
diff --git a/public/stylesheets/pleft.css b/public/stylesheets/pleft.css
index 4d495e999..6554db7ec 100644
--- a/public/stylesheets/pleft.css
+++ b/public/stylesheets/pleft.css
@@ -49,7 +49,7 @@ a:hover.subnav_green{ background:#14ad5a;}
/*简介*/
.project_intro{ width:220px; padding:10px; background:#fff; margin-top:10px; padding-top:5px; color:#6d6d6d; line-height:1.9;}
.course_description{max-height: 112px;overflow:hidden; word-break: break-all;word-wrap: break-word;}
-.project_board_content{overflow: hidden;max-height: 50px;word-break: break-all;word-wrap: break-word;}
+.project_board_content{overflow: hidden;max-height: 55px;word-break: break-all;word-wrap: break-word;}
.course_description_none{max-height: none;}
.lg-foot{ border:1px solid #e8eef2; color: #929598; text-align:center; width:220px; height:23px; cursor:pointer;display: none;}
.lg-foot:hover{ color:#787b7e; border:1px solid #d4d4d4;}
From 79c0c6f551aa67bfed5ed42efbd8af7084c93da5 Mon Sep 17 00:00:00 2001
From: alan <547533434@qq.com>
Date: Mon, 11 May 2015 16:45:03 +0800
Subject: [PATCH 5/9] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B7=AF=E7=94=B1?=
=?UTF-8?q?=E8=B7=B3=E8=BD=AC=20Signed-off-by:=20alan=20<547533434@qq.com>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/boards/_course_show.html.erb | 4 ++--
app/views/boards/_project_show.html.erb | 2 +-
app/views/layouts/_base_development_group.html.erb | 2 +-
app/views/layouts/_base_friend_group.html.erb | 2 +-
app/views/layouts/_base_research_team.html.erb | 2 +-
app/views/layouts/base_courses.html.erb | 2 +-
6 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb
index 34ce6e55f..3962a5b12 100644
--- a/app/views/boards/_course_show.html.erb
+++ b/app/views/boards/_course_show.html.erb
@@ -39,7 +39,7 @@
<%= link_to author, user_path(topic.author), :class =>"talkmain_name fl " %>
<%= h(topic.subject) %>
- <% if topic.editable_by?(User.current) %>
+ <% if topic.course_editable_by?(User.current) %>
<%= l(:button_edit) %>
<% end %>
@@ -75,7 +75,7 @@
-
+
<%= render :partial => 'edit',locals: {:topic => topic} %>
diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb
index 15237756a..150acbabd 100644
--- a/app/views/boards/_project_show.html.erb
+++ b/app/views/boards/_project_show.html.erb
@@ -82,7 +82,7 @@
-
+
<%= render :partial => 'edit',locals: {:topic => topic} %>
diff --git a/app/views/layouts/_base_development_group.html.erb b/app/views/layouts/_base_development_group.html.erb
index 24f975f66..7a5cd6c57 100644
--- a/app/views/layouts/_base_development_group.html.erb
+++ b/app/views/layouts/_base_development_group.html.erb
@@ -23,7 +23,7 @@
(<%= @project.boards.first.topics.count %>)
<% end %>
<% if User.current.member_of?(@project) %>
- <%= link_to "+"+l(:project_module_boards_post), new_board_message_path(@project.boards.first), :layout => 'base_projects', :class => "subnav_green ml105" %>
+ <%= link_to "+"+l(:project_module_boards_post), project_boards_path(@project, :flag => true), :layout => 'base_projects', :class => "subnav_green ml105" %>
<% end %>
<% end%>
diff --git a/app/views/layouts/_base_friend_group.html.erb b/app/views/layouts/_base_friend_group.html.erb
index 16ccc09e5..71d375501 100644
--- a/app/views/layouts/_base_friend_group.html.erb
+++ b/app/views/layouts/_base_friend_group.html.erb
@@ -12,7 +12,7 @@
(<%= @project.boards.first.topics.count %>)
<% end %>
<% if User.current.member_of?(@project) %>
- <%= link_to "+"+l(:project_module_boards_post), new_board_message_path(@project.boards.first), :layout => 'base_projects', :class => "subnav_green ml105" %>
+ <%= link_to "+"+l(:project_module_boards_post), project_boards_path(@project, :flag => true), :layout => 'base_projects', :class => "subnav_green ml105" %>
<% end %>
<% end%>
diff --git a/app/views/layouts/_base_research_team.html.erb b/app/views/layouts/_base_research_team.html.erb
index a214e8c20..f228f0439 100644
--- a/app/views/layouts/_base_research_team.html.erb
+++ b/app/views/layouts/_base_research_team.html.erb
@@ -23,7 +23,7 @@
(<%= @project.boards.first.topics.count %>)
<% end %>
<% if User.current.member_of?(@project) %>
- <%= link_to "+"+l(:project_module_boards_post), new_board_message_path(@project.boards.first), :layout => 'base_projects', :class => "subnav_green ml105" %>
+ <%= link_to "+"+l(:project_module_boards_post), project_boards_path(@project, :flag => true), :layout => 'base_projects', :class => "subnav_green ml105" %>
<% end %>
<% end%>
diff --git a/app/views/layouts/base_courses.html.erb b/app/views/layouts/base_courses.html.erb
index 2a26ff59f..6923b17c2 100644
--- a/app/views/layouts/base_courses.html.erb
+++ b/app/views/layouts/base_courses.html.erb
@@ -133,7 +133,7 @@
<%= link_to l(:label_course_board), course_boards_path(@course), :class => "f14 c_blue02" %>
<%= link_to "(#{@course.boards.first ? @course.boards.first.topics.count : 0})", course_boards_path(@course), :class => "subnav_num c_orange" %>
- <%= link_to( "+#{l(:label_message_new)}", new_board_message_path(@course.boards.first), :class => 'subnav_green ml95 c_white') if User.current.member_of_course?(@course) && @course.boards.first %>
+ <%= link_to( "+#{l(:label_message_new)}",course_boards_path(@course, :flag => true),:class => 'subnav_green ml95 c_white') if User.current.member_of_course?(@course) && @course.boards.first %>
<%= link_to l(:label_course_feedback), course_feedback_path(@course), :class => "f14 c_blue02" %>
From 8e61136d7fffb89f226afc5fda28aaf00cd1ba41 Mon Sep 17 00:00:00 2001
From: alan <547533434@qq.com>
Date: Mon, 11 May 2015 17:23:53 +0800
Subject: [PATCH 6/9] Signed-off-by: alan <547533434@qq.com>
---
app/controllers/messages_controller.rb | 46 +++++++++++++++++++++-----
app/views/boards/_course_show.html.erb | 24 +++++++++-----
2 files changed, 52 insertions(+), 18 deletions(-)
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index 431577f9a..666ee9c17 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -93,7 +93,15 @@ class MessagesController < ApplicationController
end
call_hook(:controller_messages_new_after_save, { :params => params, :message => @message})
render_attachment_warning_if_needed(@message)
- redirect_to board_message_url(@board, @message)
+ if params[:is_board]
+ if @project
+ redirect_to project_boards_path(@project)
+ elsif @course
+ redirect_to course_boards_path(@course)
+ end
+ else
+ redirect_to board_message_url(@board, @message)
+ end
else
layout_file = @project ? 'base_projects' : 'base_courses'
render :action => 'new', :layout => layout_file
@@ -132,7 +140,15 @@ class MessagesController < ApplicationController
else
#render file: 'messages#show', layout: 'base_courses'
end
- redirect_to board_message_url(@board, @topic, :r => @reply)
+ if params[:is_board]
+ if @project
+ redirect_to project_boards_path(@project)
+ elsif @course
+ redirect_to course_boards_path(@course)
+ end
+ else
+ redirect_to board_message_url(@board, @topic, :r => @reply)
+ end
end
@@ -150,7 +166,15 @@ class MessagesController < ApplicationController
render_attachment_warning_if_needed(@message)
flash[:notice] = l(:notice_successful_update)
@message.reload
- redirect_to board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id))
+ if params[:is_board]
+ if @project
+ redirect_to project_boards_path(@project)
+ elsif @course
+ redirect_to course_boards_path(@course)
+ end
+ else
+ redirect_to board_message_url(@message.board, @message.root, :r => (@message.parent_id && @message.id))
+ end
elsif request.get?
respond_to do |format|
format.html {
@@ -172,16 +196,20 @@ class MessagesController < ApplicationController
@message.destroy
# modify by nwb
if @project
- if @message.parent
- redirect_to board_message_url(@board, @message.parent, :r => r)
- else
+ if params[:is_board]
redirect_to project_boards_url(@project)
+ else
+ redirect_to board_message_url(@board, @topic, :r => @reply)
end
elsif @course
- if @message.parent
- redirect_to board_message_url(@board, @message.parent, :r => r)
+ if params[:is_board]
+ redirect_to course_boards_url(@course)
else
- redirect_to course_board_url(@course, @board)
+ if @message.parent
+ redirect_to board_message_url(@board, @message.parent, :r => r)
+ else
+ redirect_to course_board_url(@course, @board)
+ end
end
end
end
diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb
index 3962a5b12..ce3dd2091 100644
--- a/app/views/boards/_course_show.html.erb
+++ b/app/views/boards/_course_show.html.erb
@@ -38,7 +38,7 @@
<% author = topic.author.to_s + ":" %>
<%= link_to author, user_path(topic.author), :class =>"talkmain_name fl " %>
-
<%= h(topic.subject) %>
+
<%= h(topic.subject) %>
<% if topic.course_editable_by?(User.current) %>
<%= l(:button_edit) %>
@@ -56,24 +56,30 @@
) if topic.destroyable_by?(User.current) %>
-
- <% if topic.content.size > 300 %>
-
-
+
+
+
<%= topic.content %>
-
-
+
+ <% if topic.content.size > 300 %>
+
+
-
- <% end %>
+
+
+ <% end %>
<%= link_to_attachments_course topic, :author => false %>
+
<%= l(:label_activity_time)%>: <%= format_time topic.created_on %>
+
<%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => 'message_content',:class => ' c_dblue fr' %>
+
+
From 877384280185c4733b3a0825e64a8acb213a2f1d Mon Sep 17 00:00:00 2001
From: alan <547533434@qq.com>
Date: Mon, 11 May 2015 17:35:36 +0800
Subject: [PATCH 7/9] Signed-off-by: alan <547533434@qq.com>
---
app/controllers/messages_controller.rb | 38 ++++++++++++++++++++++----
1 file changed, 32 insertions(+), 6 deletions(-)
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index 666ee9c17..1e4f19acb 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -103,8 +103,17 @@ class MessagesController < ApplicationController
redirect_to board_message_url(@board, @message)
end
else
- layout_file = @project ? 'base_projects' : 'base_courses'
- render :action => 'new', :layout => layout_file
+ if params[:is_board]
+ if @project
+ redirect_to project_boards_path(@project, :flag => true)
+ elsif @course
+ redirect_to course_boards_path(@course, :flag => true)
+ end
+ else
+ layout_file = @project ? 'base_projects' : 'base_courses'
+ render :action => 'new', :layout => layout_file
+ end
+
end
else
respond_to do |format|
@@ -119,7 +128,15 @@ class MessagesController < ApplicationController
# Reply to a topic
def reply
if params[:reply][:content] == ""
- (redirect_to board_message_url(@board, @topic, :r => @reply), :notice => l(:label_reply_empty);return)
+ if params[:is_board]
+ if @project
+ (redirect_to project_boards_path(@project), :notice => l(:label_reply_empty);return)
+ elsif @course
+ (redirect_to course_boards_path(@course), :notice => l(:label_reply_empty);return)
+ end
+ else
+ (redirect_to board_message_url(@board, @topic, :r => @reply), :notice => l(:label_reply_empty);return)
+ end
end
@quote = params[:quote][:quote]
@reply = Message.new
@@ -155,11 +172,20 @@ class MessagesController < ApplicationController
# Edit a message
def edit
@isReply = false
- if @project
- (render_403; return false) unless @message.editable_by?(User.current)
+ if params[:is_board]
+ if @project
+ (redirect_to project_boards_path(@project); return false)
+ elsif @course
+ (redirect_to course_boards_path(@course); return false)
+ end
else
- (render_403; return false) unless @message.course_editable_by?(User.current)
+ if @project
+ (render_403; return false) unless @message.editable_by?(User.current)
+ else
+ (render_403; return false) unless @message.course_editable_by?(User.current)
+ end
end
+
@message.safe_attributes = params[:message]
if request.post? && @message.save
attachments = Attachment.attach_files(@message, params[:attachments])
From 29114e19f3c5a2afbcc8e12d0ce875375f92dcdd Mon Sep 17 00:00:00 2001
From: alan <547533434@qq.com>
Date: Tue, 12 May 2015 15:15:04 +0800
Subject: [PATCH 8/9] Signed-off-by: alan <547533434@qq.com>
---
Gemfile | 2 +-
app/views/boards/_course_new.html.erb | 2 +-
app/views/boards/_form_course.html.erb | 2 +-
app/views/boards/_form_project.html.erb | 2 +-
app/views/boards/_project_new_topic.html.erb | 3 ++-
5 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/Gemfile b/Gemfile
index 0aa77ae99..810190a6a 100644
--- a/Gemfile
+++ b/Gemfile
@@ -24,7 +24,7 @@ gem 'acts-as-taggable-on', '2.4.1'
gem 'spreadsheet'
gem 'ruby-ole'
gem 'rails_kindeditor',path:'lib/rails_kindeditor'
-gem "rmagick", ">= 2.0.0"
+#gem "rmagick", ">= 2.0.0"
group :development do
gem 'grape-swagger'
diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb
index e80ce8135..fba80127b 100644
--- a/app/views/boards/_course_new.html.erb
+++ b/app/views/boards/_course_new.html.erb
@@ -2,7 +2,7 @@
<%= render :partial => 'form_course', :locals => {:f => f, :topic => @message} %>
-
- <%= link_to l(:button_cancel), course_boards_path(@course), :class => 'grey_btn fr ml10' %>
+ <%= l(:button_cancel) %>
<%= l(:button_submit)%>
diff --git a/app/views/boards/_form_course.html.erb b/app/views/boards/_form_course.html.erb
index 5cd2d8a2f..09ee1c3b4 100644
--- a/app/views/boards/_form_course.html.erb
+++ b/app/views/boards/_form_course.html.erb
@@ -51,7 +51,7 @@
-
<% unless replying %>
- <%= render :partial => 'attachments/form_course', :locals => {:container => @message,:isReply => @isReply} %>
+ <%= render :partial => 'attachments/form_course', :locals => {:container => topic,:isReply => @isReply} %>
<% end %>
diff --git a/app/views/boards/_form_project.html.erb b/app/views/boards/_form_project.html.erb
index 4e0ffe8e7..b42cabbeb 100644
--- a/app/views/boards/_form_project.html.erb
+++ b/app/views/boards/_form_project.html.erb
@@ -51,7 +51,7 @@
-
<% unless replying %>
- <%= render :partial => 'attachments/form_project', :locals => {:container => topic,:isReply => true} %>
+ <%= render :partial => 'attachments/form_project', :locals => {:container => @message,:isReply => @isReply} %>
<% end %>
diff --git a/app/views/boards/_project_new_topic.html.erb b/app/views/boards/_project_new_topic.html.erb
index 2207c4b10..3f7c569e1 100644
--- a/app/views/boards/_project_new_topic.html.erb
+++ b/app/views/boards/_project_new_topic.html.erb
@@ -2,7 +2,8 @@
<%= render :partial => 'form_project', :locals => {:f => f, :topic => @message} %>
-
- <%= link_to l(:button_cancel), project_boards_path(@project), :class => 'grey_btn fr ml10' %>
+ <%= l(:button_cancel) %>
+
<%= l(:button_submit)%>
From fe92b050264633898d1bed919821f6e361d3e443 Mon Sep 17 00:00:00 2001
From: alan <547533434@qq.com>
Date: Tue, 12 May 2015 17:14:07 +0800
Subject: [PATCH 9/9] =?UTF-8?q?=E8=AE=A8=E8=AE=BA=E5=8C=BA=E7=BC=96?=
=?UTF-8?q?=E8=BE=91=E6=B7=BB=E5=8A=A0=E9=99=84=E4=BB=B6=20Signed-off-by:?=
=?UTF-8?q?=20alan=20<547533434@qq.com>?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Gemfile | 2 +-
app/controllers/messages_controller.rb | 14 +---
app/views/attachments/_form_course.html.erb | 8 +--
app/views/attachments/_form_project.html.erb | 8 +--
app/views/boards/_edit.html.erb | 2 +-
app/views/boards/_form_project.html.erb | 2 +-
public/javascripts/attachments.js | 75 +++++++++++++++++++-
public/stylesheets/courses.css | 21 +++++-
public/stylesheets/project.css | 18 ++++-
9 files changed, 121 insertions(+), 29 deletions(-)
diff --git a/Gemfile b/Gemfile
index 810190a6a..0aa77ae99 100644
--- a/Gemfile
+++ b/Gemfile
@@ -24,7 +24,7 @@ gem 'acts-as-taggable-on', '2.4.1'
gem 'spreadsheet'
gem 'ruby-ole'
gem 'rails_kindeditor',path:'lib/rails_kindeditor'
-#gem "rmagick", ">= 2.0.0"
+gem "rmagick", ">= 2.0.0"
group :development do
gem 'grape-swagger'
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index 1e4f19acb..6e2da4bb0 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -172,18 +172,10 @@ class MessagesController < ApplicationController
# Edit a message
def edit
@isReply = false
- if params[:is_board]
- if @project
- (redirect_to project_boards_path(@project); return false)
- elsif @course
- (redirect_to course_boards_path(@course); return false)
- end
+ if @project
+ (render_403; return false) unless @message.editable_by?(User.current)
else
- if @project
- (render_403; return false) unless @message.editable_by?(User.current)
- else
- (render_403; return false) unless @message.course_editable_by?(User.current)
- end
+ (render_403; return false) unless @message.course_editable_by?(User.current)
end
@message.safe_attributes = params[:message]
diff --git a/app/views/attachments/_form_course.html.erb b/app/views/attachments/_form_course.html.erb
index 1e81aaf65..7b07426aa 100644
--- a/app/views/attachments/_form_course.html.erb
+++ b/app/views/attachments/_form_course.html.erb
@@ -1,4 +1,4 @@
-
+
<% if defined?(container) && container && container.saved_attachments %>
<% if isReply %>
<% container.saved_attachments.each_with_index do |attachment, i| %>
@@ -38,12 +38,12 @@
<%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
-<%= button_tag "#{l(:button_browse)}", :type=>"button", :onclick=>"_file.click()",:class =>"sub_btn",:style => ie8? ? 'display:none' : '' %>
+<%= button_tag "#{l(:button_browse)}", :type=>"button", :onclick=>"file#{container.id}.click()",:class =>"sub_btn",:style => ie8? ? 'display:none' : '' %>
<%= file_field_tag 'attachments[dummy][file]',
- :id => '_file',
+ :id => "file#{container.id}",
:class => 'file_selector',
:multiple => true,
- :onchange => 'addInputFiles(this);',
+ :onchange => "addInputFiles_board(this, '#{container.id}');",
:style => 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
diff --git a/app/views/attachments/_form_project.html.erb b/app/views/attachments/_form_project.html.erb
index 9778d3242..66d9a0e80 100644
--- a/app/views/attachments/_form_project.html.erb
+++ b/app/views/attachments/_form_project.html.erb
@@ -1,4 +1,4 @@
-
+
<% if defined?(container) && container && container.saved_attachments %>
<% if isReply %>
<% container.saved_attachments.each_with_index do |attachment, i| %>
@@ -38,12 +38,12 @@
<%#= button_tag "浏览", :type=>"button", :onclick=>"CompatibleSend();" %>
- <%= button_tag "文件浏览", :type=>"button", :onclick=>"_file.click()", :class =>"sub_btn",:style => ie8? ? 'display:none' : '' %>
+ <%= button_tag "文件浏览", :type=>"button", :onclick=>"file#{container.id}.click()", :class =>"sub_btn",:style => ie8? ? 'display:none' : '' %>
<%= file_field_tag 'attachments[dummy][file]',
- :id => '_file',
+ :id => "file#{container.id}",
:class => 'file_selector',
:multiple => true,
- :onchange => 'addInputFiles(this);',
+ :onchange => "addInputFiles_board(this, '#{container.id}');",
:style => 'display:none',
:data => {
:max_file_size => Setting.attachment_max_size.to_i.kilobytes,
diff --git a/app/views/boards/_edit.html.erb b/app/views/boards/_edit.html.erb
index a4b2aff73..15358c03a 100644
--- a/app/views/boards/_edit.html.erb
+++ b/app/views/boards/_edit.html.erb
@@ -12,7 +12,7 @@
} do |f| %>
<%= render :partial => 'form_project',
:locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %>
- <%= l(:button_submit)%>
+ <%= l(:button_submit)%>
<%= l(:button_cancel) %>
<%#= link_to l(:button_cancel), board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "blue_btn grey_btn fl c_white" %>
diff --git a/app/views/boards/_form_project.html.erb b/app/views/boards/_form_project.html.erb
index b42cabbeb..3ecffa3e2 100644
--- a/app/views/boards/_form_project.html.erb
+++ b/app/views/boards/_form_project.html.erb
@@ -51,7 +51,7 @@
<% unless replying %>
- <%= render :partial => 'attachments/form_project', :locals => {:container => @message,:isReply => @isReply} %>
+ <%= render :partial => 'attachments/form_project', :locals => {:container => topic,:isReply => @isReply} %>
<% end %>
diff --git a/public/javascripts/attachments.js b/public/javascripts/attachments.js
index 2c10d28e4..6eb73182d 100644
--- a/public/javascripts/attachments.js
+++ b/public/javascripts/attachments.js
@@ -23,9 +23,10 @@ function reload(fileSpan) {
}
-function addFile(inputEl, file, eagerUpload) {
+function addFile_board(inputEl, file, eagerUpload, id) {
- if ($('#attachments_fields').children().length < 30) {
+ var attachments_frame = '#attachments_fields' + id;
+ if ($(attachments_frame).children().length < 30) {
deleteallfiles = $(inputEl).data('deleteAllFiles');
var attachmentId = addFile.nextAttachmentId++;
@@ -48,7 +49,7 @@ function addFile(inputEl, file, eagerUpload) {
}).toggle(!eagerUpload),
$('
', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} )
- ).appendTo('#attachments_fields');
+ ).appendTo(attachments_frame);
if(eagerUpload) {
ajaxUpload(file, attachmentId, fileSpan, inputEl);
@@ -58,7 +59,42 @@ function addFile(inputEl, file, eagerUpload) {
}
return null;
}
+function addFile(inputEl, file, eagerUpload) {
+ var attachments_frame = '#attachments_fields';
+ if ($(attachments_frame).children().length < 30) {
+ deleteallfiles = $(inputEl).data('deleteAllFiles');
+ var attachmentId = addFile.nextAttachmentId++;
+
+ var fileSpan = $('
', { 'id': 'attachments_' + attachmentId, 'class':'attachment' });
+
+ fileSpan.append(
+ $('', { 'type': 'text', 'class': 'filename readonly', 'name': 'attachments[' + attachmentId + '][filename]', 'readonly': 'readonly'} ).val(file.name),
+ $('', { 'type': 'text', 'class': 'description', 'name': 'attachments[' + attachmentId + '][description]', 'maxlength': 254, 'placeholder': $(inputEl).data('descriptionPlaceholder') } ).toggle(!eagerUpload),
+ $(''+$(inputEl).data('fieldIsPublic')+':').attr({ 'class': 'ispublic-label' }) ,
+ $('', { 'type': 'checkbox', 'class': 'is_public_checkbox','value':1, 'name': 'attachments[' + attachmentId + '][is_public_checkbox]', checked:'checked' } ).toggle(!eagerUpload),
+ $(' ').attr({ 'href': "#", 'class': 'remove-upload' }).click(function(){
+ if(confirm($(inputEl).data('areYouSure'))){
+ removeFile();
+ if(!eagerUpload){
+ (function(e){
+ reload(e);
+ })(fileSpan);
+ }
+ }
+
+ }).toggle(!eagerUpload),
+ $('', { 'class': 'div_attachments', 'name': 'div_'+'attachments_' + attachmentId} )
+ ).appendTo('#attachments_fields');
+
+ if(eagerUpload) {
+ ajaxUpload(file, attachmentId, fileSpan, inputEl);
+
+ }
+ return attachmentId;
+ }
+ return null;
+}
addFile.nextAttachmentId = 1;
function ajaxUpload(file, attachmentId, fileSpan, inputEl) {
@@ -202,7 +238,26 @@ function addInputFiles(inputEl) {
//clearedFileInput.insertAfter('#attachments_fields');
}
+function addInputFiles_board(inputEl, id) {
+ // var clearedFileInput = $(inputEl).clone().val('');
+ if (inputEl.files) {
+ // upload files using ajax
+ uploadAndAttachFiles_board(inputEl.files, inputEl, id);
+ // $(inputEl).remove();
+ } else {
+ // browser not supporting the file API, upload on form submission
+ var attachmentId;
+ var aFilename = inputEl.value.split(/\/|\\/);
+ attachmentId = addFile_board(inputEl, { name: aFilename[ aFilename.length - 1 ] }, false, id);
+ if (attachmentId) {
+ $(inputEl).attr({ name: 'attachments[' + attachmentId + '][file]'}).hide();
+ $('#upload_file_count').html(""+count+""+$(inputEl).data('fileCount'));
+ }
+ }
+
+ //clearedFileInput.insertAfter('#attachments_fields');
+}
function uploadAndAttachFiles(files, inputEl) {
var maxFileSize = $(inputEl).data('max-file-size');
@@ -218,7 +273,21 @@ function uploadAndAttachFiles(files, inputEl) {
$.each(files, function() {addFile(inputEl, this, true);});
}
}
+function uploadAndAttachFiles_board(files, inputEl, id) {
+ var maxFileSize = $(inputEl).data('max-file-size');
+ var maxFileSizeExceeded = $(inputEl).data('max-file-size-message');
+
+ var sizeExceeded = false;
+ $.each(files, function() {
+ if (this.size && maxFileSize != null && this.size > parseInt(maxFileSize)) {sizeExceeded=true;}
+ });
+ if (sizeExceeded) {
+ window.alert(maxFileSizeExceeded);
+ } else {
+ $.each(files, function() {addFile_board(inputEl, this, true, id);});
+ }
+}
function handleFileDropEvent(e) {
$(this).removeClass('fileover');
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css
index f49ef22f1..132cddadc 100644
--- a/public/stylesheets/courses.css
+++ b/public/stylesheets/courses.css
@@ -83,8 +83,8 @@ a:hover.talk_edit{ color:#ff5722;}
.talkpage_text{ border:1px solid #64bdd9; width:600px; color:#7d7d7d; padding:5px; margin:10px 0 10px 50px; background:#fff;}
/****新建讨论***/
.talk_new{ color:#4c4c4c;}
-.talk_input{ border:1px solid #64bdd9; height:16px; width:585px; background:#fff; margin-bottom:10px; padding:5px;}
-.talk_text{ border:1px solid #64bdd9; height:100px;width:585px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;}
+.talk_input{ border:1px solid #64bdd9; height:16px; width:550px; background:#fff; margin-bottom:10px; padding:5px;}
+.talk_text{ border:1px solid #64bdd9; height:100px;width:550px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;}
.talk_new ul li{ }
.sb{width:70px; height:26px; color:#606060; cursor:pointer;}
a.blue_btn{ background:#64bdd9; display:block; font-size:14px;color:#fff; font-weight:normal; text-align:center; margin-left:10px; margin-bottom:10px; padding:2px 10px;}
@@ -364,6 +364,23 @@ span.add_attachment {font-size: 80%;line-height: 2.5em;}
.reply_btn:hover{ background:#999; color:#fff; }
#attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; }
+
+.attachments_fields input.description {margin-left:4px; width:100px; }
+.attachments_fields span .boldSpan{display:block; white-space:nowrap; font-family:'微软雅黑';}
+.attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; }
+a.remove-upload:hover {text-decoration:none !important;}
+.attachments_fields input.is_public_checkbox {width:20px;}
+
+
+.attachments_fields span.ispublic-label {display: inline-block;width: 30px;margin-left: 10px;}
+a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%;width: 1px;display: inline-block;padding-left: 16px;}
+.attachments_fields input.filename {border: 0;height: 1.8em;width: 150px;color: #555;background-color: inherit;background: url(../images/attachment.png) no-repeat 1px 50%;padding-left: 18px;padding-top: 2px;}
+span.add_attachment {font-size: 80%;line-height: 2.5em;}
+.attachments_fields span {display: block;white-space: nowrap;}
+.file_selector{position: relative;opacity: 0;filter: alpha(opacity:0);}
+.attachments_fields .ajax-waiting input.filename {background:url(../images/hourglass.png) no-repeat 0px 50%;}
+.attachments_fields .ajax-loading input.filename {background:url(../images/loading.gif) no-repeat 0px 50%;}
+
.ui-widget {
font-family: Verdana, sans-serif;
font-size: 1.1em;
diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css
index 98194b73c..14a7a9a34 100644
--- a/public/stylesheets/project.css
+++ b/public/stylesheets/project.css
@@ -123,8 +123,8 @@ a:hover.talk_edit{ color:#ff5722;}
.recall_con{ float:left;color:#777777; width:520px; margin-left:10px; }
/****新建讨论***/
.talk_new{ color:#4c4c4c;}
-.talk_input{ border:1px solid #64bdd9; height:16px; width:585px; background:#fff; margin-bottom:10px; padding:5px;}
-.talk_text{ border:1px solid #64bdd9; height:100px;width:585px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;}
+.talk_input{ border:1px solid #64bdd9; height:16px; width:550px; background:#fff; margin-bottom:10px; padding:5px;}
+.talk_text{ border:1px solid #64bdd9; height:100px;width:550px; background:#fff; margin-left:5px; padding:5px; margin-bottom:10px;}
.talk_new ul li{ }
.sb{width:70px; height:26px; color:#606060; cursor:pointer;}
/*a.blue_btn{ background:#64bdd9; display:block; font-size:14px;color:#fff; font-weight:normal; text-align:center; margin-left:10px; margin-bottom:10px; padding:2px 10px;}*/
@@ -254,8 +254,22 @@ span.add_attachment {font-size: 80%;line-height: 2.5em;}
.reply_btn{ cursor:pointer; -moz-border-radius:3px; -webkit-border-radius:3px; border:1px solid #ccc; color:#999; border-radius:3px; padding:2px 10px; margin-bottom:10px;display: block;margin-left: 470px;}
.reply_btn:hover{ background:#999; color:#fff; }
+.attachments_fields input.description {margin-left:4px; width:100px; }
+.attachments_fields span .boldSpan{display:block; white-space:nowrap; font-family:'微软雅黑';}
+.attachments_fields div.ui-progressbar { width: 100px; height:14px; margin: 2px 0 -5px 8px; display: inline-block; }
+a.remove-upload:hover {text-decoration:none !important;}
+.attachments_fields input.is_public_checkbox {width:20px;}
+.attachments_fields span.ispublic-label {display: inline-block;width: 30px;margin-left: 10px;}
+a.remove-upload {background: url(../images/delete.png) no-repeat 1px 50%;width: 1px;display: inline-block;padding-left: 16px;}
+.attachments_fields input.filename {border: 0;height: 1.8em;width: 150px;color: #555;background-color: inherit;background: url(../images/attachment.png) no-repeat 1px 50%;padding-left: 18px;padding-top: 2px;}
+span.add_attachment {font-size: 80%;line-height: 2.5em;}
+.attachments_fields span {display: block;white-space: nowrap;}
+.file_selector{position: relative;opacity: 0;filter: alpha(opacity:0);}
+.attachments_fields .ajax-waiting input.filename {background:url(../images/hourglass.png) no-repeat 0px 50%;}
+.attachments_fields .ajax-loading input.filename {background:url(../images/loading.gif) no-repeat 0px 50%;}
+
.ui-widget {
font-family: Verdana, sans-serif;
font-size: 1.1em;