<%#= calendar_for('attachment_publish_time')%>
From 97d07134a5458ae918d83625f29e2e69daf34bad Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 21 Jun 2016 16:20:07 +0800
Subject: [PATCH 05/51] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=8A=E4=BC=A0?=
=?UTF-8?q?=E8=B5=84=E6=BA=90=E5=90=8D=E8=BF=87=E9=95=BF=E9=80=A0=E6=88=90?=
=?UTF-8?q?=E6=BA=A2=E5=87=BA=E6=A1=86=E6=9E=B6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/files/_resource_detail.html.erb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/views/files/_resource_detail.html.erb b/app/views/files/_resource_detail.html.erb
index 1c4c3a387..28f04b922 100644
--- a/app/views/files/_resource_detail.html.erb
+++ b/app/views/files/_resource_detail.html.erb
@@ -8,11 +8,11 @@
<%# 如果有历史版本则提供历史版本下载 %>
<% if file.attachment_histories.count == 0 %>
- <%= link_to truncate(file.filename,length: file.filename.length, omission: '...'),
+ <%= link_to truncate(file.filename,length: 40, omission: '...'),
download_named_attachment_path(file.id, file.filename),
:title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "linkGrey3 f_14" %>
<% else %>
- <%= link_to truncate(file.filename,length: file.filename.length, omission: '...'), attachment_history_download_path(file.id),
+ <%= link_to truncate(file.filename,length: 40, omission: '...'), attachment_history_download_path(file.id),
:title => file.filename+"\n"+file.description.to_s,
:class => "linkGrey3 f_14",
:style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;", :remote=>true %>
From ad3626d53a999fddf2b7437e7d66c4296f0175e2 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Mon, 27 Jun 2016 15:36:31 +0800
Subject: [PATCH 06/51] =?UTF-8?q?=E5=B0=86=E6=90=9C=E7=B4=A2=E9=A1=B5?=
=?UTF-8?q?=E9=9D=A2=EF=BC=9A=E2=80=9C=E7=99=BB=E9=99=86=E2=80=9D=E6=94=B9?=
=?UTF-8?q?=E4=B8=BA=E2=80=9C=E7=99=BB=E5=BD=95=E2=80=9D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/welcome/_search_all_results.html.erb | 2 +-
app/views/welcome/_search_user_results.html.erb | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/views/welcome/_search_all_results.html.erb b/app/views/welcome/_search_all_results.html.erb
index a714f53d2..af407c848 100644
--- a/app/views/welcome/_search_all_results.html.erb
+++ b/app/views/welcome/_search_all_results.html.erb
@@ -19,7 +19,7 @@
<%= User.find(item.id).user_extensions && User.find(item.id).user_extensions.brief_introduction.present? ? User.find(item.id).user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%>
加入时间:<%= format_date( User.find(item.id).created_on)%>
- 最后登陆时间:<%= format_date( User.find(item.id).last_login_on)%>
+ 最后登录时间:<%= format_date( User.find(item.id).last_login_on)%>
<%= User.find(item.id).user_extensions.occupation.present? ? '单位:'+User.find(item.id).user_extensions.occupation : ''%>
diff --git a/app/views/welcome/_search_user_results.html.erb b/app/views/welcome/_search_user_results.html.erb
index d1c8c2393..06a40d021 100644
--- a/app/views/welcome/_search_user_results.html.erb
+++ b/app/views/welcome/_search_user_results.html.erb
@@ -13,7 +13,7 @@
<%= User.find(user.id).user_extensions && User.find(user.id).user_extensions.brief_introduction.present? ? User.find(user.id).user_extensions.brief_introduction : '这位童鞋很懒,什么也没有留下~'%>
加入时间:<%= format_date( User.find(user.id).created_on)%>
- 最后登陆时间:<%= format_date( User.find(user.id).last_login_on)%>
+ 最后登录时间:<%= format_date( User.find(user.id).last_login_on)%>
<%= User.find(user.id).user_extensions.occupation.present? ? '单位:'+User.find(user.id).user_extensions.occupation : ''%>
From 863cdee37c9f26562b62a887fa055be58f72cc90 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 28 Jun 2016 14:39:43 +0800
Subject: [PATCH 07/51] =?UTF-8?q?=E5=9C=A8=E7=B2=BE=E5=93=81=E8=AF=BE?=
=?UTF-8?q?=E7=A8=8B=E7=9A=84=E5=85=A8=E9=83=A8=E8=AF=BE=E7=A8=8B=E7=95=8C?=
=?UTF-8?q?=E9=9D=A2=E4=B8=8B=E5=A2=9E=E5=8A=A0=E5=85=AC=E5=BC=80=E5=B1=9E?=
=?UTF-8?q?=E6=80=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/admin/_course_detail_tr.html.erb | 3 +++
app/views/admin/excellent_all_courses.html.erb | 17 ++++++++++-------
2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/app/views/admin/_course_detail_tr.html.erb b/app/views/admin/_course_detail_tr.html.erb
index ca15a6696..4de9cb001 100644
--- a/app/views/admin/_course_detail_tr.html.erb
+++ b/app/views/admin/_course_detail_tr.html.erb
@@ -6,6 +6,9 @@
<%= link_to(course.name, course_path(course.id)) %>
+
+ <%= checked_image course.is_public? %>
+
<%= link_to(course.try(:teacher).try(:realname).truncate(6, omission: '...'), user_path(course.teacher)) %>
diff --git a/app/views/admin/excellent_all_courses.html.erb b/app/views/admin/excellent_all_courses.html.erb
index 86e4556f9..8c7f246fc 100644
--- a/app/views/admin/excellent_all_courses.html.erb
+++ b/app/views/admin/excellent_all_courses.html.erb
@@ -27,28 +27,31 @@
序号
-
+
课程名
-
+
+ 公开
+
+
主讲老师
学生数
-
+
作业数
-
+
作品数
-
+
资源数
-
+
帖子数
-
+
<%=link_to '动态数', excellent_all_courses_path(:order=> @order == "desc" ? 'asc' : 'desc') %>
From d8284e45eda042ab58fc669c0a5142da88322e84 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Tue, 28 Jun 2016 15:06:08 +0800
Subject: [PATCH 08/51] =?UTF-8?q?=E5=9C=A8=E8=AF=BE=E7=A8=8B=E5=88=97?=
=?UTF-8?q?=E8=A1=A8=E4=B8=8B=E5=A2=9E=E5=8A=A0=E5=8A=A8=E6=80=81=E6=97=B6?=
=?UTF-8?q?=E9=97=B4=E4=B8=80=E6=A0=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/admin/courses.html.erb | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/app/views/admin/courses.html.erb b/app/views/admin/courses.html.erb
index 8e2f146a0..65e442a3e 100644
--- a/app/views/admin/courses.html.erb
+++ b/app/views/admin/courses.html.erb
@@ -25,10 +25,10 @@
序号
-
+
课程
-
+
主讲老师
@@ -37,9 +37,12 @@
<%=l(:field_is_public)%>
-
+
<%=l(:field_created_on)%>
+
+ 动态时间
+
@@ -65,6 +68,9 @@
<%= format_date(course.created_at) %>
+
+ <%= course.updated_at.strftime('%Y-%m-%d %H:%M:%S') %>
+
<% end %>
From 2eb7aa7c38432da53d76d3c0037e12a88317b02d Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Thu, 30 Jun 2016 11:32:14 +0800
Subject: [PATCH 09/51] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=B2=BE=E5=93=81?=
=?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=B8=8B-=E5=85=A8=E9=83=A8=E8=AF=BE?=
=?UTF-8?q?=E7=A8=8B=E4=B8=8B=20=E9=99=A4=E5=BA=8F=E5=88=97=E3=80=81?=
=?UTF-8?q?=E4=B8=BB=E8=AE=B2=E8=80=81=E5=B8=88=E5=92=8C=E8=AF=BE=E7=A8=8B?=
=?UTF-8?q?=E5=90=8D=E5=A4=96=E7=9A=84=E6=89=80=E6=9C=89=E5=88=97=E8=BF=9B?=
=?UTF-8?q?=E8=A1=8C=E6=8E=92=E5=BA=8F=EF=BC=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/admin_controller.rb | 34 ++++++++++++++++++-
app/views/admin/_course_detail_tr.html.erb | 2 +-
.../admin/excellent_all_courses.html.erb | 28 +++++++--------
3 files changed, 48 insertions(+), 16 deletions(-)
diff --git a/app/controllers/admin_controller.rb b/app/controllers/admin_controller.rb
index 4014a91bd..2e3612b94 100644
--- a/app/controllers/admin_controller.rb
+++ b/app/controllers/admin_controller.rb
@@ -72,10 +72,42 @@ class AdminController < ApplicationController
courses = Course.find_by_sql("SELECT c.*,count(c.id) FROM courses c,course_activities ca WHERE c.id = ca.course_id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count(c.id) #{params[:sort]}, c.id desc")
@order = params[:order]
@sort = params[:sort]
+
elsif params[:sort] && (params[:order] == 'time')
- courses = Course.find_by_sql("SELECT * FROM courses WHERE name like '%#{name}%' ORDER BY time #{params[:sort]},id desc")
+ courses = Course.find_by_sql("SELECT * FROM courses WHERE name like '%#{name}%' ORDER BY time #{params[:sort]}, id desc")
+ @order = params[:order]
+ @sort = params[:sort]
+
+ elsif params[:sort] && (params[:order] == 'post')
+ courses = Course.find_by_sql("SELECT c.*, count(m.id) count FROM boards b, courses c, messages m WHERE m.board_id = b.id AND b.course_id = c.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY count #{params[:sort]}, c.id desc")
+ @order = params[:order]
+ @sort = params[:sort]
+
+ elsif params[:sort] && (params[:order] == 'res')
+ courses = Course.find_by_sql("SELECT c.*, count(at.container_id) cat FROM attachments at, courses c WHERE at.container_type = 'Course' AND at.container_id = c.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY cat #{params[:sort]}, id desc")
+ @order = params[:order]
+ @sort = params[:sort]
+
+ elsif params[:sort] && (params[:order] == 'works')
+ courses = Course.find_by_sql("SELECT c.*, count(hc.id) chc FROM courses c, homework_commons hc,student_works sw WHERE c.id = hc.course_id AND sw.homework_common_id = hc.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY chc #{params[:sort]}, id desc")
@order = params[:order]
@sort = params[:sort]
+
+ elsif params[:sort] && (params[:order] == 'homework')
+ courses = Course.find_by_sql("SELECT c.*, count(sw.id) csw FROM student_works sw, courses c, homework_commons hc WHERE c.id = hc.course_id AND sw.id = c.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY csw #{params[:sort]}, id desc")
+ @order = params[:order]
+ @sort = params[:sort]
+
+ elsif params[:sort] && (params[:order] == 'std')
+ courses = Course.find_by_sql("SELECT c.*, count(sfc.id) sfc FROM courses c, students_for_courses sfc WHERE sfc.course_id = c.id AND c.name like '%#{name}%' GROUP BY c.id ORDER BY sfc #{params[:sort]}, id desc")
+ @order = params[:order]
+ @sort = params[:sort]
+
+ elsif params[:sort] && (params[:order] == 'open')
+ courses = Course.find_by_sql("SELECT * FROM courses WHERE name like '%#{name}%' ORDER BY is_public #{params[:sort]},id desc")
+ @order = params[:order]
+ @sort = params[:sort]
+
else
courses = Course.like(name).order('created_at desc')
end
diff --git a/app/views/admin/_course_detail_tr.html.erb b/app/views/admin/_course_detail_tr.html.erb
index 1629dda83..189cbc8f6 100644
--- a/app/views/admin/_course_detail_tr.html.erb
+++ b/app/views/admin/_course_detail_tr.html.erb
@@ -25,7 +25,7 @@
<%= visable_attachemnts_incourse(course).count%>
- <%= course.boards.first.topics.count + Message.where("board_id =? and parent_id is not ?", course.boards.first.id, nil).count %>
+ <%= Message.where("board_id =?", course.boards.first.id).count %>
<%= course.course_activities.count%>
diff --git a/app/views/admin/excellent_all_courses.html.erb b/app/views/admin/excellent_all_courses.html.erb
index e5a89573a..805c81d1f 100644
--- a/app/views/admin/excellent_all_courses.html.erb
+++ b/app/views/admin/excellent_all_courses.html.erb
@@ -30,32 +30,32 @@
课程名
-
- 公开
+
+ <%= link_to '公开', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'open') %>
主讲老师
-
- 学生数
+
+ <%= link_to '学生数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'std') %>
-
- 作业数
+
+ <%= link_to '作业数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'homework') %>
-
- 作品数
+
+ <%= link_to '作品数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'works') %>
-
- 资源数
+
+ <%= link_to '资源数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'res') %>
-
- 帖子数
+
+ <%= link_to '帖子数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'post') %>
- <%=link_to '动态数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'act') %>
+ <%= link_to '动态数', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'act') %>
- <%=link_to '开课学期', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'time') %>
+ <%= link_to '开课学期', excellent_all_courses_path(:sort=> @sort == "desc" ? 'asc' : 'desc', :order => 'time') %>
From cc649ae64b775c9056436c4421a5ecb527eb8270 Mon Sep 17 00:00:00 2001
From: cxt
Date: Mon, 4 Jul 2016 14:14:51 +0800
Subject: [PATCH 10/51] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E8=AE=A8=E8=AE=BA?=
=?UTF-8?q?=E5=8C=BA=E3=80=81=E9=A1=B9=E7=9B=AE=E8=AE=A8=E8=AE=BA=E5=8C=BA?=
=?UTF-8?q?=E3=80=81=E5=B8=96=E5=AD=90=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2?=
=?UTF-8?q?=E7=9A=84=E4=BA=8C=E7=BA=A7=E5=9B=9E=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/messages_controller.rb | 80 +++++++------
app/controllers/users_controller.rb | 16 ++-
app/helpers/application_helper.rb | 4 +-
app/views/messages/_course_show.html.erb | 33 ++++--
app/views/messages/_project_show.html.erb | 110 +++++++++---------
app/views/messages/_reply_message.html.erb | 9 +-
app/views/messages/destroy.js.erb | 8 ++
app/views/messages/quote.js.erb | 14 +--
.../users/_comment_reply_detail.html.erb | 6 +-
app/views/users/_course_message.html.erb | 20 ++--
app/views/users/_message_contents.html.erb | 23 ++++
app/views/users/_message_replies.html.erb | 61 ++++++++++
.../users/_message_reply_banner.html.erb | 18 +++
app/views/users/_project_message.html.erb | 18 ++-
app/views/users/_reply_to.html.erb | 18 ++-
app/views/users/all_journals.js.erb | 2 +
app/views/users/show_all_replies.js.erb | 2 +
public/javascripts/application.js | 35 ++++++
public/stylesheets/courses.css | 4 +-
public/stylesheets/public.css | 46 +++++++-
20 files changed, 382 insertions(+), 145 deletions(-)
create mode 100644 app/views/messages/destroy.js.erb
create mode 100644 app/views/users/_message_contents.html.erb
create mode 100644 app/views/users/_message_replies.html.erb
create mode 100644 app/views/users/_message_reply_banner.html.erb
diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb
index 8ef399d10..f5ad89832 100644
--- a/app/controllers/messages_controller.rb
+++ b/app/controllers/messages_controller.rb
@@ -44,7 +44,8 @@ class MessagesController < ApplicationController
offset = @topic.children.count(:conditions => ["#{Message.table_name}.id < ?", params[:r].to_i])
page = 1 + offset / REPLIES_PER_PAGE
end
- @reply_count = @topic.children.count
+ all_comments = []
+ @reply_count = get_all_children(all_comments, @topic).count
@reply = Message.new(:subject => "RE: #{@message.subject}")
if @course
messages_replies = @topic.children.
@@ -137,26 +138,32 @@ class MessagesController < ApplicationController
# Reply to a topic
def reply
- if params[:reply][:content] == ""
- 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
+ if params[:parent_id]
+ parent = Message.find params[:parent_id]
+ @reply = Message.new
+ @reply.author = User.current
+ @reply.board = parent.board
+ @reply.content = params[:content]
+ @reply.subject = "RE: #{parent.subject}"
+ @reply.reply_id = params[:reply_id]
+ # @reply.reply_id = params[:id]
+ parent.children << @reply
+ @topic = params[:activity_id].nil? ? parent : Message.find(params[:activity_id].to_i)
+ @user_activity_id = params[:user_activity_id] if params[:user_activity_id]
+ @is_course = params[:is_course] if params[:is_course]
+ @is_board = params[:is_board] if params[:is_board]
+ else
+ @quote = params[:quote][:quote]
+ @reply = Message.new
+ @reply.author = User.current
+ @reply.board = @board
+ @reply.safe_attributes = params[:reply]
+ @reply.content = @quote + @reply.content
+ @reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject]
+ @topic.children << @reply
+ # @reply.reply_id = params[:id]
end
- @quote = params[:quote][:quote]
- @reply = Message.new
- @reply.author = User.current
- @reply.board = @board
- @reply.safe_attributes = params[:reply]
- @reply.content = @quote + @reply.content
- @reply.subject = "RE: #{@topic.subject}" unless params[:reply][:subject]
- # @reply.reply_id = params[:id]
- @topic.children << @reply
+
update_course_activity(@topic.class,@topic.id)
update_user_activity(@topic.class,@topic.id)
update_forge_activity(@topic.class,@topic.id)
@@ -182,14 +189,10 @@ class MessagesController < ApplicationController
respond_to do |format|
format.js
end
- elsif params[:is_board]
- if @project
- redirect_to project_boards_path(@project)
- elsif @course
- redirect_to course_boards_path(@course)
- end
+ return
else
- redirect_to board_message_url(@board, @topic, :r => @reply)
+ redirect_to board_message_url(@board, @topic)
+ return
end
end
@@ -251,6 +254,17 @@ class MessagesController < ApplicationController
# Delete a messages
def destroy
+ if params[:user_activity_id]
+ @message.destroy
+ @topic = Message.find(params[:activity_id].to_i)
+ @user_activity_id = params[:user_activity_id]
+ @is_course = params[:is_course]
+ @is_board = params[:is_board]
+ respond_to do |format|
+ format.js
+ end
+ return
+ end
if @project
(render_403; return false) unless @message.destroyable_by?(User.current)
elsif @course
@@ -299,12 +313,12 @@ class MessagesController < ApplicationController
end
def quote
- @subject = @message.subject
- @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:')
-
- @content = "> #{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> "
- @temp = Message.new
- @temp.content = "#{ll(Setting.default_language, :text_user_wrote, @message.author.show_name)} #{@message.content.html_safe} ".html_safe
+ # @subject = @message.subject
+ # @subject = "RE: #{@subject}" unless @subject.starts_with?('RE:')
+ #
+ # @content = "> #{ll(Setting.default_language, :text_user_wrote, @message.author)}\n> "
+ # @temp = Message.new
+ # @temp.content = "#{ll(Setting.default_language, :text_user_wrote, @message.author.show_name)} #{@message.content.html_safe} ".html_safe
end
def preview
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index 69a38610e..fe42e6919 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -90,6 +90,8 @@ class UsersController < ApplicationController
case params[:type]
when 'JournalsForMessage'
@comment = JournalsForMessage.find params[:comment].to_i
+ when 'Message'
+ @comment = Message.find params[:comment].to_i
end
end
@@ -111,6 +113,13 @@ class UsersController < ApplicationController
@user_activity_id = params[:user_activity_id]
@activity_id = params[:activity_id]
@type = 'JournalsForMessage'
+ when 'Message'
+ @reply = Message.find params[:reply_id]
+ @user_activity_id = params[:user_activity_id]
+ @activity_id = params[:activity_id]
+ @is_course = params[:is_course]
+ @is_board = params[:is_board]
+ @type = 'Message'
end
respond_to do |format|
format.js
@@ -3281,7 +3290,12 @@ class UsersController < ApplicationController
@journals = obj.children.reorder("created_at desc")
when 'Message'
obj = Message.where('id = ?', params[:id].to_i).first
- @journals = obj.children.reorder("created_on desc")
+ @type = 'Message'
+ @is_course = params[:is_course]
+ @is_board = params[:is_board]
+ @user_activity_id = params[:div_id].to_i if params[:div_id]
+ comments = []
+ @journals = get_all_children(comments, obj)
when 'News'
obj = News.where('id = ?', params[:id].to_i).first
@journals = obj.comments.reorder("created_on desc")
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index cb8b06a8f..1d79d45ce 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -3138,9 +3138,9 @@ def get_reply_parents_no_root parents_rely, comment
parents_rely
end
-#获取留言的所有子节点
+#获取所有子节点
def get_all_children result, jour
- if jour.kind_of? JournalsForMessage
+ if (jour.kind_of? JournalsForMessage) || (jour.kind_of? Message)
jour.children.each do |jour_child|
result << jour_child
get_all_children result, jour_child
diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb
index 560925070..232be1f35 100644
--- a/app/views/messages/_course_show.html.erb
+++ b/app/views/messages/_course_show.html.erb
@@ -95,9 +95,10 @@
- <% unless @replies.empty? %>
+ <% all_comments = []%>
+ <% comments = get_all_children(all_comments, @topic) %>
- <% @replies.each_with_index do |reply,i| %>
+ <% comments.each_with_index do |reply,i| %>
-
-
- <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
-
-
-
- <% if reply.try(:author).try(:realname) == ' ' %>
- <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% else %>
- <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %>
- <% end %>
-
-
- <%= reply.content.html_safe%>
-
-
- <%= format_time(reply.created_on) %>
-
-
-
-
-
+ <% all_comments = []%>
+ <% comments = get_all_children(all_comments, @topic) %>
+
+ <% comments.each_with_index do |reply,i| %>
+
+
+
+ <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
+
+
+
+ <%= link_to reply.creator_user.show_name, user_url_in_org(reply.creator_user.id), :class => "newsBlue mr10 f14" %>
+ <%= time_from_now(reply.created_on) %>
- <% end %>
-
+ <% if !reply.parent.nil? && !reply.parent.parent.nil? %>
+ <%= render :partial => 'users/message_contents', :locals => {:comment => reply}%>
+ <% end %>
+
+ <%= reply.content.html_safe%>
+
+
+
+
+
+ <%= render :partial => "praise_tread/praise", :locals => {:activity => reply, :user_activity_id => reply.id, :type => "reply"} %>
+
+
+ <%= link_to(
+ l(:button_reply),
+ {:action => 'quote', :id => reply},
+ :remote => true,
+ :method => 'get',
+ :title => l(:button_reply)) if !@topic.locked? && authorize_for('messages', 'reply') %>
+ ︿
+
+ <%= link_to(
+ l(:button_delete),
+ {:action => 'destroy', :id => reply},
+ :method => :post,
+ :class => 'fr mr20',
+ :data => {:confirm => l(:text_are_you_sure)},
+ :title => l(:button_delete)
+ ) if reply.course_destroyable_by?(User.current) %>
+
- <% end %>
+
+
+
+
+
+
+
+ <% end %>
+
<% if !@topic.locked? && authorize_for('messages', 'reply') %>
diff --git a/app/views/messages/_reply_message.html.erb b/app/views/messages/_reply_message.html.erb
index d4d9d77a0..923734001 100644
--- a/app/views/messages/_reply_message.html.erb
+++ b/app/views/messages/_reply_message.html.erb
@@ -4,11 +4,12 @@
- <% count=0 %>
- <% if activity.parent %>
- <% count=activity.parent.children.count%>
- <% else %>
- <% count=activity.children.count%>
- <% end %>
+ <% all_comments = []%>
+ <% count=get_all_children(all_comments, activity).count %>
+ <%# allow_delete = (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher,activity.course)) %>
+ <%# count = fetch_user_leaveWord_reply(activity).count %>
- <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %>
+ <%= render :partial => 'users/message_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id,:is_course => is_course,:is_board =>is_board} %>
- <% activity= activity.parent ? activity.parent : activity%>
- <% comments = activity.children.reorder("created_on desc").limit(3) %>
- <% if count > 0 %>
+ <% all_comments = []%>
+ <% comments = get_all_children(all_comments, activity)[0..2] %>
+ <% if count > 0 %>
- <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
+ <%= render :partial => 'users/message_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'Message', :activity_id =>activity.id, :is_course => is_course, :is_board =>is_board}%>
<% end %>
diff --git a/app/views/users/_message_contents.html.erb b/app/views/users/_message_contents.html.erb
new file mode 100644
index 000000000..eab125006
--- /dev/null
+++ b/app/views/users/_message_contents.html.erb
@@ -0,0 +1,23 @@
+<% parents_rely = [] %>
+<% parents_rely = get_reply_parents_no_root parents_rely, comment %>
+<% length = parents_rely.length %>
+
\ No newline at end of file
diff --git a/app/views/users/_message_replies.html.erb b/app/views/users/_message_replies.html.erb
new file mode 100644
index 000000000..c6f9d91b0
--- /dev/null
+++ b/app/views/users/_message_replies.html.erb
@@ -0,0 +1,61 @@
+
+ <% comments.each do |comment| %>
+
+
+
+ <%= link_to image_tag(url_to_avatar(comment.creator_user), :width => 33, :height => 33, :alt => "用户头像"), user_url_in_org(comment.creator_user.id) %>
+
+
+
+ <%= link_to comment.creator_user.show_name, user_url_in_org(comment.creator_user.id), :class => "newsBlue mr10 f14" %>
+ <%= time_from_now(comment.created_on) %>
+
+ <% if !comment.parent.nil? && !comment.parent.parent.nil? %>
+ <%= render :partial => 'users/message_contents', :locals => {:comment => comment}%>
+ <% end %>
+ <% if !comment.content_detail.blank? %>
+
+
+
+
+
+
+ <%= link_to(
+ l(:button_reply),
+ {:controller => 'users' ,:action => 'reply_to', :reply_id => comment.id, :type => type, :user_activity_id => user_activity_id, :activity_id => activity_id, :is_course => is_course, :is_board => is_board},
+ :remote => true,
+ :method => 'get',
+ :title => l(:button_reply)) %>
+
+
+ <% if comment.course_destroyable_by?(User.current) %>
+ <%= link_to(
+ l(:button_delete),
+ delete_board_message_path(comment,:board_id =>comment.board.id, :user_activity_id => user_activity_id, :activity_id => activity_id, :is_course => is_course, :is_board => is_board),
+ :method => :post,
+ :remote => true,
+ :class => 'fr mr20',
+ :data => {:confirm => l(:text_are_you_sure)},
+ :title => l(:button_delete)
+ ) %>
+ <% end %>
+
+
+
+
+
+ <% end %>
+
+
+
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/users/_message_reply_banner.html.erb b/app/views/users/_message_reply_banner.html.erb
new file mode 100644
index 000000000..0c8cda379
--- /dev/null
+++ b/app/views/users/_message_reply_banner.html.erb
@@ -0,0 +1,18 @@
+
+
+ 回复
+ ︿
+ <%= count>0 ? "(#{count})" : "" %> ▪
+
+ <%=render :partial=> "praise_tread/praise", :locals => {:activity=>activity, :user_activity_id=>user_activity_id,:type=>"activity"}%>
+
+
+
<%#= format_date(activity.updated_on) %>
+ <%if count>3 %>
+
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/users/_project_message.html.erb b/app/views/users/_project_message.html.erb
index 1abc36a31..d1bb99296 100644
--- a/app/views/users/_project_message.html.erb
+++ b/app/views/users/_project_message.html.erb
@@ -77,20 +77,18 @@
- <% count = 0 %>
- <% if activity.parent %>
- <% count=activity.parent.children.count%>
- <% else %>
- <% count=activity.children.count%>
- <% end %>
+ <% all_comments = []%>
+ <% count=get_all_children(all_comments, activity).count %>
+ <%# allow_delete = (activity.user == User.current || User.current.admin? || User.current.allowed_to?(:as_teacher,activity.course)) %>
+ <%# count = fetch_user_leaveWord_reply(activity).count %>
- <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %>
+ <%= render :partial => 'users/message_reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id,:is_course => is_course,:is_board =>is_board} %>
- <% activity= activity.parent_id.nil? ? activity : activity.parent %>
- <% comments = activity.children.reorder("created_on desc").limit(3) %>
+ <% all_comments = []%>
+ <% comments = get_all_children(all_comments, activity)[0..2] %>
<% if count > 0 %>
- <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
+ <%= render :partial => 'users/message_replies', :locals => {:comments => comments, :user_activity_id => user_activity_id, :type => 'Message', :activity_id =>activity.id, :is_course => is_course, :is_board =>is_board}%>
<% end %>
diff --git a/app/views/users/_reply_to.html.erb b/app/views/users/_reply_to.html.erb
index 621b56fbd..8a2909ad4 100644
--- a/app/views/users/_reply_to.html.erb
+++ b/app/views/users/_reply_to.html.erb
@@ -16,7 +16,7 @@
<% end%>
<% elsif @type == 'JournalsForMessage' %>
- <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => reply.id}, :method => "post", :remote => true) do |f|%>
+ <%= form_for('new_form',:url => {:controller => 'words', :action => 'create_reply', :id => reply.id}, :method => "post", :remote => true) do |f|%>
<%= hidden_field_tag 'reference_id', params[:reference_id], :value => reply.id %>
<%= hidden_field_tag 'reference_user_id', params[:reference_user_id], :value => reply.user.id %>
<%= hidden_field_tag 'reference_message_id', params[:reference_message_id], :value => reply.id %>
@@ -28,6 +28,22 @@
发送
<% end%>
+ <% elsif @type == 'Message' %>
+ <%= form_for('new_form',:url => {:controller => 'messages', :action => 'reply', :id => reply.id, :board_id => reply.board.id}, :method => "post", :remote => true) do |f|%>
+ <%= hidden_field_tag 'is_course', params[:is_course], :value => @is_course %>
+ <%= hidden_field_tag 'is_board', params[:is_board], :value => @is_board %>
+ <%= hidden_field_tag 'parent_id', params[:parent_id], :value => reply.id %>
+ <%= hidden_field_tag 'reply_id', params[:reply_id], :value => reply.author.id %>
+ <%= hidden_field_tag 'activity_id',params[:activity_id],:value =>@activity_id %>
+ <%= hidden_field_tag 'user_activity_id',params[:user_activity_id],:value =>@user_activity_id %>
+
+
+
+
发送
+
+
+ <% end%>
<% end %>
diff --git a/app/views/users/all_journals.js.erb b/app/views/users/all_journals.js.erb
index 6d227e93b..d03e13742 100644
--- a/app/views/users/all_journals.js.erb
+++ b/app/views/users/all_journals.js.erb
@@ -2,6 +2,8 @@
$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/homework_replies', :locals => {:comments => @journals, :is_in_course =>@is_in_course,:course_activity=>@course_activity, :is_teacher => @is_teacher, :user_activity_id => @user_activity_id}) %>');
<% elsif params[:type] == 'JournalsForMessage' %>
$('#reply_div_<%= @user_activity_id %>').html('<%=escape_javascript(render :partial => 'users/journal_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :allow_delete => @allow_delete, :activity_id =>params[:id].to_i}) %>');
+<% elsif params[:type] == 'Message' %>
+$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/message_replies', :locals => {:comments => @journals,:user_activity_id => @user_activity_id, :type => @type, :activity_id =>params[:id].to_i,:is_course => @is_course, :is_board => @is_board}) %>');
<% else %>
$('#reply_div_<%= params[:div_id].to_i %>').html('<%=escape_javascript(render :partial => 'users/all_replies', :locals => {:comments => @journals}) %>');
<% end %>
diff --git a/app/views/users/show_all_replies.js.erb b/app/views/users/show_all_replies.js.erb
index 5f5ea6c3f..ae8803653 100644
--- a/app/views/users/show_all_replies.js.erb
+++ b/app/views/users/show_all_replies.js.erb
@@ -1,6 +1,8 @@
<% unless @comment.parent.nil? %>
<% if params[:type] == 'JournalsForMessage' && (@comment.jour_type == 'Principal' || @comment.jour_type == 'Course') %>
$('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/journal_comment_reply', :locals => {:comment => @comment.parent})%>");
+ <% elsif @comment.class.to_s == 'Message' %>
+ $('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/journal_comment_reply', :locals => {:comment => @comment.parent})%>");
<% else %>
$('#comment_reply_<%=@comment.id %>').html("<%= escape_javascript(render :partial => 'users/comment_reply', :locals => {:comment => @comment.parent})%>");
<% end %>
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 016526512..91467cca4 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1374,6 +1374,41 @@ function expand_journal_reply(container, btnid, id, type, div_id, allow_delete)
}
}
+function expand_message_reply(container, btnid, id, type, div_id, is_course, is_board) {
+ var target = $(container);
+ var btn = $(btnid);
+ if (btn.data('init') == '0') {
+ btn.data('init', 1);
+ $.get(
+ '/users/all_journals',
+ {
+ type: type,
+ id: id,
+ div_id: div_id,
+ is_course: is_course,
+ is_board: is_board
+ },
+ function(data) {
+
+ }
+ );
+ btn.html('收起回复');
+ //target.show();
+ } else if(btn.data('init') == '1') {
+ btn.data('init', 3);
+ btn.html('展开更多');
+ target.hide();
+ target.eq(0).show();
+ target.eq(1).show();
+ target.eq(2).show();
+ }
+ else {
+ btn.data('init', 1);
+ btn.html('收起回复');
+ target.show();
+ }
+}
+
function expand_reply_homework(container, btnid, id, type, div_id, is_in_course, course_activity, user_activity_id) {
var target = $(container);
var btn = $(btnid);
diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css
index 96c9947b1..9f7aeeafc 100644
--- a/public/stylesheets/courses.css
+++ b/public/stylesheets/courses.css
@@ -190,7 +190,7 @@ a.postOptionLink2:hover {color:#ffffff; background-color:#269ac9;}
.imageFuzzy {filter:alpha(opacity=50); -moz-opacity:0.5; -khtml-opacity:0.5;opacity: 0.5;}
.homepagePostReplyDes {float:left; width:632px; margin-left:15px;}
.homepagePostReplyPublisher {font-size:12px; color:#888888; margin-bottom:5px;}
-.homepagePostReplyContent {font-size:12px; color:#484848; margin-bottom:12px;}
+.homepagePostReplyContent {font-size:12px; color:#484848; margin:3px 5px 12px 5px;}
.homepagePostReplyContent ol li{list-style-type: decimal;margin-left: 20px;}
.homepagePostReplyContent ul li{list-style-type: disc;margin-left: 20px;}
.homepagePostReplyContent td,.homepagePostReplyContent tr {border: 1px solid; border-color: inherit;}
@@ -1429,4 +1429,4 @@ a.pages-big{ width:50px;}
.W300 {width:300px !important;}
.W600{ width:600px;}
-.syllabus_input {width: 290px; border: 1px solid #64bdd9; height: 30px;}
+.syllabus_input {width: 290px; border: 1px solid #64bdd9; height: 30px;}
diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css
index 7cfb7f9e0..154cda201 100644
--- a/public/stylesheets/public.css
+++ b/public/stylesheets/public.css
@@ -666,7 +666,7 @@ a.postReplyCancel:hover {color:#ffffff;}
.homepagePostReplyPortrait {float:left; width:45px;}
.homepagePostReplyDes {float:left; width:620px; margin-left:15px;}
.homepagePostReplyPublisher {font-size:12px; color:#484848; margin-bottom:5px;}
-.homepagePostReplyContent {font-size:12px; color:#484848; margin-bottom:12px;}
+.homepagePostReplyContent {font-size:12px; color:#484848; margin:3px 5px 12px 5px;}
.homepagePostReplyContent ol li{list-style-type: decimal;margin-left: 40px;}
.homepagePostReplyContent ul li{list-style-type: disc;margin-left: 40px;}
.homepagePostReplyContent td,.homepagePostReplyContent tr {border: 1px solid; border-color: inherit;}
@@ -1184,4 +1184,46 @@ a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px;
.reply_iconup{ position:absolute; top:21px; left:13px; color:#d4d4d4; font-size:16px; background:#f1f1f1; line-height:13px;}
/*20160622代码分析弹窗*/
-.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;}
+.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;}
+
+/* 二级回复 */
+.clearfix:after { content:"."; display:block; height:0; visibility:hidden; clear:both; }
+.clearfix { zoom:1; }
+.clearit { clear:both; height:0; font-size:0; overflow:hidden; }
+.comment_item{ width:720px; background-color:#f1f1f1; color:#888;}
+.comment_top{ height:15px; border: 1px solid #e4e4e4; padding:10px; position:relative;}
+.reply_iconup{ position:absolute; top:21px; left:13px; color:#d4d4d4; font-size:16px; background:#f1f1f1; line-height:13px;}
+.fl{ float:left;}
+.fr{ float:right;}
+.comment_item_cont{ padding:15px; border-bottom:1px solid #e3e3e3;}
+.J_Comment_Face img{ width:40px; height:40px; }
+.t_content{ width:92%; margin-left:15px;}
+a.content-username { color:#269ac9; font-size:14px; margin-right:15px;}
+a.content-username:hover{ color:#297fb8;}
+.orig_user img{width:32px; height:32px;}
+.reply-right{ float:right; position:relative;}
+.reply_iconup02{ position:absolute; top:16px; left:4px; color:#d4d4d4; font-size:16px; background:#f1f1f1; line-height:13px;}
+.comment_orig_content{margin:10px 0; color:#999;}
+.comment_orig_content .comment_orig_content{margin-top:0;}
+.orig_cont{ border:solid 1px #F3DDB3; background:#FFFEF4; padding:4px;color:#999;margin-top:-1px;}
+.orig_cont_sub{ border-top:0}
+.orig_index{ float:right; color:#666; font-family:Arial; padding-right:5px;line-height:30px;}
+.orig_user{ margin:10px 15px 10px 5px;}
+.orig_user span{ color:#999; padding-right:5px;}
+.orig_content{padding:5px 0px 5px 0px;line-height:24px; color:#333; }
+.orig_right{ width:80%; margin-top:5px;}
+a.comment_ding_link{ height:24px;line-height:24px;display:inline-block;padding-left:2px;vertical-align:middle; color:#333; }
+a:hover.comment_ding_link{ color:#269ac9;}
+.comment_ding_link span{display: inline-block;padding: 0 0px 0 8px;}
+.comment_ding_link em{font-style: normal;font-family: arial;}
+.comment_reply_link{ display:inline-block; width:50px; height:24px;line-height: 24px; vertical-align:middle;text-align: center;}
+.comment_reply_link:link,.comment_reply_link:visited{color:#333;text-decoration: none;}
+.comment_content{ color:#333;}
+.t_txt{ margin-top:10px;}
+.orig_reply_box{border-top:1px solid #e3e3e3; width:95%; padding:15px 0px 15px 25px;}
+.orig_reply_box2{border-top:1px solid #e3e3e3; width:95%; padding:10px 25px 10px 0;}
+.orig_textarea{width:90%; margin-bottom:10px;}
+.orig_sub{ float:right; background-color:#269ac9; color:#fff; height:25px; line-height:25px; text-align:center; width:80px; border:none;}
+.orig_sub:hover{ background:#297fb8;}
+.orig_cont_hide{ text-align:center; width:624px; display:block; font-size:14px; color:#333; border-bottom:1px solid #F3DDB3; padding:8px 0;}
+.orig_icon{ color:#888; margin-right:10px; font-size:14px; font-weight:bold;}
From 0dd7ef4460b794fcd66f74f554a5e892e4015c5a Mon Sep 17 00:00:00 2001
From: cxt
Date: Mon, 4 Jul 2016 14:45:50 +0800
Subject: [PATCH 11/51] =?UTF-8?q?=E5=B8=96=E5=AD=90=E5=88=97=E8=A1=A8?=
=?UTF-8?q?=E7=9A=84=E5=9B=9E=E5=A4=8D=E6=95=B0=E4=B8=8E=E5=AE=9E=E9=99=85?=
=?UTF-8?q?=E4=B8=8D=E7=AC=A6?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/boards_controller.rb | 4 +++-
app/views/users/_course_boardlist.html.erb | 8 ++------
app/views/users/_project_boardlist.html.erb | 8 ++------
3 files changed, 7 insertions(+), 13 deletions(-)
diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb
index 9a72bb4df..ceb63d7b0 100644
--- a/app/controllers/boards_controller.rb
+++ b/app/controllers/boards_controller.rb
@@ -125,7 +125,9 @@ class BoardsController < ApplicationController
if @order.to_i == 2
@type = 2
@topics.each do |topic|
- topic[:infocount] = get_praise_num(topic) + (topic.parent ? topic.parent.children.count : topic.children.count)
+ all_comments = []
+ count=get_all_children(all_comments, topic).count
+ topic[:infocount] = get_praise_num(topic) + count
if topic[:infocount] < 0
topic[:infocount] = 0
end
diff --git a/app/views/users/_course_boardlist.html.erb b/app/views/users/_course_boardlist.html.erb
index 5cb2c27a7..bdff80d33 100644
--- a/app/views/users/_course_boardlist.html.erb
+++ b/app/views/users/_course_boardlist.html.erb
@@ -46,12 +46,8 @@
发帖人: <%=(u.try(:realname) != " " ? u.lastname + u.firstname : u.try(:login)) %>
更新:<%= format_time(activity.children.any? ? activity.children.last[:created_on] : activity[:created_on] ) %>
- <% count=0 %>
- <% if activity.parent %>
- <% count=activity.parent.children.count%>
- <% else %>
- <% count=activity.children.count%>
- <% end %>
+ <% all_comments = []%>
+ <% count=get_all_children(all_comments, activity).count %>
<%= count>0 ? "#{count}" : "0" %> 回复 | <%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" : "0" %> 赞
diff --git a/app/views/users/_project_boardlist.html.erb b/app/views/users/_project_boardlist.html.erb
index fe7bc03f2..3ba0244d9 100644
--- a/app/views/users/_project_boardlist.html.erb
+++ b/app/views/users/_project_boardlist.html.erb
@@ -46,12 +46,8 @@
发帖人:<%=(u.try(:realname) != " " ? u.lastname + u.firstname : u.try(:login)) %>
更新:<%= format_time(activity.children.any? ? activity.children.last[:created_on] : activity[:created_on] ) %>
- <% count=0 %>
- <% if activity.parent %>
- <% count=activity.parent.children.count%>
- <% else %>
- <% count=activity.children.count%>
- <% end %>
+ <% all_comments = []%>
+ <% count=get_all_children(all_comments, activity).count %>
<%= count>0 ? "#{count}" : "0" %> 回复 | <%= get_praise_num(activity) > 0 ? "#{get_praise_num(activity)}" : "0" %> 赞
From da19bbd3a0d043d4f8e0f30e01edcdb914efe108 Mon Sep 17 00:00:00 2001
From: yuanke <249218296@qq.com>
Date: Tue, 5 Jul 2016 09:02:34 +0800
Subject: [PATCH 12/51] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E4=B8=8B?=
=?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=B5=84=E6=96=99=E7=95=8C=E9=9D=A2=E7=9A=84?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/school_controller.rb | 26 ++--
app/models/apply_add_schools.rb | 1 +
app/views/my/_apply_add_school.html.erb | 187 ------------------------
app/views/my/account.html.erb | 185 -----------------------
public/javascripts/application.js | 186 +++++++++++++++++++++++
5 files changed, 202 insertions(+), 383 deletions(-)
diff --git a/app/controllers/school_controller.rb b/app/controllers/school_controller.rb
index 44f4378fe..dab752afb 100644
--- a/app/controllers/school_controller.rb
+++ b/app/controllers/school_controller.rb
@@ -155,47 +155,51 @@ class SchoolController < ApplicationController
def apply_add_school
data = {result:0,name:params[:name],school_id:0}
- #0 成功 1参数错误 2名称已存在
+ #0 成功 1参数错误 2名称已存在 3.失败
data[:result] = 0
#检验参数
if params[:name] == "" || params[:province] == "" || params[:city] == "" || params[:address] == ""
data[:result] = 1
else
- school_id = School.find_by_sql("select id from schools where name='#{params[:name]}'").first
- if school_id
+ school = School.where("name = '#{params[:name]}'").first
+ if school
data[:result] = 2
else
school = School.new
school.name = params[:name].strip
school.pinyin = Pinyin.t(params[:name].strip, splitter: '')
- school.save
#status 0未处理 1通过 2拒绝
applyschool = ApplyAddSchools.new
- applyschool.school_id = school.id
+
+ #用belongs_to 可以一起存数据库
+ applyschool.school = school
applyschool.name = school.name
applyschool.province = params[:province]
applyschool.city = params[:city]
applyschool.address = params[:address]
applyschool.remarks = params[:remarks]
- applyschool.save
- data[:school_id] = school.id
+ if applyschool.save
+ data[:school_id] = school.id
+ else
+ data[:result] = 3
+ end
end
end
render :json =>data
end
def search_repeat_schoolname
- status = 0
+ status = 0 #没有重复的
name = params[:name]
if name
- school_id = School.find_by_sql("select id from schools where name='#{name}'").first
+ school = School.where("name = '#{name}'").first
- if school_id
- status = 1
+ if school
+ status = 1 #有重复的
end
end
diff --git a/app/models/apply_add_schools.rb b/app/models/apply_add_schools.rb
index 2082c0012..efa56e808 100644
--- a/app/models/apply_add_schools.rb
+++ b/app/models/apply_add_schools.rb
@@ -1,3 +1,4 @@
class ApplyAddSchools < ActiveRecord::Base
attr_accessible :address, :city, :name, :province, :remarks, :school_id, :status
+ belongs_to :school
end
diff --git a/app/views/my/_apply_add_school.html.erb b/app/views/my/_apply_add_school.html.erb
index 1449fa1f1..c7b08e305 100644
--- a/app/views/my/_apply_add_school.html.erb
+++ b/app/views/my/_apply_add_school.html.erb
@@ -120,193 +120,6 @@
});
}
- function showcity(province, cityField) {
- $("#provincenotice").hide();
- switch (province) {
- case "北京" :
- var cityOptions = new Array(
- "东城", "西城", "朝阳", "丰台", "石景山", "海淀", "门头沟",
- "房山", "通州", "顺义", "昌平", "大兴", "平谷", "怀柔", "密云", "延庆");
- break;
- case "上海" :
- var cityOptions = new Array(
- "崇明", "黄浦", "卢湾", "徐汇", "长宁", "静安", "普陀", "闸北", "虹口", "杨浦", "闵行",
- "宝山", "嘉定", "浦东", "金山", "松江", "青浦", "南汇", "奉贤");
- break;
- case "广东" :
- var cityOptions = new Array(
- "广州", "深圳", "珠海", "东莞", "中山", "佛山", "惠州", "河源", "潮州", "江门", "揭阳", "茂名",
- "梅州", "清远", "汕头", "汕尾", "韶关", "顺德", "阳江", "云浮", "湛江", "肇庆");
- break;
- case "江苏" :
- var cityOptions = new Array(
- "南京", "常熟", "常州", "海门", "淮安", "江都", "江阴", "昆山", "连云港", "南通",
- "启东", "沭阳", "宿迁", "苏州", "太仓", "泰州", "同里", "无锡", "徐州", "盐城",
- "扬州", "宜兴", "仪征", "张家港", "镇江", "周庄");
- break;
- case "重庆" :
- var cityOptions = new Array(
- "万州", "涪陵", "渝中", "大渡口", "江北", "沙坪坝", "九龙坡", "南岸", "北碚", "万盛",
- "双挢", "渝北", "巴南", "黔江", "长寿", "綦江", "潼南", "铜梁", "大足", "荣昌", "壁山",
- "梁平", "城口", "丰都", "垫江", "武隆", "忠县", "开县", "云阳", "奉节", "巫山", "巫溪",
- "石柱", "秀山", "酉阳", "彭水", "江津", "合川", "永川", "南川");
- break;
- case "安徽" :
- var cityOptions = new Array(
- "合肥", "安庆", "蚌埠", "亳州", "巢湖", "滁州", "阜阳", "贵池", "淮北", "淮化", "淮南",
- "黄山", "九华山", "六安", "马鞍山", "宿州", "铜陵", "屯溪", "芜湖", "宣城");
- break;
- case "福建" :
- var cityOptions = new Array(
- "福州", "厦门", "泉州", "漳州", "龙岩", "南平", "宁德", "莆田", "三明");
- break;
- case "甘肃" :
- var cityOptions = new Array(
- "兰州", "白银", "定西", "敦煌", "甘南", "金昌", "酒泉", "临夏", "平凉", "天水",
- "武都", "武威", "西峰", "张掖");
- break;
- case "广西" :
- var cityOptions = new Array(
- "南宁", "百色", "北海", "桂林", "防城港", "贵港", "河池", "贺州", "柳州", "钦州", "梧州", "玉林");
- break;
- case "贵州" :
- var cityOptions = new Array(
- "贵阳", "安顺", "毕节", "都匀", "凯里", "六盘水", "铜仁", "兴义", "玉屏", "遵义");
- break;
- case "海南" :
- var cityOptions = new Array(
- "海口", "儋县", "陵水", "琼海", "三亚", "通什", "万宁");
- break;
- case "河北" :
- var cityOptions = new Array(
- "石家庄", "保定", "北戴河", "沧州", "承德", "丰润", "邯郸", "衡水", "廊坊", "南戴河", "秦皇岛",
- "唐山", "新城", "邢台", "张家口");
- break;
- case "黑龙江" :
- var cityOptions = new Array(
- "哈尔滨", "北安", "大庆", "大兴安岭", "鹤岗", "黑河", "佳木斯", "鸡西", "牡丹江", "齐齐哈尔",
- "七台河", "双鸭山", "绥化", "伊春");
- break;
- case "河南" :
- var cityOptions = new Array(
- "郑州", "安阳", "鹤壁", "潢川", "焦作", "济源", "开封", "漯河", "洛阳", "南阳", "平顶山",
- "濮阳", "三门峡", "商丘", "新乡", "信阳", "许昌", "周口", "驻马店");
- break;
- case "香港" :
- var cityOptions = new Array(
- "香港", "九龙", "新界");
- break;
- case "湖北" :
- var cityOptions = new Array(
- "武汉", "恩施", "鄂州", "黄冈", "黄石", "荆门", "荆州", "潜江", "十堰", "随州", "武穴",
- "仙桃", "咸宁", "襄阳", "襄樊", "孝感", "宜昌");
- break;
- case "湖南" :
- var cityOptions = new Array(
- "长沙", "常德", "郴州", "衡阳", "怀化", "吉首", "娄底", "邵阳", "湘潭", "益阳", "岳阳",
- "永州", "张家界", "株洲");
- break;
- case "江西" :
- var cityOptions = new Array(
- "南昌", "抚州", "赣州", "吉安", "景德镇", "井冈山", "九江", "庐山", "萍乡",
- "上饶", "新余", "宜春", "鹰潭");
- break;
- case "吉林" :
- var cityOptions = new Array(
- "长春", "吉林", "白城", "白山", "珲春", "辽源", "梅河", "四平", "松原", "通化", "延吉");
- break;
- case "辽宁" :
- var cityOptions = new Array(
- "沈阳", "鞍山", "本溪", "朝阳", "大连", "丹东", "抚顺", "阜新", "葫芦岛", "锦州",
- "辽阳", "盘锦", "铁岭", "营口");
- break;
- case "澳门" :
- var cityOptions = new Array("澳门");
- break;
- case "内蒙古" :
- var cityOptions = new Array(
- "呼和浩特", "阿拉善盟", "包头", "赤峰", "东胜", "海拉尔", "集宁", "临河", "通辽", "乌海",
- "乌兰浩特", "锡林浩特");
- break;
- case "宁夏" :
- var cityOptions = new Array(
- "银川", "固源", "石嘴山", "吴忠");
- break;
- case "青海" :
- var cityOptions = new Array(
- "西宁", "德令哈", "格尔木", "共和", "海东", "海晏", "玛沁", "同仁", "玉树");
- break;
- case "山东" :
- var cityOptions = new Array(
- "济南", "滨州", "兖州", "德州", "东营", "菏泽", "济宁", "莱芜", "聊城", "临沂",
- "蓬莱", "青岛", "曲阜", "日照", "泰安", "潍坊", "威海", "烟台", "枣庄", "淄博");
- break;
- case "山西" :
- var cityOptions = new Array(
- "太原", "长治", "大同", "候马", "晋城", "离石", "临汾", "宁武", "朔州", "忻州",
- "阳泉", "榆次", "运城");
- break;
- case "陕西" :
- var cityOptions = new Array(
- "西安", "安康", "宝鸡", "汉中", "渭南", "商州", "绥德", "铜川", "咸阳", "延安", "榆林");
- break;
- case "四川" :
- var cityOptions = new Array(
- "成都", "巴中", "达川", "德阳", "都江堰", "峨眉山", "涪陵", "广安", "广元", "九寨沟",
- "康定", "乐山", "泸州", "马尔康", "绵阳", "眉山", "南充", "内江", "攀枝花", "遂宁",
- "汶川", "西昌", "雅安", "宜宾", "自贡", "资阳");
- break;
- case "台湾" :
- var cityOptions = new Array(
- "台北", "基隆", "台南", "台中", "高雄", "屏东", "南投", "云林", "新竹", "彰化", "苗栗",
- "嘉义", "花莲", "桃园", "宜兰", "台东", "金门", "马祖", "澎湖");
- break;
- case "天津" :
- var cityOptions = new Array(
- "天津", "和平", "东丽", "河东", "西青", "河西", "津南", "南开", "北辰", "河北", "武清", "红挢",
- "塘沽", "汉沽", "大港", "宁河", "静海", "宝坻", "蓟县");
- break;
- case "新疆" :
- var cityOptions = new Array(
- "乌鲁木齐", "阿克苏", "阿勒泰", "阿图什", "博乐", "昌吉", "东山", "哈密", "和田", "喀什",
- "克拉玛依", "库车", "库尔勒", "奎屯", "石河子", "塔城", "吐鲁番", "伊宁");
- break;
- case "西藏" :
- var cityOptions = new Array(
- "拉萨", "阿里", "昌都", "林芝", "那曲", "日喀则", "山南");
- break;
- case "云南" :
- var cityOptions = new Array(
- "昆明", "大理", "保山", "楚雄", "大理", "东川", "个旧", "景洪", "开远", "临沧", "丽江",
- "六库", "潞西", "曲靖", "思茅", "文山", "西双版纳", "玉溪", "中甸", "昭通");
- break;
- case "浙江" :
- var cityOptions = new Array(
- "杭州", "安吉", "慈溪", "定海", "奉化", "海盐", "黄岩", "湖州", "嘉兴", "金华", "临安",
- "临海", "丽水", "宁波", "瓯海", "平湖", "千岛湖", "衢州", "江山", "瑞安", "绍兴", "嵊州",
- "台州", "温岭", "温州", "余姚", "舟山");
- break;
- case "海外" :
- var cityOptions = new Array(
- "美国", "日本", "英国", "法国", "德国", "其他");
- break;
- default:
- var cityOptions = new Array("");
- break;
- }
-
- cityField.options.length = 0;
- for (var i = 0; i < cityOptions.length; i++) {
- cityField.options[i] = new Option(cityOptions[i], cityOptions[i]);
- /*
- if (cityField.options[i].value==city)
- {
- //alert("here put City ok!");
- document.oblogform["city"].selectedIndex = i;
- }*/
- }
- }
-
function ifNameRepeat(){
//名称不能为空也不能重复
diff --git a/app/views/my/account.html.erb b/app/views/my/account.html.erb
index 589541c39..d356756c1 100644
--- a/app/views/my/account.html.erb
+++ b/app/views/my/account.html.erb
@@ -249,191 +249,6 @@
<% end %>
<% html_title(l(:label_course_all)) -%>
diff --git a/app/views/admin/create_syllabus.js.erb b/app/views/admin/create_syllabus.js.erb
new file mode 100644
index 000000000..ac37abd78
--- /dev/null
+++ b/app/views/admin/create_syllabus.js.erb
@@ -0,0 +1,10 @@
+hideModal();
+<%courses = Course.where("tea_id = #{@user.id}") %>
+<% unless courses.empty? %>
+ <% courses.each do |course|%>
+ $("#course_<%=course.id %>").html("<%=escape_javascript(render :partial => 'courselist_detail_tr', :locals => {:course => course}) %>");
+ <% end %>
+<% end %>
+<% if @flag == 1 %>
+ $("#course_<%=@course.id %>").html("");
+<% end %>
\ No newline at end of file
diff --git a/app/views/admin/excellent_courses.html.erb b/app/views/admin/excellent_courses.html.erb
index c107713a0..0418ebf30 100644
--- a/app/views/admin/excellent_courses.html.erb
+++ b/app/views/admin/excellent_courses.html.erb
@@ -16,7 +16,7 @@
序号
- 课程名
+ 班级名
主讲老师
diff --git a/app/views/admin/non_syllabus_courses.html.erb b/app/views/admin/non_syllabus_courses.html.erb
new file mode 100644
index 000000000..6c3cbec10
--- /dev/null
+++ b/app/views/admin/non_syllabus_courses.html.erb
@@ -0,0 +1,164 @@
+
+ <%= link_to l(:label_course_new), {:controller => 'courses', :action => 'new'}, :class => 'icon icon-add' %>
+
+
+
+ 未配置班级列表
+
+<%= render 'tab_syllabuses_courses' %>
+
+
+ 未配置班级列表
+
+
+<%= form_tag({}, :method => :get) do %>
+
+
+ 班级:
+
+ <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '班级、老师名称' %>
+ <%= submit_tag l(:button_apply), :class => "small", :name => nil %>
+ <%= link_to l(:button_clear), {:controller => 'admin', :action => 'non_syllabus_courses'}, :class => 'icon icon-reload' %>
+
+<% end %>
+
+
+
+
+
+
+
+<% html_title(l(:label_course_all)) -%>
diff --git a/app/views/admin/syllabuses.html.erb b/app/views/admin/syllabuses.html.erb
new file mode 100644
index 000000000..1066ac3ef
--- /dev/null
+++ b/app/views/admin/syllabuses.html.erb
@@ -0,0 +1,142 @@
+
+ 课程列表
+
+<%= render 'tab_syllabuses_courses' %>
+
+
+ 课程列表
+
+
+<%= form_tag({}, :method => :get) do %>
+
+
+ 课程:
+
+ <%= text_field_tag 'name', params[:name], :size => 30, :placeholder => '课程名称' %>
+ <%= submit_tag l(:button_apply), :class => "small", :name => nil %>
+ <%= link_to l(:button_clear), {:controller => 'admin', :action => 'syllabuses'}, :class => 'icon icon-reload' %>
+
+<% end %>
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/views/admin/update_course_name.js.erb b/app/views/admin/update_course_name.js.erb
new file mode 100644
index 000000000..2da524b5b
--- /dev/null
+++ b/app/views/admin/update_course_name.js.erb
@@ -0,0 +1 @@
+$("#rename_course_name_<%=@course.id %>").html("<%=@course.name %>");
\ No newline at end of file
diff --git a/app/views/layouts/base_admin.html.erb b/app/views/layouts/base_admin.html.erb
index cff80a15d..81cc2df9d 100644
--- a/app/views/layouts/base_admin.html.erb
+++ b/app/views/layouts/base_admin.html.erb
@@ -19,6 +19,10 @@
<%= call_hook :view_layouts_base_html_head %>
<%= yield :header_tags -%>
+
+
diff --git a/config/locales/courses/zh.yml b/config/locales/courses/zh.yml
index 1aa1ea666..29d6b236c 100644
--- a/config/locales/courses/zh.yml
+++ b/config/locales/courses/zh.yml
@@ -12,7 +12,7 @@ zh:
#
label_course_join_student: 加入班级
label_course_exit_student: 退出班级
- label_course_new: 新建课程
+ label_course_new: 新建班级
label_course_name: 课程名称
label_homework: 作业
diff --git a/config/locales/zh.yml b/config/locales/zh.yml
index fc3e39980..0220cd11c 100644
--- a/config/locales/zh.yml
+++ b/config/locales/zh.yml
@@ -482,9 +482,10 @@ zh:
label_show_contest: 显示竞赛
#by young
label_requirement: 需求
- label_new_course: 课程列表
- label_course_all: 课程列表
- label_excellent_courses_list: 精品课程列表
+ label_new_course: 班级列表
+ label_course_all: 班级列表
+ label_syllabus_all: 课程列表
+ label_excellent_courses_list: 精品班级列表
label_course_resource_list: 班级资源列表
label_project_resource_list: 項目资源列表
label_teacher_all: 所有教师
@@ -1367,7 +1368,7 @@ zh:
label_bid_reason_homework: 请输入作业提交说明!
label_create_new_projects: 创建项目
label_call_for_bids: 发布需求
- label_create_course: 创建课程
+ label_create_course: 创建班级
label_milestone: 里程碑
label_features: 特性
@@ -1488,7 +1489,7 @@ zh:
label_user_project: 项目
- label_user_course: 课程
+ label_user_course: 班级
label_user_homework: 作业
label_bid_if_agreement: 如果喜欢我,请点击我
@@ -1542,7 +1543,7 @@ zh:
label_teacher_work_unit: 教师单位
label_course_time: 课程年度
label_i_new_activity: 有了新活动在
- label_choose_course: 选择课程
+ label_choose_course: 选择班级
button_submit_homework: 提交作业
button_submit_bid: 参与竞标
label_requirement_from: 需求来源
@@ -1596,9 +1597,9 @@ zh:
#end
- label_joined_course: 参加的课程
- label_created_course: 创建的课程
- label_course: 课程
+ label_joined_course: 参加的班级
+ label_created_course: 创建的班级
+ label_course: 班级
label_public_info: (打钩为公开,不打钩则不公开,若不公开,仅项目成员可见该项目。)
diff --git a/config/routes.rb b/config/routes.rb
index 4465c9e1b..5717325e1 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -1027,7 +1027,10 @@ RedmineApp::Application.routes.draw do
match 'admin', :to => 'admin#index', :via => :get
match 'admin/projects', :via => :get
- get 'admin/courses'
+ get 'admin/courses', as: :all_courses
+ get 'admin/syllabuses', as: :all_syllabuses
+ get 'admin/non_syllabus_courses', as: :non_syllabus_courses
+ post 'admin/update_course_name'
get 'admin/excellent_courses', as: :excellent_courses
get 'admin/excellent_all_courses', as: :excellent_all_courses
match 'admin/set_excellent_course/:id', :to => 'admin#set_excellent_course'
@@ -1060,6 +1063,8 @@ RedmineApp::Application.routes.draw do
get 'admin/homework'
get 'admin/apply_for_homework'
get 'admin/code_work_tests'
+ post 'admin/select_course_syllabus'
+ post 'admin/create_syllabus'
resources :auth_sources do
member do
diff --git a/lib/redmine.rb b/lib/redmine.rb
index c0aa658ae..cfd8b6824 100644
--- a/lib/redmine.rb
+++ b/lib/redmine.rb
@@ -367,7 +367,7 @@ end
Redmine::MenuManager.map :admin_menu do |menu|
menu.push :organization, {:controller => 'admin', :action => 'organization'}, :caption => :label_organization_list
menu.push :projects, {:controller => 'admin', :action => 'projects'}, :caption => :label_project_plural
- menu.push :courses, {:controller => 'admin', :action => 'courses'}, :caption => :label_course_all
+ menu.push :syllabuses, {:controller => 'admin', :action => 'syllabuses'}, :caption => :label_course_all
menu.push :users, {:controller => 'admin', :action => 'users'}, :caption => :label_user_plural
menu.push :messages, {:controller => 'admin', :action => 'messages'}, :caption => :label_system_message
menu.push :schools, {:controller => 'admin', :action => 'schools'}, :caption => :label_school_plural
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 525a1fb1a..da833fe47 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1589,3 +1589,71 @@ function expand_course_list(id, target, btnid, count) {
}
}
+function regex_syllabus_name() {
+ var name = $.trim($("#new_syllabus_name").val());
+ if(name.length < 2)
+ {
+ $("#new_syllabus_name_notice").show();
+ return false;
+ }
+ else
+ {
+ $("#new_syllabus_name_notice").hide();
+ return true;
+ }
+}
+
+function alert_new_syllabus(course_id, flag){
+ htmlvalue = "
";
+ pop_up_box(htmlvalue,600,30,50);
+}
+
+function admin_new_syllabus(course_id, flag){
+ if(regex_syllabus_name()) {
+ $.ajax({
+ type: "post",
+ url: "/admin/create_syllabus",
+ data: {course_id: course_id,
+ title: $("#new_syllabus_name").val(),
+ eng_name: $("#new_syllabus_eng_name").val(),
+ flag: flag},
+ success: function (data) {
+ }
+ });
+ hideModal();
+ }
+}
+
+//执行修改courseName方法
+function updateCourseName(){
+ if(isdb){
+ isdb = false;
+ if($("#renameCourseName").val() == tagName){ //如果值一样,则恢复原来的状态
+ ele.parent().css("border","");
+ ele.parent().html(tagNameHtml);
+ }
+ else{
+ $.post(
+ '<%= admin_update_course_name_path %>',
+ {"course_id": tagId, "name": $("#renameCourseName").val().trim()}
+ );
+ }
+ }
+}
\ No newline at end of file
diff --git a/public/javascripts/course.js b/public/javascripts/course.js
index 8215f3aa1..0e60f01c9 100644
--- a/public/javascripts/course.js
+++ b/public/javascripts/course.js
@@ -224,20 +224,6 @@ function submit_new_syllabus()
}
}
-function regex_syllabus_name() {
- var name = $.trim($("#new_syllabus_name").val());
- if(name.length < 2)
- {
- $("#new_syllabus_name_notice").show();
- return false;
- }
- else
- {
- $("#new_syllabus_name_notice").hide();
- return true;
- }
-}
-
//课程讨论区
function regexTopicSubject() {
var name = $("#message_subject").val();
diff --git a/public/stylesheets/application.css b/public/stylesheets/application.css
index 3764ceb04..112f8224b 100644
--- a/public/stylesheets/application.css
+++ b/public/stylesheets/application.css
@@ -1409,6 +1409,7 @@ table td {padding:2px;}
table p {margin:0;}
.odd {background-color:#f6f7f8;}
.even {background-color: #fff;}
+.odd_grey {background-color: #b4b4b4}
a.sort { padding-right: 16px; background-position: 100% 50%; background-repeat: no-repeat; }
a.sort.asc { background-image: url(../images/sort_asc.png); }
@@ -2847,4 +2848,10 @@ img.school_avatar {
}
.admin_message_warn{font-size: 12px;color: red;}
-a.btn_message_free{ background:#15BCCF; display:block; text-align:center; color:#fff; padding:3px 0; width:60px; margin-bottom:10px;margin-left: 58px;}
\ No newline at end of file
+a.btn_message_free{ background:#15BCCF; display:block; text-align:center; color:#fff; padding:3px 0; width:60px; margin-bottom:10px;margin-left: 58px;}
+
+.course_syllabus_input{width:120px;}
+.name_input{ border:1px solid #64bdd9; height:16px; width:310px; background:#fff; margin-bottom:10px; padding:5px;}
+a.Blue-btn{ display:block; margin-right:15px;width:65px; height:22px; background-color:#ffffff; line-height:24px; vertical-align:middle; text-align:center; border:1px solid #3598db; color:#3598db; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px;}
+a:hover.Blue-btn{ background:#3598db; color:#fff;}
+.c_white {color:#fff;}
\ No newline at end of file
From a732efa6c6809596ee518120f4e738df3961b3a1 Mon Sep 17 00:00:00 2001
From: yuanke <249218296@qq.com>
Date: Thu, 7 Jul 2016 10:42:51 +0800
Subject: [PATCH 32/51] =?UTF-8?q?1.=E7=BB=84=E7=BB=87=E5=8A=A8=E6=80=81?=
=?UTF-8?q?=E4=B8=AD=E5=8E=BB=E6=8E=89=E8=AE=BE=E4=B8=BA=E9=A6=96=E9=A1=B5?=
=?UTF-8?q?=E7=9A=84=E6=96=87=E7=AB=A0=E5=8A=A8=E6=80=81=202.=E4=B8=AA?=
=?UTF-8?q?=E4=BA=BA=E4=B8=BB=E9=A1=B5=E5=8A=A8=E6=80=81=E4=B8=AD=E5=8E=BB?=
=?UTF-8?q?=E6=8E=89=E8=AE=BE=E4=B8=BA=E9=A6=96=E9=A1=B5=E7=9A=84=E5=8D=9A?=
=?UTF-8?q?=E5=AE=A2=E5=8A=A8=E6=80=81=E5=B9=B6=E5=B0=86=20=E6=9C=80?=
=?UTF-8?q?=E4=B8=8A=E9=9D=A2=E7=9A=84=E5=8D=9A=E5=AE=A2=E6=98=BE=E7=A4=BA?=
=?UTF-8?q?=E5=9B=9E=E5=A4=8D=E5=86=85=E5=AE=B9=E5=8F=8A=E5=8F=AF=E5=9B=9E?=
=?UTF-8?q?=E5=A4=8D?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/blog_comments_controller.rb | 3 ++
app/views/blog_comments/reply.js.erb | 5 +-
app/views/blogs/_homepage.html.erb | 49 +++++++++++++++++++
.../organizations/_org_activities.html.erb | 2 +-
app/views/users/_user_activities.html.erb | 4 +-
5 files changed, 60 insertions(+), 3 deletions(-)
diff --git a/app/controllers/blog_comments_controller.rb b/app/controllers/blog_comments_controller.rb
index 0224a587d..4a8de5814 100644
--- a/app/controllers/blog_comments_controller.rb
+++ b/app/controllers/blog_comments_controller.rb
@@ -116,6 +116,9 @@ class BlogCommentsController < ApplicationController
#回复
def reply
+ if params[:homepage]
+ @in_user_homepage = true
+ end
if params[:in_user_center]
@in_user_center = true
end
diff --git a/app/views/blog_comments/reply.js.erb b/app/views/blog_comments/reply.js.erb
index 915ab892d..baf4418e9 100644
--- a/app/views/blog_comments/reply.js.erb
+++ b/app/views/blog_comments/reply.js.erb
@@ -1,4 +1,7 @@
-<% if @in_user_center%>
+<% if @in_user_homepage %>
+ <% homepage = BlogComment.find(@user.blog.homepage_id) %>
+ $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/homepage', :locals => {:activity => homepage, :user_activity_id => homepage.id}) %>");
+<% elsif @in_user_center%>
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/user_blog', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>");
// init_activity_KindEditor_data(<%#= @user_activity_id%>,"","87%", 'UserActivity');
<% else%>
diff --git a/app/views/blogs/_homepage.html.erb b/app/views/blogs/_homepage.html.erb
index 5dbee59d6..140f547cb 100644
--- a/app/views/blogs/_homepage.html.erb
+++ b/app/views/blogs/_homepage.html.erb
@@ -48,4 +48,53 @@
+ <% count=activity.children.count %>
+
+ <%= render :partial => 'users/reply_banner', :locals => {:count => count, :activity => activity, :user_activity_id => user_activity_id} %>
+
+ <% comments = activity.children.reorder("created_on desc").limit(3) %>
+ <% if count > 0 %>
+
+ <%= render :partial => 'users/all_replies', :locals => {:comments => comments}%>
+
+ <% end %>
+
+ <% if activity.locked == false && User.current.logged?%>
+
+
<%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
+
+ <% if User.current.logged? %>
+
+ <%= form_for('new_form',:url => {:controller => 'blog_comments', :action => 'reply', :user_id=>activity.author_id,:blog_id=>activity.blog_id,:id=>activity.id,:homepage=>1},:method => "post", :remote => true) do |f|%>
+
+
+
+
+
+
+
+
+
发送
+
+
+ <% end%>
+
+ <% else %>
+ <%= render :partial => "users/show_unlogged" %>
+ <% end %>
+
+
+
+
+ <% end %>
+
+
\ No newline at end of file
diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb
index cc1404eb5..bddba3eee 100644
--- a/app/views/organizations/_org_activities.html.erb
+++ b/app/views/organizations/_org_activities.html.erb
@@ -46,7 +46,7 @@
<% end %>
- <% if act.org_act_type == 'OrgDocumentComment' %>
+ <% if act.org_act_type == 'OrgDocumentComment' && act.org_act.organization.home_id != act.org_act.id %>
<%= render :partial => 'show_org_document', :locals => {:document => act.org_act, :act => act, :flag => 2, :org_subfield_id => params[:org_subfield_id]} %>
<% end %>
<% end %>
diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb
index 5d06a7001..5c6f07bb1 100644
--- a/app/views/users/_user_activities.html.erb
+++ b/app/views/users/_user_activities.html.erb
@@ -93,7 +93,9 @@
<%# cache (act) do %>
<% case user_activity.act_type.to_s %>
<% when 'BlogComment' %>
- <%= render :partial => 'user_blog', :locals => {:activity => act,:user_activity_id =>user_activity.id} %>
+ <% if !(act.blog.homepage_id and act.id == act.blog.homepage_id) %>
+ <%= render :partial => 'user_blog', :locals => {:activity => act,:user_activity_id =>user_activity.id} %>
+ <% end %>
<% end %>
<%# end %>
<% end %>
From 92b6171c36d7fd931bd1210d23621018c6be7757 Mon Sep 17 00:00:00 2001
From: huang
Date: Thu, 7 Jul 2016 11:08:29 +0800
Subject: [PATCH 33/51] sonar error puts
---
.../quality_analysis_controller.rb | 25 ++++++++-----------
app/views/quality_analysis/create.html.erb | 20 ++++++++-------
.../repositories/_quality_analysis.html.erb | 2 +-
public/stylesheets/public.css | 4 +--
4 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb
index bec66aeff..4c67ef621 100644
--- a/app/controllers/quality_analysis_controller.rb
+++ b/app/controllers/quality_analysis_controller.rb
@@ -61,7 +61,7 @@ class QualityAnalysisController < ApplicationController
# 判断调用sonar分析是否成功
# 等待启动时间处理, 最长时间为30分钟
for i in 0..60 do
- sleep(60)
+ sleep(30)
@current_build_status = @client.job.get_current_build_status("#{job_name}")
if (@current_build_status != "not_run" || @current_build_status != "running")
break
@@ -74,23 +74,27 @@ class QualityAnalysisController < ApplicationController
@console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')
logger.info("@current_build_status is ==> #{@current_build_status}")
- logger.info("@console_build is ==> #{@console_build}")
-
d = @client.job.delete("#{job_name}") if jenkins_job == '200' && code != '201'
logger.error("delete result ==> #{code}")
+ if @current_build_status == "success"
+ SonarError.create()
+ end
if qa.blank? && @current_build_status == "success"
QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier,
:sonar_version => version, :path => path, :branch => branch, :language => language, :sonar_name => "#{user_name}:#{rep_id}")
else
- qa.update_attribute(:sonar_version, version)
+ qa.update_attribute(:sonar_version, version) unless qa.blank?
end
end
rescue => e
puts e
end
respond_to do |format|
- format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch, :current_build_status => @current_build_status, :job_name => job_name)}
- # format.js{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch)}
+ if @current_build_status == "success"
+ format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch, :current_build_status => @current_build_status, :job_name => job_name)}
+ elsif @current_build_status == "failure"
+ format.html
+ end
end
end
@@ -145,7 +149,7 @@ class QualityAnalysisController < ApplicationController
get_current_build_status = @client.job.get_current_build_status("Hjqreturn-1280")
logger.error("Failed to update job: ==> #{jenkins_job}") unless jenkins_job == '200'
- # 数据更新到Trustie数据库
+ # 数据更新到Trustie数据
if jenkins_job == '200'
logger.info("quality_ananlysis will be updated: ==> #{jenkins_job}")
@quality_analysis.path = path
@@ -168,18 +172,12 @@ class QualityAnalysisController < ApplicationController
@branch = params[:branch]
@resource_id = params[:resource_id]
@sonar_address = Redmine::Configuration['sonar_address']
- @jenkins_address = Redmine::Configuration['jenkins_address']
if params[:resource_id].nil?
@name_flag = true
projects_date = open(@sonar_address + "/api/projects/index").read
arr = JSON.parse(projects_date).map {|m| m["nm"]} # eg: ["Hjqreturn:cc_rep", "Hjqreturn:putong", "Hjqreturn:sonar_rep2", "shitou:sonar_rep"]
@quality_analyses = QualityAnalysis.where(:project_id => @project.id).select{|qa| arr.include?(qa.sonar_name)}
-
else
- if params[:current_build_status] == "failure"
- job_name = params[:job_name]
- @console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')["output"]
- end
complexity_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=sqale_rating,function_complexity,duplicated_lines_density,comment_lines_density,sqale_index,lines,file_line,files,functions,classes,directories").read
@complexity =JSON.parse(complexity_date).first
issue_date = open(@sonar_address + "/api/resources/index?resource=#{@resource_id}&depth=0&metrics=blocker_violations,critical_violations,major_violations,minor_violations,info_violations,violations").read
@@ -188,7 +186,6 @@ class QualityAnalysisController < ApplicationController
rescue => e
puts e
end
-
end
# Find project of id params[:project_id]
diff --git a/app/views/quality_analysis/create.html.erb b/app/views/quality_analysis/create.html.erb
index e7c81f662..a0a9d7254 100644
--- a/app/views/quality_analysis/create.html.erb
+++ b/app/views/quality_analysis/create.html.erb
@@ -1,9 +1,11 @@
-<% if @current_build_status == "success" %>
- <%= render :partial => "show", :locals => {:branch => params[:branch]} %>
-<% else %>
- <% if @build_console_result %>
- 运行结果超时
- <% else %>
- <%= render :partial => "console_output" %>
- <% end %>
-<% end %>
\ No newline at end of file
+
+
质量分析
+
+
+
本次分析失败,原因如下:
+ <% if @current_build_status == "failure" %>
+ <%= h @console_build.to_json %>
+ <% elsif @build_console_result == false %>
+ 分析超时
+ <% end %>
+
\ No newline at end of file
diff --git a/app/views/repositories/_quality_analysis.html.erb b/app/views/repositories/_quality_analysis.html.erb
index 0053849a3..936e513f5 100644
--- a/app/views/repositories/_quality_analysis.html.erb
+++ b/app/views/repositories/_quality_analysis.html.erb
@@ -15,7 +15,7 @@
<%= select_tag :language, options_for_select(["java","python","ruby","c++","c#","c"]), :id => 'branch', :class => "analysis-option-box" %>
-
+
diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css
index 7cfb7f9e0..9662181df 100644
--- a/public/stylesheets/public.css
+++ b/public/stylesheets/public.css
@@ -246,7 +246,7 @@ a.c_green{ color:#28be6c;}
.b_blue{background:#64bdd9;}
.b_green{background:#28be6c;}
.b_slow_yellow{background:#adde18;}
-.b_yellow{background:#DDDF0D;}
+.b_yellow{background:#e4de4b;}
.b_slow_red{background:#df8538;}
.b_green2 {background:#63c360;}
.b_red {background:#d60308;}
@@ -1184,4 +1184,4 @@ a.shadowbox_news_all{ display:block; width:305px; height:40px; line-height:40px;
.reply_iconup{ position:absolute; top:21px; left:13px; color:#d4d4d4; font-size:16px; background:#f1f1f1; line-height:13px;}
/*20160622代码分析弹窗*/
-.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;}
+.analysis-option-box {width:100%; border:1px solid #ccc; padding:3px 5px;}
From b90c90bc60c923d8225d6cf469adcc5d5aada794 Mon Sep 17 00:00:00 2001
From: huang
Date: Thu, 7 Jul 2016 14:22:48 +0800
Subject: [PATCH 34/51] add model error_list
---
.../quality_analysis_controller.rb | 39 +++++++++++++-----
app/models/sonar_error.rb | 3 ++
app/views/quality_analysis/create.html.erb | 6 +--
.../quality_analysis/error_list.html.erb | 11 +++++
config/routes.rb | 1 +
.../20160707031248_create_sonar_errors.rb | 11 +++++
db/schema.rb | 41 ++++++++++++++++---
spec/factories/sonar_errors.rb | 7 ++++
spec/models/sonar_error_spec.rb | 5 +++
9 files changed, 105 insertions(+), 19 deletions(-)
create mode 100644 app/models/sonar_error.rb
create mode 100644 app/views/quality_analysis/error_list.html.erb
create mode 100644 db/migrate/20160707031248_create_sonar_errors.rb
create mode 100644 spec/factories/sonar_errors.rb
create mode 100644 spec/models/sonar_error_spec.rb
diff --git a/app/controllers/quality_analysis_controller.rb b/app/controllers/quality_analysis_controller.rb
index 4c67ef621..f18cc7d46 100644
--- a/app/controllers/quality_analysis_controller.rb
+++ b/app/controllers/quality_analysis_controller.rb
@@ -72,18 +72,28 @@ class QualityAnalysisController < ApplicationController
end
end
- @console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')
+ # 获取sonar output结果
+ console_build = @client.job.get_console_output("#{job_name}", build_num = 0, start = 0, mode = 'text')
logger.info("@current_build_status is ==> #{@current_build_status}")
- d = @client.job.delete("#{job_name}") if jenkins_job == '200' && code != '201'
- logger.error("delete result ==> #{code}")
- if @current_build_status == "success"
- SonarError.create()
- end
- if qa.blank? && @current_build_status == "success"
- QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier,
- :sonar_version => version, :path => path, :branch => branch, :language => language, :sonar_name => "#{user_name}:#{rep_id}")
+
+ # 两种情况需要删除job:
+ # 1/创建成功但是build失败则删除job
+ # 2/creat和build成功,调用sonar启动失败则删除job
+ # 错误信息存储需存到Trustie数据库,否则一旦job删除则无法获取这些信息
+ if jenkins_job == '200' && code != '201'
+ @client.job.delete("#{job_name}")
else
- qa.update_attribute(:sonar_version, version) unless qa.blank?
+ if @current_build_status == "failure"
+ @sonar_error = SonarError.create(:project_id => @project.id, :jenkins_job_name => job_name, :output => console_build)
+ @client.job.delete("#{job_name}")
+ elsif @current_build_status == "success"
+ if qa.blank?
+ QualityAnalysis.create(:project_id => @project.id, :author_login => user_name, :rep_identifier => identifier,
+ :sonar_version => version, :path => path, :branch => branch, :language => language, :sonar_name => "#{user_name}:#{rep_id}")
+ else
+ qa.update_attribute(:sonar_version, version)
+ end
+ end
end
end
rescue => e
@@ -93,11 +103,18 @@ class QualityAnalysisController < ApplicationController
if @current_build_status == "success"
format.html{redirect_to project_quality_analysis_path(:project_id => @project.id, :resource_id => sonar_name, :branch => branch, :current_build_status => @current_build_status, :job_name => job_name)}
elsif @current_build_status == "failure"
- format.html
+ format.html{redirect_to error_list_project_quality_analysi_path(:project_id => @project.id, :job_name => job_name)}
end
end
end
+ def error_list
+ @error_list = SonarError.where(:jenkins_job_name => params[:job_name]).first
+ respond_to do |format|
+ format.html
+ end
+ end
+
# get language type
def swith_language_type language
if language == "c#"
diff --git a/app/models/sonar_error.rb b/app/models/sonar_error.rb
new file mode 100644
index 000000000..05fcfc5b9
--- /dev/null
+++ b/app/models/sonar_error.rb
@@ -0,0 +1,3 @@
+class SonarError < ActiveRecord::Base
+ attr_accessible :jenkins_job_name, :output, :project_id
+end
diff --git a/app/views/quality_analysis/create.html.erb b/app/views/quality_analysis/create.html.erb
index a0a9d7254..4f01fa2c8 100644
--- a/app/views/quality_analysis/create.html.erb
+++ b/app/views/quality_analysis/create.html.erb
@@ -3,9 +3,9 @@
本次分析失败,原因如下:
- <% if @current_build_status == "failure" %>
- <%= h @console_build.to_json %>
- <% elsif @build_console_result == false %>
+ <% if @build_console_result == false %>
分析超时
+ <% else %>
+ <%= h @sonar_error.to_json %>
<% end %>
\ No newline at end of file
diff --git a/app/views/quality_analysis/error_list.html.erb b/app/views/quality_analysis/error_list.html.erb
new file mode 100644
index 000000000..217990b13
--- /dev/null
+++ b/app/views/quality_analysis/error_list.html.erb
@@ -0,0 +1,11 @@
+
+
质量分析
+
+
+
本次分析失败,原因如下:
+ <% if @build_console_result == false %>
+ 分析超时
+ <% else %>
+ <%= h @error_list.to_json %>
+ <% end %>
+
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index bc9abeb35..0ef4c9fcb 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -797,6 +797,7 @@ RedmineApp::Application.routes.draw do
match 'update_jenkins_job'
match 'edit'
match 'create'
+ get 'error_list'
end
end
# resources :files, :only => [:index, :new, :create] do
diff --git a/db/migrate/20160707031248_create_sonar_errors.rb b/db/migrate/20160707031248_create_sonar_errors.rb
new file mode 100644
index 000000000..c55caccce
--- /dev/null
+++ b/db/migrate/20160707031248_create_sonar_errors.rb
@@ -0,0 +1,11 @@
+class CreateSonarErrors < ActiveRecord::Migration
+ def change
+ create_table :sonar_errors do |t|
+ t.integer :project_id
+ t.string :jenkins_job_name
+ t.text :output
+
+ t.timestamps
+ end
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index 3258f89c1..93dbba8a4 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20160627090316) do
+ActiveRecord::Schema.define(:version => 20160707031248) do
create_table "activities", :force => true do |t|
t.integer "act_id", :null => false
@@ -57,6 +57,18 @@ ActiveRecord::Schema.define(:version => 20160627090316) do
t.integer "user_id", :null => false
end
+ create_table "apply_add_schools", :force => true do |t|
+ t.string "name"
+ t.string "province"
+ t.string "city"
+ t.string "address"
+ t.string "remarks"
+ t.integer "school_id"
+ t.integer "status", :default => 0
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "apply_homeworks", :force => true do |t|
t.integer "status"
t.integer "user_id"
@@ -1633,10 +1645,11 @@ ActiveRecord::Schema.define(:version => 20160627090316) do
create_table "schools", :force => true do |t|
t.string "name"
t.string "province"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
t.string "logo_link"
t.string "pinyin"
+ t.integer "school_type", :default => 0
end
create_table "secdomains", :force => true do |t|
@@ -1725,6 +1738,14 @@ ActiveRecord::Schema.define(:version => 20160627090316) do
t.integer "project_id"
end
+ create_table "sonar_errors", :force => true do |t|
+ t.integer "project_id"
+ t.string "jenkins_job_name"
+ t.text "output"
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ end
+
create_table "ssos", :force => true do |t|
t.integer "user_id"
t.string "openid"
@@ -1849,8 +1870,18 @@ ActiveRecord::Schema.define(:version => 20160627090316) do
t.string "title"
t.text "description"
t.integer "user_id"
- t.datetime "created_at", :null => false
- t.datetime "updated_at", :null => false
+ t.datetime "created_at", :null => false
+ t.datetime "updated_at", :null => false
+ t.string "eng_name"
+ t.integer "syllabus_type"
+ t.integer "credit"
+ t.integer "hours"
+ t.integer "theory_hours"
+ t.integer "practice_hours"
+ t.string "applicable_major"
+ t.string "pre_course"
+ t.integer "visits", :default => 0
+ t.integer "des_status", :default => 0
end
add_index "syllabuses", ["user_id"], :name => "index_syllabuses_on_user_id"
diff --git a/spec/factories/sonar_errors.rb b/spec/factories/sonar_errors.rb
new file mode 100644
index 000000000..a5ed5485f
--- /dev/null
+++ b/spec/factories/sonar_errors.rb
@@ -0,0 +1,7 @@
+FactoryGirl.define do
+ factory :sonar_error do
+ project_id 1
+ jenkins_job_name "MyString"
+ output "MyText"
+ end
+end
diff --git a/spec/models/sonar_error_spec.rb b/spec/models/sonar_error_spec.rb
new file mode 100644
index 000000000..9aae8db29
--- /dev/null
+++ b/spec/models/sonar_error_spec.rb
@@ -0,0 +1,5 @@
+require 'rails_helper'
+
+RSpec.describe SonarError, :type => :model do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
From c621602050d9494455377d83b30a07e6421c23d3 Mon Sep 17 00:00:00 2001
From: daiao <358551898@qq.com>
Date: Thu, 7 Jul 2016 15:02:02 +0800
Subject: [PATCH 35/51] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BD=93=E9=BC=A0?=
=?UTF-8?q?=E6=A0=87=E7=A7=BB=E8=87=B3=E5=8C=BA=E5=9F=9F=E5=86=85=E6=89=8D?=
=?UTF-8?q?=E4=BC=9A=E6=98=BE=E7=A4=BAicon?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/views/layouts/_syllabus_base_info.html.erb | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/app/views/layouts/_syllabus_base_info.html.erb b/app/views/layouts/_syllabus_base_info.html.erb
index ae6da2ac3..4b205d356 100644
--- a/app/views/layouts/_syllabus_base_info.html.erb
+++ b/app/views/layouts/_syllabus_base_info.html.erb
@@ -1,6 +1,6 @@
-
+
<% if User.current.logged? && (User.current == syllabus.user || User.current.admin?) %>
- <%= link_to image_tag("../images/signature_edit.png",width:"12px", height: "12px"), "javascript:void(0);", :class => 'fr', :onclick => "show_edit_base_info();"%>
+ <%= link_to image_tag("../images/signature_edit.png",width:"12px", height: "12px"), "javascript:void(0);", :id => 'signature_edit', :class => 'fr', :onclick => "show_edit_base_info();"%>
<% end %>
创建教师: <%=syllabus.user.show_name %>
From da7509f64cf9f1c924e17747e9449a7b94f191c5 Mon Sep 17 00:00:00 2001
From: cxt
Date: Thu, 7 Jul 2016 15:04:57 +0800
Subject: [PATCH 36/51] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E5=A4=A7=E7=BA=B2?=
=?UTF-8?q?=E7=9A=84=E4=BC=98=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
app/controllers/syllabuses_controller.rb | 12 +++++++-
app/helpers/application_helper.rb | 2 +-
app/helpers/courses_helper.rb | 6 ++--
app/views/courses/new.html.erb | 2 +-
app/views/courses/settings.html.erb | 2 +-
app/views/layouts/_project_info.html.erb | 30 ++++++++++---------
app/views/layouts/_syllabus_info.html.erb | 25 +++++++++-------
app/views/layouts/_syllabus_title.html.erb | 5 ++++
app/views/layouts/base_syllabus.html.erb | 4 +--
.../syllabuses/edit_syllabus_title.js.erb | 3 ++
config/routes.rb | 1 +
public/javascripts/syllabus.js | 18 +++++++++++
public/stylesheets/leftside.css | 2 +-
public/stylesheets/syllabus.css | 6 ++--
14 files changed, 81 insertions(+), 37 deletions(-)
create mode 100644 app/views/layouts/_syllabus_title.html.erb
create mode 100644 app/views/syllabuses/edit_syllabus_title.js.erb
diff --git a/app/controllers/syllabuses_controller.rb b/app/controllers/syllabuses_controller.rb
index 8ff88823d..8d7195f38 100644
--- a/app/controllers/syllabuses_controller.rb
+++ b/app/controllers/syllabuses_controller.rb
@@ -6,7 +6,7 @@ class SyllabusesController < ApplicationController
include CoursesHelper
before_filter :is_logged, :only => [:index, :show, :edit, :new, :update, :destroy, :delete_syllabus]
- before_filter :find_syllabus, :only => [:show, :edit, :update, :destroy, :syllabus_courselist, :edit_syllabus_eng_name, :update_base_info, :delete_syllabus, :delete_des]
+ before_filter :find_syllabus, :only => [:show, :edit, :update, :destroy, :syllabus_courselist, :edit_syllabus_eng_name, :edit_syllabus_title, :update_base_info, :delete_syllabus, :delete_des]
def index
user = User.current
@syllabuses = user.syllabuses
@@ -140,6 +140,16 @@ class SyllabusesController < ApplicationController
end
end
+ #修改课程名称
+ def edit_syllabus_title
+ if @syllabus && params[:title] != ""
+ @syllabus.update_column("title",params[:title])
+ end
+ respond_to do |format|
+ format.js
+ end
+ end
+
#修改英文名称
def edit_syllabus_eng_name
if @syllabus
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index e4fa452f5..5b18908d4 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -3323,7 +3323,7 @@ def get_group_member_names work
result
end
-def course_syllabus_option user
+def course_syllabus_option user = User.current
syllabuses = user.syllabuses
type = []
option1 = []
diff --git a/app/helpers/courses_helper.rb b/app/helpers/courses_helper.rb
index 55a4da73a..d1f4bfe97 100644
--- a/app/helpers/courses_helper.rb
+++ b/app/helpers/courses_helper.rb
@@ -772,12 +772,12 @@ module CoursesHelper
url = joined ? join_path(:object_id => course.id) : try_join_path(:object_id => course.id)
method = joined ? 'delete' : 'post'
if joined
- link = link_to(text, url, :remote => true, :method => method, :class => "pr_join_a", :id => "#{course.id}", :confirm => l(:text_are_you_sure_out))
+ link = link_to(text, url, :remote => true, :method => method, :class => "Blue-btn", :style => "margin_left: 0px;", :id => "#{course.id}", :confirm => l(:text_are_you_sure_out))
else
- link = link_to(text, url, :remote => true, :method => method, :id => "#{course.id}", :class => "pr_join_a")
+ link = link_to(text, url, :remote => true, :method => method, :id => "#{course.id}", :class => "Blue-btn", :style => "margin_left: 0px;")
end
else
- link = "#{l(:label_course_join_student)} "
+ link = "#{l(:label_course_join_student)} "
end
link.html_safe
end
diff --git a/app/views/courses/new.html.erb b/app/views/courses/new.html.erb
index f8db461a6..78b3d8293 100644
--- a/app/views/courses/new.html.erb
+++ b/app/views/courses/new.html.erb
@@ -7,7 +7,7 @@
* <%= l(:label_tags_syllabus_name)%> :
<% if @syllabus.nil? %>
- <%= select_tag :syllabus_id,options_for_select(syllabus_option,@course.syllabus_id), {:id=>"new_syllabus_id", :class=>"syllabus_input"} %>
+ <%= select_tag :syllabus_id,options_for_select(course_syllabus_option,@course.syllabus_id), {:id=>"new_syllabus_id", :class=>"syllabus_input"} %>
<% else %>
<%=@syllabus.title %>
diff --git a/app/views/courses/settings.html.erb b/app/views/courses/settings.html.erb
index 10bb0ed55..ee0f6c98a 100644
--- a/app/views/courses/settings.html.erb
+++ b/app/views/courses/settings.html.erb
@@ -31,7 +31,7 @@
* <%= l(:label_tags_syllabus_name)%> :
- <%= select_tag :syllabus_id,options_for_select(syllabus_option,@course.syllabus_id), {:id=>"edit_syllabus_id", :class=>"syllabus_input", :style=>'width:280px'} %>
+ <%= select_tag :syllabus_id,options_for_select(course_syllabus_option,@course.syllabus_id), {:id=>"edit_syllabus_id", :class=>"syllabus_input", :style=>'width:280px'} %>
如果列表中没有对应的课程,请您先<%=link_to '创建课程', new_syllabus_path(),:target => '_blank', :class => 'ml5 green_btn_share c_white'%>
diff --git a/app/views/layouts/_project_info.html.erb b/app/views/layouts/_project_info.html.erb
index c0366ec39..b0407e2c5 100644
--- a/app/views/layouts/_project_info.html.erb
+++ b/app/views/layouts/_project_info.html.erb
@@ -8,30 +8,29 @@
<% end %>
<%= image_tag(url_to_avatar(@course), :width => "60", :height => "60") %>
-
+
-
- <% unless is_teacher %>
-
- <% end %>
+
+
- 邀请码:
- <%=@course.generate_invite_code %>
+ 邀请码:
+ <%=@course.generate_invite_code %>
+ <% unless is_teacher %>
+
+ <% end %>
+