From 3476731b83a418fa31153866e64245a6ecb16554 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 9 Dec 2015 09:59:13 +0800 Subject: [PATCH 01/80] =?UTF-8?q?=E5=B0=86at=20js=20data=E6=95=B4=E5=90=88?= =?UTF-8?q?=E5=88=B0=E6=96=87=E4=BB=B6=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/at_controller.rb | 25 +++++++++++++++++++++++ app/controllers/issues_controller.rb | 29 ++++++++++----------------- app/helpers/application_helper.rb | 10 +-------- app/views/at/show.js.erb | 8 ++++++++ app/views/issues/show.html.erb | 2 +- config/routes.rb | 3 ++- public/assets/kindeditor/at/config.js | 5 ++--- 7 files changed, 50 insertions(+), 32 deletions(-) create mode 100644 app/controllers/at_controller.rb create mode 100644 app/views/at/show.js.erb diff --git a/app/controllers/at_controller.rb b/app/controllers/at_controller.rb new file mode 100644 index 000000000..92506d4e8 --- /dev/null +++ b/app/controllers/at_controller.rb @@ -0,0 +1,25 @@ +#coding=utf-8 + +class AtController < ApplicationController + respond_to :js + + def show + type = params[:type] + case type + when "Issue" + @users = find_issue(params) + else + end + end + + private + def find_issue(params) + #1. issues list persons + #2. project persons + issue = Issue.find(params[:id]) + journals = issue.journals + at_persons = journals.map(&:user) + issue.project.users + at_persons.uniq{|u| u.id}.delete_if{|u| u.id == User.current.id} + end + +end \ No newline at end of file diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 7cdc838e2..6f441c29a 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -142,24 +142,17 @@ class IssuesController < ApplicationController @project_base_tag = (params[:project_id] || @issue.project) ? 'base_projects':'base'#by young @available_watchers = (@issue.project.users.sort + @issue.watcher_users).uniq - #id name email - #1. issues list persons - #2. project persons - @at_persons = @journals.map(&:user) + @issue.project.users - @at_persons = @at_persons.uniq{|u| u.id}.delete_if{|u| u.id == User.current.id} - @at_persons = nil - - respond_to do |format|`` - format.html { - retrieve_previous_and_next_issue_ids - render :template => 'issues/show', :layout => @project_base_tag#by young - } - format.api - format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } - format.pdf { - pdf = issue_to_pdf(@issue, :journals => @journals) - send_data(pdf, :type => 'application/pdf', :filename => filename_for_content_disposition("#{@project.identifier}-#{@issue.id}.pdf") ) - } + respond_to do |format| + format.html { + retrieve_previous_and_next_issue_ids + render :template => 'issues/show', :layout => @project_base_tag#by young + } + format.api + format.atom { render :template => 'journals/index', :layout => false, :content_type => 'application/atom+xml' } + format.pdf { + pdf = issue_to_pdf(@issue, :journals => @journals) + send_data(pdf, :type => 'application/pdf', :filename => filename_for_content_disposition("#{@project.identifier}-#{@issue.id}.pdf") ) + } end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ba8fe4f53..227de930f 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2624,15 +2624,7 @@ int main(int argc, char** argv){ opt = {enable_at: true, prettify: false, init_activity: false}.merge default_opt ss = '' if opt[:enable_at] - ss = '" + ss += %Q|| end ss += javascript_include_tag("/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg') diff --git a/app/views/at/show.js.erb b/app/views/at/show.js.erb new file mode 100644 index 000000000..df253f237 --- /dev/null +++ b/app/views/at/show.js.erb @@ -0,0 +1,8 @@ +(function(){ + window.atPersonLists = []; + <% @users && @users.each_with_index do |person,index| %> + var o = {id: <%=index%>, name: '<%=person.show_name%>', login: '<%=person.login%>', searchKey: '<%=person.get_at_show_name%>'}; + atPersonLists.push(o); + <% end %> + +})(); diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index 80d3aaac1..67d1186c4 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -1,5 +1,5 @@ <%= content_for(:header_tags) do %> -<%= import_ke(enable_at: true) %> +<%= import_ke(enable_at: {id: @issue.id, type: 'Issue'}) %> <% end %>
diff --git a/config/routes.rb b/config/routes.rb index 59eb29d70..656f55720 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1035,13 +1035,14 @@ RedmineApp::Application.routes.draw do match 'system_log/clear' ##ended by lizanle - resources :git_callback do collection do post 'post_update' end end + resources :at + Dir.glob File.expand_path("plugins/*", Rails.root) do |plugin_dir| file = File.join(plugin_dir, "config/routes.rb") if File.exists?(file) diff --git a/public/assets/kindeditor/at/config.js b/public/assets/kindeditor/at/config.js index b9769c42e..0a1bbf11a 100644 --- a/public/assets/kindeditor/at/config.js +++ b/public/assets/kindeditor/at/config.js @@ -1,4 +1,4 @@ -function enableAt(_editor) { +var enableAt = function(_editor) { var editor = _editor; if(editor.edit == undefined || editor.edit.iframe == undefined){ return; @@ -11,7 +11,7 @@ function enableAt(_editor) { console.log("enable at"); $.fn.atwho.debug = true; - if(!atPersonLists){ + if("undefined" === (typeof atPersonLists) || !atPersonLists){ return; } var names = atPersonLists; @@ -32,7 +32,6 @@ function enableAt(_editor) { } $inputor = $(ifrBody).atwho(at_config); - window.aaa= $inputor; $inputor.caret('pos', 47); $inputor.focus().atwho('run'); }; From 91b245ad2cb694726996c31811276b5129a0be7e Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sat, 12 Dec 2015 18:06:59 +0800 Subject: [PATCH 02/80] =?UTF-8?q?lastname=E4=B8=BA=E7=A9=BA=E6=97=B6?= =?UTF-8?q?=E4=B9=9F=E5=8F=AF=E4=BB=A5=E5=8A=A0,=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E7=9C=81=E6=8E=89=E6=9F=A5=E8=AF=A2extensions=E7=9A=84?= =?UTF-8?q?=E8=AF=AD=E5=8F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/user.rb | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/app/models/user.rb b/app/models/user.rb index 65c0bf858..0d3d465e2 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -399,16 +399,7 @@ class User < Principal end def show_name - name = "" - unless self.user_extensions.nil? - if self.user_extensions.identity == 2 - name = firstname - else - name = lastname+firstname - end - else - name = lastname+firstname - end + name = lastname + firstname name.empty? || name.nil? ? login : name end ## end From 9b86ec30445a0ad2682ee91361ecbbf2a0019543 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 14 Dec 2015 10:07:55 +0800 Subject: [PATCH 03/80] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/_search_all_results.html.erb | 4 ++-- app/views/welcome/_search_memo_results.html.erb | 2 +- app/views/welcome/_search_project_results.html.erb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/views/welcome/_search_all_results.html.erb b/app/views/welcome/_search_all_results.html.erb index 34ef9a8eb..7256534e5 100644 --- a/app/views/welcome/_search_all_results.html.erb +++ b/app/views/welcome/_search_all_results.html.erb @@ -67,7 +67,7 @@
  • <%= item.try(:highlight).try(:description) ? item.highlight.description[0].html_safe : item.description%>
  • -
  • 管理人员:<%= item.user_id ? User.find(item.user_id).login : '无' %>创建时间:<%= date_format_local( Project.find(item.id).created_on) %>
  • +
  • 管理人员:<%= item.user_id ? User.find(item.user_id).login : '无' %>更新时间:<%= date_format_local( Project.find(item.id).updated_on) %>
  • @@ -83,7 +83,7 @@
  • <%= item.try(:highlight).try(:content) ? item.highlight.content[0].html_safe : item.content.html_safe%>
  • -
  • 发帖人:<%= item.author_id ? User.find(item.author_id).login : '无' %>创建时间:<%= format_date( item.created_at) %>
  • +
  • 发帖人:<%= item.author_id ? User.find(item.author_id).login : '无' %>更新时间:<%= format_date( item.updated_at) %>
  • diff --git a/app/views/welcome/_search_memo_results.html.erb b/app/views/welcome/_search_memo_results.html.erb index c5fe9cc72..98f9ae7f0 100644 --- a/app/views/welcome/_search_memo_results.html.erb +++ b/app/views/welcome/_search_memo_results.html.erb @@ -12,7 +12,7 @@
  • <%= memo.try(:highlight).try(:content) ? memo.highlight.content[0].html_safe : memo.content.html_safe%>
  • -
  • 发帖人:<%= memo.author_id ? User.find(memo.author_id).login : '无' %>创建时间:<%= format_date( memo.created_at) %>
  • +
  • 发帖人:<%= memo.author_id ? User.find(memo.author_id).login : '无' %>更新时间:<%= format_date( memo.updated_at) %>
  • diff --git a/app/views/welcome/_search_project_results.html.erb b/app/views/welcome/_search_project_results.html.erb index b3ed44654..5775a939d 100644 --- a/app/views/welcome/_search_project_results.html.erb +++ b/app/views/welcome/_search_project_results.html.erb @@ -12,7 +12,7 @@
  • <%= project.try(:highlight).try(:description) ? project.highlight.description[0].html_safe : project.description%>
  • -
  • 管理人员:<%= project.user_id ? User.find(project.user_id).login : '无' %>创建时间:<%= date_format_local( Project.find(project.id).created_on) %>
  • +
  • 管理人员:<%= project.user_id ? User.find(project.user_id).login : '无' %>更新时间:<%= date_format_local( Project.find(project.id).updated_on) %>
  • From f6867068f532de4259e863c7783e313852ff07a9 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 14 Dec 2015 10:27:30 +0800 Subject: [PATCH 04/80] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=20=E5=B8=96=E5=AD=90?= =?UTF-8?q?=20=20=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4=20=E8=B5=84=E6=BA=90?= =?UTF-8?q?=20=E4=B8=8B=E8=BD=BD=E6=AC=A1=E6=95=B0=20=E7=94=A8=E6=88=B7=20?= =?UTF-8?q?=E6=9C=80=E5=90=8E=E7=99=BB=E9=99=86=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/welcome/_search_all_results.html.erb | 9 +++++++-- app/views/welcome/_search_attachment_results.html.erb | 4 +++- app/views/welcome/_search_user_results.html.erb | 4 +++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/views/welcome/_search_all_results.html.erb b/app/views/welcome/_search_all_results.html.erb index 7256534e5..537da336a 100644 --- a/app/views/welcome/_search_all_results.html.erb +++ b/app/views/welcome/_search_all_results.html.erb @@ -17,7 +17,10 @@
  • <%= 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)%><%= User.find(item.id).user_extensions.occupation.present? ? '单位:'+User.find(item.id).user_extensions.occupation : ''%>
  • +
  • + 加入时间:<%= format_date( User.find(item.id).created_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 : ''%>
  • @@ -51,7 +54,9 @@
  • 发布者:<%= User.find(item.author_id).login%>(<%= User.find(item.author_id).realname%>) - 发布时间:<%= format_date(item.created_on)%>
  • + 发布时间:<%= format_date(item.created_on)%> + 下载次数:<%= item.downloads%>次 +
    diff --git a/app/views/welcome/_search_attachment_results.html.erb b/app/views/welcome/_search_attachment_results.html.erb index 36c4fcbab..21ba68336 100644 --- a/app/views/welcome/_search_attachment_results.html.erb +++ b/app/views/welcome/_search_attachment_results.html.erb @@ -12,7 +12,9 @@
  • 发布者:<%= User.find(attachment.author_id).login%>(<%= User.find(attachment.author_id).realname%>) - 发布时间:<%= format_date(attachment.created_on)%>
  • + 发布时间:<%= format_date(attachment.created_on)%> + 下载次数:<%= attachment.downloads%>次 +
    diff --git a/app/views/welcome/_search_user_results.html.erb b/app/views/welcome/_search_user_results.html.erb index 459d3a27b..d1c8c2393 100644 --- a/app/views/welcome/_search_user_results.html.erb +++ b/app/views/welcome/_search_user_results.html.erb @@ -12,7 +12,9 @@
  • <%= 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)%><%= User.find(user.id).user_extensions.occupation.present? ? '单位:'+User.find(user.id).user_extensions.occupation : ''%>
  • +
  • 加入时间:<%= format_date( User.find(user.id).created_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 c004b059913b3999ade0434c7a3d25dc7842daf3 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Mon, 14 Dec 2015 10:52:19 +0800 Subject: [PATCH 05/80] =?UTF-8?q?=E8=B5=84=E6=BA=90=E5=BA=93=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=20sql=E6=B3=A8=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/users_controller.rb | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 834009d71..c20282a45 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1857,46 +1857,46 @@ class UsersController < ApplicationController # 根据资源关键字进行搜索 def resource_search - search = params[:search].to_s.strip.downcase + search = "%#{params[:search].strip.downcase}%" if(params[:type].nil? || params[:type].blank? || params[:type] == "1" || params[:type] == 'all') #全部 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} #我的资源库的话,那么应该是我上传的所有资源 加上 我加入的课程的所有资源 取交集并查询 @attachments = Attachment.where("((author_id = #{params[:id]} and container_type in('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon')) "+ - " or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like '%#{search}%') ").order("created_on desc") + " or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')}))) and (filename like :p) ",:p=>search).order("created_on desc") else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type in" + " ('Project','Principal','Course','Issue','Document','Message','News','StudentWorkScore','HomewCommon'))"+ " or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )" + - " and (filename like '%#{search}%') ").order("created_on desc") + " and (filename like :p) ",:p=>search).order("created_on desc") end elsif params[:type] == "2" #课程资源 if User.current.id.to_i == params[:id].to_i user_course_ids = User.current.courses.map { |c| c.id} - @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like '%#{search}%') ").order("created_on desc") + @attachments = Attachment.where("(author_id = #{params[:id]} and container_type = 'Course') or (container_type = 'Course' and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) and (filename like :p) ",:p=>search).order("created_on desc") else user_course_ids = User.find(params[:id]).courses.visible.map { |c| c.id} #如果课程私有资源,那么要看这个资源的课程是不是在 这个user的所有我可见的课程中 @attachments = Attachment.where("((author_id = #{params[:id]} and is_public = 1 and container_type = 'Course') "+ "or (container_type = 'Course' and is_public = 1 and container_id in (#{user_course_ids.empty? ? '0': user_course_ids.join(',')})) )"+ - " and (filename like '%#{search}%') ").order("created_on desc") + " and (filename like :p) ",:p=>search).order("created_on desc") end elsif params[:type] == "3" #项目资源 if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like '%#{search}%')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Project' and (filename like :p)",:p=>search).order("created_on desc") else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' and (filename like '%#{search}%') ").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Project' and (filename like :p) ",:p=>search).order("created_on desc") end elsif params[:type] == "4" #附件 if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type in('Project','Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("created_on desc") else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like '%#{search}%')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type in('Issue','Document','Message','News','StudentWorkScore','HomewCommon') and (filename like :p)",:p=>search).order("created_on desc") end elsif params[:type] == "5" #用户资源 if User.current.id.to_i == params[:id].to_i - @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and container_type = 'Principal' and (filename like :p)",:p=>search).order("created_on desc") else - @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like '%#{search}%')").order("created_on desc") + @attachments = Attachment.where("author_id = #{params[:id]} and is_public = 1 and container_type = 'Principal' and (filename like :p)",:p=>search).order("created_on desc") end end @type = params[:type] From 5ca8d4cd66cd77c5fa6d99c30f0c3a2ba6acace8 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 14 Dec 2015 10:54:37 +0800 Subject: [PATCH 06/80] =?UTF-8?q?=E4=BF=AE=E6=94=B9http=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E6=8D=A2=E5=9F=9F=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_base_footer_public.html.erb | 4 ++-- app/views/layouts/_footer.html.erb | 2 +- app/views/layouts/_logined_header.html.erb | 2 +- app/views/layouts/_unlogin_header.html.erb | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/views/layouts/_base_footer_public.html.erb b/app/views/layouts/_base_footer_public.html.erb index dba26f1f6..eb2e83ba2 100644 --- a/app/views/layouts/_base_footer_public.html.erb +++ b/app/views/layouts/_base_footer_public.html.erb @@ -2,9 +2,9 @@
    • <%= l(:label_about_us)%>|
    • -
    • <%= l(:label_contact_us)%>|
    • +
    • <%= l(:label_contact_us)%>|
    • <%= l(:label_recruitment_information)%>|
    • -
    • <%= l(:label_surpport_group)%>|
    • +
    • <%= link_to l(:label_surpport_group), "https://#{Setting.host_name}/forums/1/memos/1168", :class => "f_grey mw20", :target=>"_blank" %>|
    • <%= l(:label_forums)%>|
    • <%= l(:label_language)%> " id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的课程、项目、用户以及资源"/> + " id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的课程、项目、用户、资源以及帖子"/> diff --git a/app/views/layouts/_unlogin_header.html.erb b/app/views/layouts/_unlogin_header.html.erb index 162f59ed4..7a2196d01 100644 --- a/app/views/layouts/_unlogin_header.html.erb +++ b/app/views/layouts/_unlogin_header.html.erb @@ -52,7 +52,7 @@ <% name = name%> <%= form_tag({controller: :welcome, action: :search },:class=>'navHomepageSearchBox', method: :get) do %> - " id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的课程、项目、用户以及资源" onkeypress="search_in_header_I(event,$(this));"/> + " id="navHomepageSearchInput" class="navHomepageSearchInput" placeholder="请输入关键词搜索公开的课程、项目、用户、资源以及帖子" onkeypress="search_in_header_I(event,$(this));"/> From f61f639af2fe13598a74d1e35507470b15d735e1 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Mon, 14 Dec 2015 17:13:57 +0800 Subject: [PATCH 11/80] =?UTF-8?q?=E8=BD=AC=E6=8D=A2=E4=B8=BAremote=20js?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/at_controller.rb | 134 ++++++++++++++++-- app/helpers/application_helper.rb | 19 ++- app/views/at/show.js.erb | 8 -- app/views/at/show.json.erb | 6 + app/views/bids/_new_homework_form.html.erb | 4 +- app/views/blog_comments/_edit.html.erb | 6 +- app/views/blog_comments/_reply_form.html.erb | 6 +- app/views/blog_comments/quote.js.erb | 2 +- app/views/blog_comments/reply.js.erb | 4 +- app/views/blog_comments/show.html.erb | 2 +- app/views/blogs/_article_list.html.erb | 2 +- app/views/boards/_course_new.html.erb | 6 +- app/views/boards/_course_show.html.erb | 2 +- app/views/comments/create.js.erb | 2 +- app/views/courses/_course_activity.html.erb | 6 +- app/views/courses/_courses_jours.html.erb | 5 +- app/views/courses/syllabus.html.erb | 4 +- .../start_anonymous_comment.js.erb | 4 +- .../stop_anonymous_comment.js.erb | 4 +- app/views/issues/_edit.html.erb | 5 +- app/views/issues/_form.html.erb | 2 +- app/views/issues/add_journal.js.erb | 2 +- app/views/issues/add_journal_in_org.js.erb | 2 +- app/views/issues/new.html.erb | 2 +- app/views/issues/show.html.erb | 2 +- app/views/memos/show.html.erb | 2 +- app/views/messages/_course_show.html.erb | 2 +- app/views/messages/quote.js.erb | 2 +- app/views/messages/reply.js.erb | 2 +- .../_reply_form.html.erb | 2 +- .../org_document_comments/add_reply.js.erb | 2 +- .../org_document_comments/index.html.erb | 2 +- app/views/org_document_comments/quote.js.erb | 2 +- app/views/org_document_comments/show.html.erb | 2 +- .../organizations/_org_activities.html.erb | 2 +- app/views/organizations/show.html.erb | 2 +- .../forbidden_anonymous_comment.js.erb | 4 +- app/views/student_work/set_score_rule.js.erb | 4 +- app/views/users/_user_activities.html.erb | 6 +- app/views/users/_user_homework_form.html.erb | 6 +- app/views/users/_user_homework_list.html.erb | 6 +- app/views/words/create_reply.js.erb | 2 +- app/views/words/leave_homework_message.js.erb | 4 +- .../lib/rails_kindeditor/helper.rb | 13 +- public/assets/kindeditor/at/config.js | 17 ++- .../javascripts/init_activity_KindEditor.js | 9 +- 46 files changed, 242 insertions(+), 92 deletions(-) delete mode 100644 app/views/at/show.js.erb create mode 100644 app/views/at/show.json.erb diff --git a/app/controllers/at_controller.rb b/app/controllers/at_controller.rb index 92506d4e8..3759abf53 100644 --- a/app/controllers/at_controller.rb +++ b/app/controllers/at_controller.rb @@ -1,25 +1,143 @@ #coding=utf-8 class AtController < ApplicationController - respond_to :js + respond_to :json def show - type = params[:type] + @logger = Logger.new(Rails.root.join('log', 'at.log').to_s) + users = find_at_users(params[:type], params[:id]) + @users = users.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id } + end + + private + def find_at_users(type, id) + @logger.info("#{type}, #{id}") case type when "Issue" - @users = find_issue(params) + find_issue(id) + when 'Project' + find_project(id) + when 'Course' + find_course(id) + when 'Activity', 'CourseActivity', 'ForgeActivity','UserActivity', 'OrgActivity','PrincipalActivity' + find_activity(id, type) + when 'Attachment' + find_attachment(id) + when 'Message' + find_message(id) else + nil end end - private - def find_issue(params) + def find_issue(id) #1. issues list persons #2. project persons - issue = Issue.find(params[:id]) - journals = issue.journals + issue = Issue.find(id) + journals = issue.journals at_persons = journals.map(&:user) + issue.project.users - at_persons.uniq{|u| u.id}.delete_if{|u| u.id == User.current.id} + at_persons.uniq { |u| u.id }.delete_if { |u| u.id == User.current.id } + end + + def find_project(id) + at_persons = Project.find(id).users + at_persons.delete_if { |u| u.id == User.current.id } + end + + def find_course(id) + at_persons = Course.find(id).users + at_persons.delete_if { |u| u.id == User.current.id } + end + + def find_activity(id, type) + + ## 基本上是本类型中的 加上所属类型的用户 + case type + when 'Activity' + activity = Activity.find(id) + (find_at_users(activity.act_type, activity.act_id) ||[]) + + (find_at_users(activity.activity_container_type, activity.activity_container_id) || []) + when 'CourseActivity' + activity = CourseActivity.find(id) + (find_at_users(activity.course_act_type, activity.course_act_id) || []) + (find_course(activity.course.id) || []) + when 'ForgeActivity' + activity = ForgeActivity.find(id) + (find_at_users(activity.forge_act_type, activity.forge_act_id) ||[]) + + (find_project(activity.project_id) || []) + when 'UserActivity' + activity = UserActivity.find(id) + (find_at_users(activity.act_type, activity.act_id) || []) + + (find_at_users(activity.container_type, activity.container_id) || []) + when 'OrgActivity' + activity = OrgActivity.find(id) + (find_at_users(activity.org_act_type, activity.org_act_id) || []) + + (find_at_users(activity.container_type, activity.container_id) || []) + when 'PrincipalActivity' + activity = PrincipalActivity.find(id) + find_at_users(activity.principal_act_type, activity.principal_act_id) + else + nil + end + end + + #作业应该是关联课程,取课程的用户列表 + def find_homework(id) + homework = HomeworkCommon.find(id) + find_course(homework.course_id) + end + + def find_attachment(id) + attachment = Attachment.find(id) + find_at_users(attachment.container_type, attachment.container_id) + end + + #Message + def find_message(id) + message = Message.find(id) + at_persons = message.board.messages.map(&:author) + + end + + #News + def find_news(id) + find_project(News.find(id).project_id) + end + + #JournalsForMessage + def find_journals_for_message(id) + jounrnal = JournalsForMessage.find(id) + find_at_users(jounrnal.jour_type, jounrnal.jour_id) + end + + #Poll + def find_poll(id) + end + + #Journal + def find_journal(id) + journal = Journal.find(id) + find_at_users(journal.journalized_type, journal.journalized_id) + end + + #Document + def find_document(id) + find_project(Document.find(id).project_id) + end + + #ProjectCreateInfo + def find_project_create_info(id) + + end + + #Principal + def find_principal(id) + + end + + #BlogComment + def find_blog_comment(id) + blog = BlogComment.find(id).blog + blog.users end end \ No newline at end of file diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 227de930f..98249dbc8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1716,6 +1716,13 @@ module ApplicationHelper # def javascript_include_tag(*sources) options = sources.last.is_a?(Hash) ? sources.pop : {} + + @sources ||= [] + sources = sources.delete_if do|source| + @sources.include?(source) + end + @sources += sources + if plugin = options.delete(:plugin) sources = sources.map do |source| if plugin @@ -1725,7 +1732,12 @@ module ApplicationHelper end end end - super sources, options + + if sources && !sources.empty? + super(sources, options) + else + '' + end end def content_for(name, content = nil, &block) @@ -2621,11 +2633,8 @@ int main(int argc, char** argv){ end def import_ke(default_opt={}) - opt = {enable_at: true, prettify: false, init_activity: false}.merge default_opt + opt = {enable_at: false, prettify: false, init_activity: false}.merge default_opt ss = '' - if opt[:enable_at] - ss += %Q|| - end ss += javascript_include_tag("/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg') if opt[:enable_at] diff --git a/app/views/at/show.js.erb b/app/views/at/show.js.erb deleted file mode 100644 index df253f237..000000000 --- a/app/views/at/show.js.erb +++ /dev/null @@ -1,8 +0,0 @@ -(function(){ - window.atPersonLists = []; - <% @users && @users.each_with_index do |person,index| %> - var o = {id: <%=index%>, name: '<%=person.show_name%>', login: '<%=person.login%>', searchKey: '<%=person.get_at_show_name%>'}; - atPersonLists.push(o); - <% end %> - -})(); diff --git a/app/views/at/show.json.erb b/app/views/at/show.json.erb new file mode 100644 index 000000000..7af729ff7 --- /dev/null +++ b/app/views/at/show.json.erb @@ -0,0 +1,6 @@ +[ + <% @users && @users.each_with_index do |person,index| %> + {"id": <%=index%>, "name": "<%=person.show_name%>", "login": "<%=person.login%>", "searchKey": "<%=person.get_at_show_name%>"} + <%= index != @users.size-1 ? ',' : '' %> + <% end %> +] diff --git a/app/views/bids/_new_homework_form.html.erb b/app/views/bids/_new_homework_form.html.erb index 5958fccff..815ff27e4 100644 --- a/app/views/bids/_new_homework_form.html.erb +++ b/app/views/bids/_new_homework_form.html.erb @@ -15,10 +15,10 @@ <% if edit_mode %> - <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:owner_id => bid.id,:owner_type =>OwnerTypeHelper::BID,:resizeType => 0 %> + <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:owner_id => bid.id,:owner_type =>OwnerTypeHelper::BID,:resizeType => 0,act_id: @course.id, act_type: @course.class.to_s %> <% else %> <%= hidden_field_tag :asset_id,params[:asset_id],:required => false,:style => 'display:none' %> - <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:resizeType => 0 %> + <%= f.kindeditor :description,:width=>'91%',:editor_id => 'bid_description_editor',:resizeType => 0, act_id: @course.id, act_type: @course.class.to_s %> <% end %>
    • diff --git a/app/views/blog_comments/_edit.html.erb b/app/views/blog_comments/_edit.html.erb index c7065ece4..048402635 100644 --- a/app/views/blog_comments/_edit.html.erb +++ b/app/views/blog_comments/_edit.html.erb @@ -1,5 +1,5 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false) %> + <%= import_ke(enable_at: true, prettify: false) %> <%= javascript_include_tag 'blog' %> <% end %> @@ -34,7 +34,9 @@ :class => 'talk_text fl', :input_html => { :id => 'message_content', :class => 'talk_text fl', - :maxlength => 5000 }%> + :maxlength => 5000 }, + act_id: article.id, act_type: article.class.to_s + %>

    diff --git a/app/views/blog_comments/_reply_form.html.erb b/app/views/blog_comments/_reply_form.html.erb index 32f4333c2..67642069c 100644 --- a/app/views/blog_comments/_reply_form.html.erb +++ b/app/views/blog_comments/_reply_form.html.erb @@ -1,5 +1,5 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false) %> + <%= import_ke(enable_at: true, prettify: false) %> <% end %>
  • @@ -27,7 +27,9 @@ :minHeight=>100, :input_html => { :id => 'message_content', :class => 'talk_text fl', - :maxlength => 5000 }%> + :maxlength => 5000 }, + at_id: article.id, at_type: article.class.to_s + %>

  • diff --git a/app/views/blog_comments/quote.js.erb b/app/views/blog_comments/quote.js.erb index 088b2cf67..cd53707d5 100644 --- a/app/views/blog_comments/quote.js.erb +++ b/app/views/blog_comments/quote.js.erb @@ -3,7 +3,7 @@ if($("#reply_message_<%= @blogComment.id%>").length > 0) { $(function(){ $('#reply_subject').val("<%= raw escape_javascript(@subject) %>"); $('#quote_quote').val("<%= raw escape_javascript(@temp.content.html_safe) %>"); - init_activity_KindEditor_data(<%= @blogComment.id%>,null,"85%"); + init_activity_KindEditor_data(<%= @blogComment.id%>,null,"85%", "<%=@blogComment.class.to_s%>"); }); }else if($("#reply_to_message_<%= @blogComment.id%>").length >0) { $("#reply_to_message_<%= @blogComment.id%>").replaceWith("

    "); diff --git a/app/views/blog_comments/reply.js.erb b/app/views/blog_comments/reply.js.erb index 1cb64b2b5..06adca74d 100644 --- a/app/views/blog_comments/reply.js.erb +++ b/app/views/blog_comments/reply.js.erb @@ -1,7 +1,7 @@ <% if @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%"); + init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", 'UserActivity'); <% else%> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'blogs/article', :locals => {:activity => @article,:user_activity_id =>@user_activity_id}) %>"); -init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", 'UserActivity'); <% end %> \ No newline at end of file diff --git a/app/views/blog_comments/show.html.erb b/app/views/blog_comments/show.html.erb index e46a7249f..aa984c621 100644 --- a/app/views/blog_comments/show.html.erb +++ b/app/views/blog_comments/show.html.erb @@ -27,7 +27,7 @@ } } $(function() { - init_activity_KindEditor_data(<%= @article.id%>,null,"85%"); + init_activity_KindEditor_data(<%= @article.id%>,null,"85%", '<%=@article.class.to_s%>'); showNormalImage('message_description_<%= @article.id %>'); }); diff --git a/app/views/blogs/_article_list.html.erb b/app/views/blogs/_article_list.html.erb index a91dd8151..f6383c95b 100644 --- a/app/views/blogs/_article_list.html.erb +++ b/app/views/blogs/_article_list.html.erb @@ -74,7 +74,7 @@ } $(function () { - init_activity_KindEditor_data(<%= topic.id%>, null, "87%"); + init_activity_KindEditor_data(<%= topic.id%>, null, "87%", "<%=topic.class.to_s%>"); showNormalImage('activity_description_<%= topic.id %>'); /*var description_images=$("div#activity_description_<%#= topic.id %>").find("img"); if (description_images.length>0) { diff --git a/app/views/boards/_course_new.html.erb b/app/views/boards/_course_new.html.erb index e4cf57ae3..31cdf41eb 100644 --- a/app/views/boards/_course_new.html.erb +++ b/app/views/boards/_course_new.html.erb @@ -1,5 +1,5 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false) %> + <%= import_ke(enable_at: true, prettify: false) %> <% end %> <%= error_messages_for 'message' %> @@ -34,7 +34,9 @@ :class => 'talk_text fl', :input_html => { :id => 'message_content', :class => 'talk_text fl', - :maxlength => 5000 }%> + :maxlength => 5000 }, + at_id: topic.id, at_type: topic.class.to_s + %>

    diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 306a0c7ce..074da9af1 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -74,7 +74,7 @@ } $(function () { - init_activity_KindEditor_data(<%= topic.id%>, null, "87%"); + init_activity_KindEditor_data(<%= topic.id%>, null, "87%", "<%=topic.class.to_s%>"); showNormalImage('activity_description_<%= topic.id %>'); /*var description_images=$("div#activity_description_<%#= topic.id %>").find("img"); if (description_images.length>0) { diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index ea904a63f..c3942ee38 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -1,3 +1,3 @@ $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); -init_activity_KindEditor_data('<%= @user_activity_id%>',"","87%"); +init_activity_KindEditor_data('<%= @user_activity_id%>',"","87%", "UserActivity"); diff --git a/app/views/courses/_course_activity.html.erb b/app/views/courses/_course_activity.html.erb index b4c560fa4..d31b28bc0 100644 --- a/app/views/courses/_course_activity.html.erb +++ b/app/views/courses/_course_activity.html.erb @@ -1,5 +1,5 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false, init_activity: true) %> + <%= import_ke(enable_at: true, prettify: false, init_activity: true) %> <% end %> <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false, init_activity: true) %> + <%= import_ke(enable_at: true, prettify: false, init_activity: true) %> <% end %> - diff --git a/app/views/courses/syllabus.html.erb b/app/views/courses/syllabus.html.erb index f4b8ce8a4..9d20b5adb 100644 --- a/app/views/courses/syllabus.html.erb +++ b/app/views/courses/syllabus.html.erb @@ -1,6 +1,6 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false, init_activity: true) %> + <%= import_ke(enable_at: true, prettify: false, init_activity: true) %> <%= javascript_include_tag 'blog' %> <% end %> @@ -40,7 +40,7 @@ } } $(function() { - init_activity_KindEditor_data(<%= @article.id%>,null,"87%"); + init_activity_KindEditor_data(<%= @article.id%>,null,"87%", "<%=@article.class.to_s%>"); showNormalImage('message_description_<%= @article.id %>'); }); diff --git a/app/views/homework_common/start_anonymous_comment.js.erb b/app/views/homework_common/start_anonymous_comment.js.erb index ea63ea12c..ffeda2cb5 100644 --- a/app/views/homework_common/start_anonymous_comment.js.erb +++ b/app/views/homework_common/start_anonymous_comment.js.erb @@ -2,10 +2,10 @@ alert('启动成功'); <% if @user_activity_id == -1 %> $("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => "users/user_homework_detail",:locals => {:homework_common => @homework, :is_in_course => @is_in_course})%>"); - init_activity_KindEditor_data(<%= @homework.id%>,"","87%"); + init_activity_KindEditor_data(<%= @homework.id%>,"","87%", "<%=@homework.class.to_s%>"); <% else %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@course_activity}) %>"); - init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); + init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", "UserActivity"); <% end %> /*$("#<%#= @homework.id %>_start_anonymous_comment").replaceWith('<%#= escape_javascript(link_to "关闭匿评", alert_anonymous_comment_homework_common_path(@homework), remote: true, id:"#{@homework.id}_stop_anonymous_comment",:class => "postOptionLink")%>');*/ <% elsif @statue == 2 %> diff --git a/app/views/homework_common/stop_anonymous_comment.js.erb b/app/views/homework_common/stop_anonymous_comment.js.erb index 214a157dc..308e8a39f 100644 --- a/app/views/homework_common/stop_anonymous_comment.js.erb +++ b/app/views/homework_common/stop_anonymous_comment.js.erb @@ -1,10 +1,10 @@ alert('关闭成功'); <% if @user_activity_id == -1 %> $("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => "users/user_homework_detail",:locals => {:homework_common => @homework, :is_in_course => @is_in_course})%>"); -init_activity_KindEditor_data(<%= @homework.id%>,"","87%"); +init_activity_KindEditor_data(<%= @homework.id%>,"","87%", "<%=@homework.class.to_s%>"); <% else %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@course_activity}) %>"); -init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", 'UserActivity'); <% end %> /* $("#<%#= @homework.id %>_stop_anonymous_comment").replaceWith('');*/ diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb index b8f362429..05793ea7c 100644 --- a/app/views/issues/_edit.html.erb +++ b/app/views/issues/_edit.html.erb @@ -1,8 +1,7 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> + <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> <% end %> - <%= labelled_form_for @issue, :html => {:id => 'issue-form', :multipart => true} do |f| %> <%= error_messages_for 'issue', 'time_entry' %> <%= render :partial => 'conflict' if @conflict %> @@ -24,7 +23,7 @@
    回复 - <%= f.kindeditor :notes, :style => "width:99%;",:height=>'100px', :cssData =>"blockquote { padding:0px}", :rows => "5", :no_label => true, :editor_id=>'issue_journal_kind_reply' %> + <%= f.kindeditor :notes, :style => "width:99%;",:height=>'100px', :cssData =>"blockquote { padding:0px}", :rows => "5", :no_label => true, :editor_id=>'issue_journal_kind_reply', at_id: @issue.id, at_type: @issue.class.to_s %>
    diff --git a/app/views/issues/_form.html.erb b/app/views/issues/_form.html.erb index 0d5c876f1..c1d2a841b 100644 --- a/app/views/issues/_form.html.erb +++ b/app/views/issues/_form.html.erb @@ -49,7 +49,7 @@ <%= f.label_for_field :description, :required => @issue.required_attribute?('description'), :no_label => true, :class => "label" %> <%#= link_to_function image_tag('edit.png'), '$(this).hide(); $("#issue_description_and_toolbar").show()' unless @issue.new_record? %> <%#= content_tag 'span', :id => "issue_description_and_toolbar" do %> - <%= f.kindeditor :description,:editor_id => "issue_desc_editor", :width=>'87%', :resizeType => 0, :no_label => true %> + <%= f.kindeditor :description,:editor_id => "issue_desc_editor", :width=>'87%', :resizeType => 0, :no_label => true,at_id: @project.id, at_type: @project.class.to_s %> <%# end %> <%#= wikitoolbar_for 'issue_description' %> <% end %> diff --git a/app/views/issues/add_journal.js.erb b/app/views/issues/add_journal.js.erb index 0b1c02b88..8ff5a71f1 100644 --- a/app/views/issues/add_journal.js.erb +++ b/app/views/issues/add_journal.js.erb @@ -1,3 +1,3 @@ $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_issue', :locals => {:activity => @issue,:user_activity_id =>@user_activity_id}) %>"); -init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); \ No newline at end of file +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", "UserActivity"); \ No newline at end of file diff --git a/app/views/issues/add_journal_in_org.js.erb b/app/views/issues/add_journal_in_org.js.erb index ad7a85540..34e874f13 100644 --- a/app/views/issues/add_journal_in_org.js.erb +++ b/app/views/issues/add_journal_in_org.js.erb @@ -1,3 +1,3 @@ $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'organizations/org_project_issue', :locals => {:activity => @issue,:user_activity_id =>@user_activity_id}) %>"); -init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); \ No newline at end of file +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", "UserActivity"); \ No newline at end of file diff --git a/app/views/issues/new.html.erb b/app/views/issues/new.html.erb index 9c6ad647c..c4daedaa4 100644 --- a/app/views/issues/new.html.erb +++ b/app/views/issues/new.html.erb @@ -1,5 +1,5 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> + <%= import_ke(enable_at: true, prettify: false, init_activity: false) %> <% end %> diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index 67d1186c4..80d3aaac1 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -1,5 +1,5 @@ <%= content_for(:header_tags) do %> -<%= import_ke(enable_at: {id: @issue.id, type: 'Issue'}) %> +<%= import_ke(enable_at: true) %> <% end %>
    diff --git a/app/views/memos/show.html.erb b/app/views/memos/show.html.erb index 44f3e5a64..b7cc1a0c2 100644 --- a/app/views/memos/show.html.erb +++ b/app/views/memos/show.html.erb @@ -34,7 +34,7 @@ } } $(function() { - init_activity_KindEditor_data(<%= @memo.id%>,null,"87%"); + init_activity_KindEditor_data(<%= @memo.id%>,null,"87%", "<%=@memo.class.to_s%>"); }); function del_confirm(){ diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index 0f39b73d2..e06c04775 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -27,7 +27,7 @@ } } $(function() { - init_activity_KindEditor_data(<%= @topic.id%>,null,"85%"); + init_activity_KindEditor_data(<%= @topic.id%>,null,"85%", "<%=@topic.class.to_s%>"); showNormalImage('message_description_<%= @topic.id %>'); }); diff --git a/app/views/messages/quote.js.erb b/app/views/messages/quote.js.erb index eee820c61..b0e8ecb85 100644 --- a/app/views/messages/quote.js.erb +++ b/app/views/messages/quote.js.erb @@ -11,7 +11,7 @@ if($("#reply_message_<%= @message.id%>").length > 0) { $(function(){ $('#reply_subject').val("<%= raw escape_javascript(@subject) %>"); $('#quote_quote').val("<%= raw escape_javascript(@temp.content.html_safe) %>"); - init_activity_KindEditor_data(<%= @message.id%>,null,"85%"); + init_activity_KindEditor_data(<%= @message.id%>,null,"85%", "<%=@message.class.to_s%>"); }); }else if($("#reply_to_message_<%= @message.id%>").length >0) { $("#reply_to_message_<%= @message.id%>").replaceWith("

    "); diff --git a/app/views/messages/reply.js.erb b/app/views/messages/reply.js.erb index ac80de3b4..518479344 100644 --- a/app/views/messages/reply.js.erb +++ b/app/views/messages/reply.js.erb @@ -3,4 +3,4 @@ <%elsif @course%> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_message', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>"); <%end%> -init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); \ No newline at end of file +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", "UserActivity"); \ No newline at end of file diff --git a/app/views/org_document_comments/_reply_form.html.erb b/app/views/org_document_comments/_reply_form.html.erb index 7871b910d..8808ff8b7 100644 --- a/app/views/org_document_comments/_reply_form.html.erb +++ b/app/views/org_document_comments/_reply_form.html.erb @@ -1,2 +1,2 @@ $("#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%"); +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", "UserActivity"); diff --git a/app/views/org_document_comments/add_reply.js.erb b/app/views/org_document_comments/add_reply.js.erb index 40ed2eeb2..84f8c1f83 100644 --- a/app/views/org_document_comments/add_reply.js.erb +++ b/app/views/org_document_comments/add_reply.js.erb @@ -1,3 +1,3 @@ $("#organization_document_<%= @act.id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/show_org_document', :locals => {:document => @document, :act => @act}) %>"); -init_activity_KindEditor_data(<%= @act.id %>,"","87%"); \ No newline at end of file +init_activity_KindEditor_data(<%= @act.id %>,"","87%", "<%=@act.class.to_s%>"); \ No newline at end of file diff --git a/app/views/org_document_comments/index.html.erb b/app/views/org_document_comments/index.html.erb index 331e61bfd..ddbb6bf9c 100644 --- a/app/views/org_document_comments/index.html.erb +++ b/app/views/org_document_comments/index.html.erb @@ -19,7 +19,7 @@ <% @documents.each do |document| %> <%= render :partial => 'organizations/show_org_document', :locals => {:document => document, :act => OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id=?", document.id).first} %> diff --git a/app/views/org_document_comments/quote.js.erb b/app/views/org_document_comments/quote.js.erb index a71b23f0e..7ea5daf7b 100644 --- a/app/views/org_document_comments/quote.js.erb +++ b/app/views/org_document_comments/quote.js.erb @@ -3,7 +3,7 @@ if($("#reply_message_<%= @org_comment.id%>").length > 0) { $(function(){ $('#reply_subject').val("<%= raw escape_javascript(@subject) %>"); $('#quote_quote').val("<%= raw escape_javascript(@temp.content.html_safe) %>"); - init_activity_KindEditor_data(<%= @org_comment.id%>,null,"85%"); + init_activity_KindEditor_data(<%= @org_comment.id%>,null,"85%", "<%=@org_comment.class.to_s%>"); }); }else if($("#reply_to_message_<%= @org_comment.id %>").length >0) { $("#reply_to_message_<%= @org_comment.id%>").replaceWith("

    "); diff --git a/app/views/org_document_comments/show.html.erb b/app/views/org_document_comments/show.html.erb index 1b1eca418..3a50e5faa 100644 --- a/app/views/org_document_comments/show.html.erb +++ b/app/views/org_document_comments/show.html.erb @@ -5,7 +5,7 @@ diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index 33ac13e76..8f9acbc7b 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -2,7 +2,7 @@ <% org_activities.each do |act| %> <% if act.container_type == 'Organization' %> diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index 7200761a3..9d62dd1f9 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -59,7 +59,7 @@ <% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 %> <% act = OrgActivity.where("org_act_type = 'OrgDocumentComment' and org_act_id =?", @organization.home_id).first %> diff --git a/app/views/student_work/forbidden_anonymous_comment.js.erb b/app/views/student_work/forbidden_anonymous_comment.js.erb index a72c29509..47dfb4b51 100644 --- a/app/views/student_work/forbidden_anonymous_comment.js.erb +++ b/app/views/student_work/forbidden_anonymous_comment.js.erb @@ -1,7 +1,7 @@ <% if @user_activity_id == -1 %> $("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => "users/user_homework_detail",:locals => {:homework_common => @homework, :is_in_course => @is_in_course})%>"); -init_activity_KindEditor_data(<%= @homework.id%>,"","87%"); +init_activity_KindEditor_data(<%= @homework.id%>,"","87%", "<%=@homework.class.to_s%>"); <% else %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id,:course_activity=>@course_activity}) %>"); -init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", "UserActivity"); <% end %> \ No newline at end of file diff --git a/app/views/student_work/set_score_rule.js.erb b/app/views/student_work/set_score_rule.js.erb index ff3a0e7ed..180f04faa 100644 --- a/app/views/student_work/set_score_rule.js.erb +++ b/app/views/student_work/set_score_rule.js.erb @@ -1,8 +1,8 @@ clickCanel(); <% if @user_activity_id %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_homework', :locals => {:activity => @homework,:user_activity_id =>@user_activity_id}) %>"); - init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); + init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", "UserActivity"); <% else %> $("#homework_common_<%= @homework.id %>").replaceWith("<%= escape_javascript(render :partial => 'users/user_homework_detail', :locals => {:homework_common => @homework,:is_in_course => @is_in_course}) %>"); - init_activity_KindEditor_data(<%= @homework.id%>,"","87%"); + init_activity_KindEditor_data(<%= @homework.id%>,"","87%", "<%=@homework.class.to_s%>"); <% end %> \ No newline at end of file diff --git a/app/views/users/_user_activities.html.erb b/app/views/users/_user_activities.html.erb index 4f1d3a5d8..557b9e9ee 100644 --- a/app/views/users/_user_activities.html.erb +++ b/app/views/users/_user_activities.html.erb @@ -1,12 +1,12 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false, init_activity: true) %> + <%= import_ke(enable_at: true, prettify: false, init_activity: true) %> <% end %> -<%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false, init_activity: true) %> -<% end %> - - +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_KindEditor" %> @@ -24,11 +20,11 @@

    <%= l(:label_leave_message) %>

    <% if !User.current.logged?%> -
    - <%= l(:label_user_login_tips) %> - <%= link_to l(:label_user_login_new), signin_path %> -
    -
    +
    + <%= l(:label_user_login_tips) %> + <%= link_to l(:label_user_login_new), signin_path %> +
    +
    <% else %>
    <%= form_for('new_form',:url => {:controller => 'words', :action => 'leave_course_message'}, :html=>{:id => "course_feedback_new"},:method => "post") do |f|%> @@ -59,37 +55,37 @@ $("#submit_feedback_course").one('click',function() { $("#course_feedback_new").submit(); }); - KindEditor.ready(function(K){ - $("a[nhname='reply_btn']").live('click',function(){ - var params = {}; - params.kindutil = K; - params.container = $(this).parent('div').parent('div'); - params.div_form = $(">.respond-form",params.container); - params.form = $("form",params.div_form); - params.textarea = $("textarea[name='user_notes']",params.div_form); - params.contentmsg = $("p[nhname='contentmsg']",params.div_form); - params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form); - params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form); - params.height = 55; - if(params.textarea.data('init') == undefined){ - params.editor = init_editor(params); - init_form(params); - params.cancel_btn.click(function(){ - nh_reset_form(params); - }); - } - params.cancel_btn.click(); - toggleAndSettingWordsVal(params.div_form, params.textarea); - setTimeout(function(){ - if(!params.div_form.is(':hidden')){ - params.textarea.show(); - params.textarea.focus(); - params.textarea.hide(); - } - },300); - params.textarea.data('init',1); - }); + KindEditor.ready(function(K){ + $("a[nhname='reply_btn']").live('click',function(){ + var params = {}; + params.kindutil = K; + params.container = $(this).parent('div').parent('div'); + params.div_form = $(">.respond-form",params.container); + params.form = $("form",params.div_form); + params.textarea = $("textarea[name='user_notes']",params.div_form); + params.contentmsg = $("p[nhname='contentmsg']",params.div_form); + params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form); + params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form); + params.height = 55; + if(params.textarea.data('init') == undefined){ + params.editor = init_editor(params); + init_form(params); + params.cancel_btn.click(function(){ + nh_reset_form(params); + }); + } + params.cancel_btn.click(); + toggleAndSettingWordsVal(params.div_form, params.textarea); + setTimeout(function(){ + if(!params.div_form.is(':hidden')){ + params.textarea.show(); + params.textarea.focus(); + params.textarea.hide(); + } + },300); + params.textarea.data('init',1); + }); + }); }); - }); From dc4532145487e903367e0bbddf0ea1eedea89c7b Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 15 Dec 2015 17:34:40 +0800 Subject: [PATCH 20/80] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=96=87=E7=AB=A0?= =?UTF-8?q?=E4=BA=8C=E7=BA=A7=E5=9B=9E=E5=A4=8D=E4=BB=A3=E7=A0=81=E8=A2=AB?= =?UTF-8?q?=E8=A6=86=E7=9B=96=EF=BC=8C=E6=81=A2=E5=A4=8D=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/org_document_comments/show.html.erb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/views/org_document_comments/show.html.erb b/app/views/org_document_comments/show.html.erb index dfe27cde3..7a64e4514 100644 --- a/app/views/org_document_comments/show.html.erb +++ b/app/views/org_document_comments/show.html.erb @@ -1,8 +1,4 @@ -<%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> -<%= javascript_include_tag 'blog' %> -<% end %> - +<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg',"init_activity_KindEditor",'blog' %> + <% replies_all_i=replies_all_i + 1 %> +
  • +
    + <%= link_to image_tag(url_to_avatar(reply.user), :width => "33", :height => "33"), user_path(reply.user_id), :alt => "用户头像" %> +
    +
    +
    + <% if reply.try(:user).try(:realname) == ' ' %> + <%= link_to reply.try(:user), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:user).try(:realname), user_path(reply.user_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> +
    +
    + <% if reply.details.any? %> + <% details_to_strings(reply.details).each do |string| %> +

    <%= string %>

    + <% end %> + <% end %> +

    <%= reply.notes.html_safe %>

    +
    +
    +
    +
  • + <% end %> + \ No newline at end of file diff --git a/app/views/issues/add_journal.js.erb b/app/views/issues/add_journal.js.erb index 0b1c02b88..5a3fa90ca 100644 --- a/app/views/issues/add_journal.js.erb +++ b/app/views/issues/add_journal.js.erb @@ -1,3 +1,8 @@ -$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_issue', :locals => {:activity => @issue,:user_activity_id =>@user_activity_id}) %>"); - -init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); \ No newline at end of file +<% if @issue_id%> + $("#reply_div_<%= @issue_id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => Issue.find( @issue_id),:replies_all_i=>0}) %>"); + $(".homepagePostReplyBannerCount").html('回复(<%= Issue.find( @issue_id).journals.count %>)') + issues_reply_editor.html('') +<%else%> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_issue', :locals => {:activity => @issue,:user_activity_id =>@user_activity_id}) %>"); + init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%"); +<%end %> \ No newline at end of file diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index 80d3aaac1..dc8e2b84a 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -1,106 +1,55 @@ <%= content_for(:header_tags) do %> -<%= import_ke(enable_at: true) %> + <%= import_ke(enable_at: true) %> <% end %> - -
    -

    <%= l(:label_issue_edit) %>

    + +
    +
    +
    问题跟踪
    -<% html_title "#{@issue.tracker.name} #{@issue.source_from}'#'#{@issue.project_index}: #{@issue.subject}" %> -
    -
    - <%= link_to "#{@issue.project.name}"+">", project_issues_path(@issue.project) %> - <%= "#" + @issue.id.to_s %> -
    -
    -
    - <%= link_to image_tag(url_to_avatar(@issue.author), :width => 46, :height => 46), user_path(@issue.author), :class => "ping_dispic" %> -
    - -
    -

    - - <%= @issue.subject %> - <%= get_issue_priority(@issue.priority_id)[1] %> -


    - -
    - 由<%= @issue.author %>添加于 <%= format_time(@issue.created_on).html_safe %> -
    - - 'action_menu' %> -
    - <% if @issue.description? || @issue.attachments.any? -%> -
    - <% if @issue.description? %> - <%#= link_to l(:button_quote), quoted_issue_path(@issue.id), :remote => true, :method => 'post', :class => 'icon icon-comment' if authorize_for('issues', 'edit') %> - <%= textAreailizable @issue, :description, :attachments => @issue.attachments %> - <% end %> +
    +
    +
    +
    + <%= render :partial => 'issues/detail'%> +
    + - <% end -%> - -
    - - - <%= link_to_attachment_project @issue, :thumbnails => true %>
    - <%= call_hook(:view_issues_show_description_bottom, :issue => @issue) %> -
    -
    - - - <%= render :partial => 'attributes_show' %> - - - <%# 该应用是对issue主题内容的引用,对应:to => 'journals#new %> - - -
    -
    - - -
    - - - <% if @issue.editable? %> -
    - <%= render :partial => 'edit' %>
    -

    - <%#--引用时不能修改,剥离出引用内容--%> - - <%= l(:button_submit) %> - - <% end %> - <%#= submit_tag l(:button_submit) %> - <%#= preview_link preview_edit_issue_path(:project_id => @project, :id => @issue), 'issue-form' ,'preview',{:class => "blue_btn fr mr10"}%> -
    -<% if @changesets.present? %> -
    -

    <%= l(:label_associated_revisions) %>

    - <%= render :partial => 'changesets', :locals => {:changesets => @changesets} %> -
    -<% end %> - -
    -<% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => {:key => User.current.rss_key} %> - <%= f.link_to 'PDF' %> -<% end %> + +
    +
    +
    +
    +
    回复(<%= @issue.journals.count %>)
    +
    +
    -<% content_for :sidebar do %> - <%= render :partial => 'issues/sidebar' %> -
    - <% if User.current.allowed_to?(:add_issue_watchers, @project) || - (@issue.watchers.present? && User.current.allowed_to?(:view_issue_watchers, @project)) %> -
    - <%= render :partial => 'watchers/watchers', :locals => {:watched => @issue} %> +
    + <%= render :partial => 'issue_replies',:locals => {:issue=>@issue,:replies_all_i=>0} %>
    - <% end %> -<% end %> -<% content_for :header_tags do %> - <%= auto_discovery_link_tag(:atom, {:format => 'atom', :key => User.current.rss_key}, :title => "#{@issue.project} - #{@issue.tracker} ##{@issue.id}: #{@issue.subject}") %> -<% end %> -<%= context_menu issues_context_menu_path %> +
    + <%= form_for('new_form',:url => add_journal_issue_path(@issue.id),:method => "post", :remote => true) do |f|%> +
    + <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@issue.author_id), :alt => "用户头像" %> +
    + +
    + <%= kindeditor_tag :notes,"",:height=>"33",:minHeight=>"33",:editor_id=>"issues_reply_editor"%> +
    +
    + 发送 +
    + <% end %> +
    +
    + \ No newline at end of file diff --git a/app/views/issues/update.js.erb b/app/views/issues/update.js.erb new file mode 100644 index 000000000..504d50a65 --- /dev/null +++ b/app/views/issues/update.js.erb @@ -0,0 +1,5 @@ +$("#issue_detail").html('<%= escape_javascript(render :partial => 'issues/detail') %>') +$("#issue_detail").show(); +$("#issue_edit").hide(); +$("#reply_div_<%= @issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => @issue,:replies_all_i=>0}) %>"); +$(".homepagePostReplyBannerCount").html('回复(<%= @issue.journals.count %>)') \ No newline at end of file diff --git a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb index 08f4da0ad..14eba3bee 100644 --- a/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb +++ b/lib/rails_kindeditor/lib/rails_kindeditor/helper.rb @@ -1,6 +1,8 @@ module RailsKindeditor module Helper - EVAL_STR = %Q|eval(function(){ if(typeof enablePasteImg ==='function'){enablePasteImg(self);} if(typeof enableAt ==='function'){enableAt(self);} this.loadPlugin("autoheight")})| + EVAL_STR = %Q|eval(function(){ if(typeof enablePasteImg ==='function'){enablePasteImg(self);} if(typeof enableAt ==='function'){enableAt(self);} this.loadPlugin("autoheight"),$(this.toolbar.div).hide();})| + EVAL_STR_AFTER_FOCUS = %Q|eval(function(){$(this.toolbar.div).show();})| + EVAL_STR_AFTER_BLUR = %Q|eval(function(){$(this.toolbar.div).hide();})| def kindeditor_tag(name, content = nil, options = {}) id = sanitize_to_id(name) @@ -11,6 +13,8 @@ module RailsKindeditor output << javascript_tag(js_replace(id, options.merge(window_onload: 'true', :autoHeightMode=>true, afterCreate: EVAL_STR, + afterFocus:EVAL_STR_AFTER_FOCUS, + afterBlur:EVAL_STR_AFTER_BLUR, emotionsBasePath: 'http://' + Setting.host_name ))) end @@ -24,6 +28,8 @@ module RailsKindeditor output_buffer << javascript_tag(js_replace(input_html['id'],options.merge(window_onload: 'true', :autoHeightMode=>true, afterCreate: EVAL_STR, + afterFocus:EVAL_STR_AFTER_FOCUS, + afterBlur:EVAL_STR_AFTER_BLUR, emotionsBasePath: 'http://' + Setting.host_name ))) end diff --git a/public/assets/kindeditor/kindeditor.js b/public/assets/kindeditor/kindeditor.js index bf9cb26d8..3096d2326 100644 --- a/public/assets/kindeditor/kindeditor.js +++ b/public/assets/kindeditor/kindeditor.js @@ -3932,7 +3932,9 @@ _extend(KToolbar, KWidget, { pdiv = $("#define",container); }else if(!$("#full",container).is(':hidden')){ pdiv = $("#full",container); - } + }else if($("#full",container).is(':hidden') && $("#define",container).is(':hidden')){ //都隐藏的情况下 + pdiv = $("#define", container); + } return (this._itemMap[name] = K('span.ke-icon-' + name, pdiv).parent()); }, select : function(name) { @@ -4729,15 +4731,21 @@ function _bindTabEvent() { } function _bindFocusEvent() { var self = this; - K(self.edit.textarea[0], self.edit.win).focus(function(e) { - if (self.afterFocus) { - self.afterFocus.call(self, e); - } - }).blur(function(e) { - if (self.afterBlur) { - self.afterBlur.call(self, e); - } - }); + K(self.edit.textarea[0], self.edit.win).focus(function(e) { + if(typeof self.afterFocus == 'string'){ + self.afterFocus = eval(self.afterFocus); + } + if ( typeof self.afterFocus == 'function') { + self.afterFocus.call(self, e); + } + }).blur(function(e) { + if(typeof self.afterBlur == 'string'){ + self.afterBlur = eval(self.afterBlur); + } + if ( typeof self.afterBlur == 'function') { + self.afterBlur.call(self, e); + } + }); } function _removeBookmarkTag(html) { return _trim(html.replace(/]*id="?__kindeditor_bookmark_\w+_\d+__"?[^>]*><\/span>/ig, '')); diff --git a/public/assets/kindeditor/plugins/autoheight/autoheight.js b/public/assets/kindeditor/plugins/autoheight/autoheight.js index 3c25fe49e..b63dc7062 100644 --- a/public/assets/kindeditor/plugins/autoheight/autoheight.js +++ b/public/assets/kindeditor/plugins/autoheight/autoheight.js @@ -29,7 +29,7 @@ KindEditor.plugin('autoheight', function(K) { edit.iframe.height(minHeight); self.resize(null, Math.max( (K.IE ? body.scrollHeight : body.offsetHeight) - + 76, minHeight)); + + 33, minHeight)); } function init() { @@ -42,7 +42,7 @@ KindEditor.plugin('autoheight', function(K) { edit.iframe.height(minHeight); self.resize(null, Math.max( ((K.IE ? body.scrollHeight : body.offsetHeight) > 500 ? 500 : (K.IE ? body.scrollHeight : body.offsetHeight)) //限制初始化太高的情况 - + 76, minHeight)); + + 33, minHeight)); } if (self.isCreated) { diff --git a/public/javascripts/project.js b/public/javascripts/project.js index f3e6b76ce..a7bf954a0 100644 --- a/public/javascripts/project.js +++ b/public/javascripts/project.js @@ -541,4 +541,14 @@ function cancel_relation(orgId,projectId){ }); } }); +} + +function issueEditShow(){ + $("#issue_detail").hide(); + $("#issue_edit").show(); +} + +function issueDetailShow(){ + $("#issue_edit").hide(); + $("#issue_detail").show(); } \ No newline at end of file diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index b1367b882..aa3297128 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -1065,4 +1065,17 @@ a.homepagePostTypeQuiz { padding-left: 23px; } -.loadMore {font-size:14px;width:748px; text-align:center; display:block; border:1px solid #dddddd; background-color:#ffffff; float:right;padding:5px 0; letter-spacing: 1px;} \ No newline at end of file +.loadMore {font-size:14px;width:748px; text-align:center; display:block; border:1px solid #dddddd; background-color:#ffffff; float:right;padding:5px 0; letter-spacing: 1px;} + +img.date-trigger { + display:block; + cursor: pointer; + vertical-align: middle; + float:left; + border:1px solid #dddddd; + padding:1px 2px 2px 2px; + border-left:none; +} +.proInfoBox{ margin-left:60px; border:1px solid #dddddd; height:45px; padding:10px 0; background-color:#f1f1f1;} +.proInfoBox ul li{ height:24px;} +.proInfoP{color:#000000 !important; float:left; width:80px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } \ No newline at end of file diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index fa1767ad7..6c8b71785 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -12,7 +12,7 @@ textarea {resize: none;} .pInline {margin:0px; padding:0px; display:inline-block;} /*常用*/ -select,input,textarea{ border:1px solid #269ac9; background:#fff; color:#000; padding-left:5px} +select,input,textarea{ border:1px solid #dddddd; background:#fff; color:#000; padding-left:5px} .sub_btn{ cursor:pointer; -moz-border-radius:3px; -webkit-border-radius:3px; border:1px solid #707070; color:#000; border-radius:3px; padding:1px 10px; margin-bottom:10px; background:#dbdbdb;} .sub_btn:hover{ background:#b5e2fa; color:#000; border:1px solid #3c7fb1;} table{ background:#fff;} @@ -73,6 +73,7 @@ h4{ font-size:14px; color:#3b3b3b;} .ml30{ margin-left:30px;} .ml38{ margin-left:38px;} .ml60{ margin-left:60px;} +.ml160 {margin-left:160px;} .ml80{ margin-left:80px;} .ml90{ margin-left:90px;} .ml100{ margin-left:100px;} From 699d0e22dd0fd978831a7f6f60e305cdd32bdd6d Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 15 Dec 2015 19:05:19 +0800 Subject: [PATCH 24/80] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=A4=9A=E4=BD=99?= =?UTF-8?q?=E5=AD=A6=E7=94=9F=E7=9A=84=E6=B5=8B=E9=AA=8C=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20151215105425_delete_exercise_user.rb | 9 +++++++++ db/schema.rb | 4 +--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 db/migrate/20151215105425_delete_exercise_user.rb diff --git a/db/migrate/20151215105425_delete_exercise_user.rb b/db/migrate/20151215105425_delete_exercise_user.rb new file mode 100644 index 000000000..781337454 --- /dev/null +++ b/db/migrate/20151215105425_delete_exercise_user.rb @@ -0,0 +1,9 @@ +class DeleteExerciseUser < ActiveRecord::Migration + def up + eus=ExerciseUser.where("score is null and status=?",0) + eus.delete_all + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 17e613acb..9926f2876 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 => 20151209085942) do +ActiveRecord::Schema.define(:version => 20151215105425) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1161,7 +1161,6 @@ ActiveRecord::Schema.define(:version => 20151209085942) do t.datetime "updated_at", :null => false t.boolean "locked", :default => false t.integer "sticky", :default => 0 - t.integer "org_subfield_id" end create_table "org_member_roles", :force => true do |t| @@ -1188,7 +1187,6 @@ ActiveRecord::Schema.define(:version => 20151209085942) do t.string "name" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false - t.string "field_type" end create_table "organizations", :force => true do |t| From 481b7b96eb0783a97d6a3cb6b51463b86ab212d2 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 15 Dec 2015 20:15:10 +0800 Subject: [PATCH 25/80] =?UTF-8?q?=E6=AD=A3=E5=BC=8F=E7=89=88=E6=8A=A5500?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 8 ++++---- app/views/exercise/_exercise_teacher.html.erb | 4 ++-- db/schema.rb | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 73da3b9c4..3ed5886e7 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -359,7 +359,7 @@ class ExerciseController < ApplicationController if @exercise.end_time <= Time.now @course.student.each do |student| if ExerciseUser.where("user_id = ? && exercise_id = ?",student.student_id,@exercise.id).empty? - ExerciseUser.create(:user_id => student.student_id, :exercise_id => @exercise.id, :start_at => @exercise.end_time, :status => false,:score=>0) + ExerciseUser.create(:user_id => student.student_id, :exercise_id => @exercise.id, :start_at => @exercise.end_time, :status => true,:score=>0) end s_score = calculate_student_score(@exercise, student.student) @@ -577,15 +577,15 @@ class ExerciseController < ApplicationController standard_answer = get_user_standard_answer(question, user) unless answer.empty? # 问答题有多个答案 - if question.question_type == 3 + if question.question_type == 3 && !standard_answer.empty? if standard_answer.include?(answer.first.answer_text) score1 = score1+ question.question_score unless question.question_score.nil? end - elsif question.question_type == 1 + elsif question.question_type == 1 && !standard_answer.nil? if answer.first.exercise_choice.choice_position == standard_answer.exercise_choice_id score2 = score2 + question.question_score unless question.question_score.nil? end - else + elsif question.question_type == 2 && !standard_answer.nil? arr = get_mulscore(question, user) if arr.to_i == standard_answer.exercise_choice_id score3 = score3 + question.question_score unless question.question_score.nil? diff --git a/app/views/exercise/_exercise_teacher.html.erb b/app/views/exercise/_exercise_teacher.html.erb index 24687d28b..586c033a1 100644 --- a/app/views/exercise/_exercise_teacher.html.erb +++ b/app/views/exercise/_exercise_teacher.html.erb @@ -32,7 +32,7 @@
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分)
    - 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first %>
    @@ -64,7 +64,7 @@
    第<%= list_index+1%>题:<%= exercise_question.question_title %>  (<%= exercise_question.question_score %>分)
    - 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) %> + 标准答案:<%= convert_to_char(exercise_question.exercise_standard_answers.first.exercise_choice_id.to_s) if exercise_question.exercise_standard_answers.first%>
    diff --git a/db/schema.rb b/db/schema.rb index 9926f2876..51020f45d 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 => 20151215105425) do +ActiveRecord::Schema.define(:version => 20151215112107) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1161,6 +1161,7 @@ ActiveRecord::Schema.define(:version => 20151215105425) do t.datetime "updated_at", :null => false t.boolean "locked", :default => false t.integer "sticky", :default => 0 + t.integer "org_subfield_id" end create_table "org_member_roles", :force => true do |t| @@ -1187,6 +1188,7 @@ ActiveRecord::Schema.define(:version => 20151215105425) do t.string "name" t.datetime "created_at", :null => false t.datetime "updated_at", :null => false + t.string "field_type" end create_table "organizations", :force => true do |t| From 097d0653bac1bf98313ed2f788e0993012b5fd26 Mon Sep 17 00:00:00 2001 From: cxt Date: Tue, 15 Dec 2015 20:33:29 +0800 Subject: [PATCH 26/80] =?UTF-8?q?=E6=B3=A8=E9=87=8A=E6=8E=89=E7=BB=99?= =?UTF-8?q?=E6=9C=AA=E7=AD=94=E9=A2=98=E7=9A=84=E5=AD=A6=E7=94=9F0?= =?UTF-8?q?=E5=88=86=E7=9A=84=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/exercise_controller.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/controllers/exercise_controller.rb b/app/controllers/exercise_controller.rb index 3ed5886e7..8fa90ea46 100644 --- a/app/controllers/exercise_controller.rb +++ b/app/controllers/exercise_controller.rb @@ -356,6 +356,7 @@ class ExerciseController < ApplicationController end def student_exercise_list +=begin if @exercise.end_time <= Time.now @course.student.each do |student| if ExerciseUser.where("user_id = ? && exercise_id = ?",student.student_id,@exercise.id).empty? @@ -367,6 +368,7 @@ class ExerciseController < ApplicationController exercise_user.update_attributes(:score => s_score) end end +=end @is_teacher = User.current.allowed_to?(:as_teacher,@course) || User.current.admin? @all_exercises = @course.exercises.where("exercise_status > 1").order("created_at desc") @exercise_count = @exercise.exercise_users.where('score is not NULL').count From 8d1003770a17919a3c02aa2c778ec3b6945e7235 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Tue, 15 Dec 2015 23:01:54 +0800 Subject: [PATCH 27/80] =?UTF-8?q?=E5=9C=A8=E6=9C=AC=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E4=BF=AE=E6=94=B9=E7=9A=84=E6=97=B6=E5=80=99?= =?UTF-8?q?=EF=BC=8C=E7=94=B1=E4=BA=8Eedit=E9=A1=B5=E9=9D=A2=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E6=9B=B4=E6=96=B0=EF=BC=8C=E5=AF=BC=E8=87=B4issue?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=A7=A6=E5=8F=91=E4=B9=90=E8=A7=82=E9=94=81?= =?UTF-8?q?=E3=80=82lock=5Fversion=E6=AF=94=E6=95=B0=E6=8D=AE=E5=BA=93?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=E5=AD=98=E5=9C=A8=E7=9A=84lock=5Fversion?= =?UTF-8?q?=E6=9B=B4=E4=BD=8E=EF=BC=8C=E6=89=80=E4=BB=A5=E5=9B=9E=E6=BB=9A?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/issues/update.js.erb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/issues/update.js.erb b/app/views/issues/update.js.erb index 504d50a65..7dba2aa5d 100644 --- a/app/views/issues/update.js.erb +++ b/app/views/issues/update.js.erb @@ -1,4 +1,5 @@ $("#issue_detail").html('<%= escape_javascript(render :partial => 'issues/detail') %>') +$("#issue_edit").html('<%= escape_javascript(render :partial => 'issues/edit') %>') $("#issue_detail").show(); $("#issue_edit").hide(); $("#reply_div_<%= @issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => @issue,:replies_all_i=>0}) %>"); From 47a9be132ac4b9ff28e4638110e029244bcd6aed Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 16 Dec 2015 09:31:11 +0800 Subject: [PATCH 28/80] =?UTF-8?q?=E8=AF=A6=E6=83=85=E5=92=8C=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/attachments/_form.html.erb | 23 ++++------------------- app/views/issues/_detail.html.erb | 4 +++- app/views/issues/_edit.html.erb | 2 ++ app/views/issues/show.html.erb | 6 +----- app/views/issues/update.js.erb | 20 +++++++++++++++++--- 5 files changed, 27 insertions(+), 28 deletions(-) diff --git a/app/views/attachments/_form.html.erb b/app/views/attachments/_form.html.erb index ab8b80dcb..aac365a15 100644 --- a/app/views/attachments/_form.html.erb +++ b/app/views/attachments/_form.html.erb @@ -7,8 +7,10 @@ <% if defined?(container) && container && container.saved_attachments %> <% container.attachments.each_with_index do |attachment, i| %> - <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %><%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %><%= l(:field_is_public) %>: - <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %> + <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'upload_filename readonly', :readonly => 'readonly') %> + <%#= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %> + + <%#= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %> <%= if attachment.id.nil? #待补充代码 else @@ -21,24 +23,7 @@
    <% end %> - <% container.saved_attachments.each_with_index do |attachment, i| %> - - <%= text_field_tag("attachments[p#{i}][filename]", attachment.filename, :class => 'filename readonly', :readonly => 'readonly') %> - <%= text_field_tag("attachments[p#{i}][description]", attachment.description, :maxlength => 254, :placeholder => l(:label_optional_description), :class => 'description', :style => "display: inline-block;") %> - <%= l(:field_is_public) %>: - <%= check_box_tag("attachments[p#{i}][is_public_checkbox]", attachment.is_public, attachment.is_public == 1 ? true : false, :class => 'is_public') %> - <%= if attachment.id.nil? - #待补充代码 - else - link_to(' '.html_safe, attachment_path(attachment, :attachment_id => "p#{i}", :format => 'js'), :method => 'delete', :remote => true, :class => 'remove-upload') - end - %> - <%#= render :partial => 'tags/tag', :locals => {:obj => attachment, :object_flag => "6"} %> - <%= hidden_field_tag "attachments[p#{i}][token]", "#{attachment.token}" %> - -
    - <% end %> <% end %> <% project = project %> diff --git a/app/views/issues/_detail.html.erb b/app/views/issues/_detail.html.erb index b085ce32f..b175bd417 100644 --- a/app/views/issues/_detail.html.erb +++ b/app/views/issues/_detail.html.erb @@ -1,3 +1,4 @@ +
    <%= link_to image_tag(url_to_avatar(@issue.author), :width => 46, :height => 46), user_path(@issue.author), :class => "ping_dispic" %>
    @@ -33,4 +34,5 @@ <%= render :partial => 'issues/attributes_show' %> -
    \ No newline at end of file +
    +
    \ No newline at end of file diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb index 87430e5d6..b1127a3d3 100644 --- a/app/views/issues/_edit.html.erb +++ b/app/views/issues/_edit.html.erb @@ -1,3 +1,4 @@ + \ No newline at end of file diff --git a/app/views/issues/show.html.erb b/app/views/issues/show.html.erb index dc8e2b84a..4c56a0f05 100644 --- a/app/views/issues/show.html.erb +++ b/app/views/issues/show.html.erb @@ -15,12 +15,8 @@
    -
    <%= render :partial => 'issues/detail'%> -
    - + <%= render :partial => 'issues/edit'%>
    diff --git a/app/views/issues/update.js.erb b/app/views/issues/update.js.erb index 7dba2aa5d..d5f213455 100644 --- a/app/views/issues/update.js.erb +++ b/app/views/issues/update.js.erb @@ -1,6 +1,20 @@ -$("#issue_detail").html('<%= escape_javascript(render :partial => 'issues/detail') %>') -$("#issue_edit").html('<%= escape_javascript(render :partial => 'issues/edit') %>') +$("#issue_detail").replaceWith('<%= escape_javascript(render :partial => 'issues/detail') %>') +$("#issue_edit").replaceWith('<%= escape_javascript(render :partial => 'issues/edit') %>') $("#issue_detail").show(); $("#issue_edit").hide(); $("#reply_div_<%= @issue.id %>").html("<%= escape_javascript(render :partial => 'issues/issue_replies', :locals => {:issue => @issue,:replies_all_i=>0}) %>"); -$(".homepagePostReplyBannerCount").html('回复(<%= @issue.journals.count %>)') \ No newline at end of file +$(".homepagePostReplyBannerCount").html('回复(<%= @issue.journals.count %>)') +//edit里的编辑器貌似显示不出来,所以手动js生成。 +issue_desc_editor = KindEditor.create('#issue_description', + {"width":"87%", + "resizeType":0, + "no_label":true, + "autoHeightMode":true, + "afterCreate":"eval(function(){ if(typeof enablePasteImg ==='function'){enablePasteImg(self);} if(typeof enableAt ==='function'){enableAt(self);} this.loadPlugin(\"autoheight\"),$(this.toolbar.div).hide();})", + "afterFocus":"eval(function(){$(this.toolbar.div).show();})", + "afterBlur":"eval(function(){$(this.toolbar.div).hide();})", + "emotionsBasePath":"http://localhost:3000","height":300, + "allowFileManager":true, + "uploadJson":"/kindeditor/upload", + "fileManagerJson":"/kindeditor/filemanager"}); + From 06e5784436cb6a4481972d43b9ac64a988c15c28 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 16 Dec 2015 10:00:10 +0800 Subject: [PATCH 29/80] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E8=8B=B1=E9=9B=84?= =?UTF-8?q?=E6=A6=9C=E4=B8=A4=E4=B8=AA=E7=94=A8=E6=88=B7=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E5=AD=98=E5=9C=A8=E7=9A=84but?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 2 +- ...1215070238_delete_validate_course_contributor.rb | 13 +++++++++++++ db/schema.rb | 2 +- 3 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 db/migrate/20151215070238_delete_validate_course_contributor.rb diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index ec6390408..96853d1c7 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -267,7 +267,7 @@ class JournalsForMessage < ActiveRecord::Base # 课程成员得分(英雄榜) def act_as_student_score - unless self.user.allowed_to?(:as_teacher, self.jour) + if !self.user.allowed_to?(:as_teacher, self.jour) course_member_score(self.jour_id, self.user_id, "JournalForMessage") end end diff --git a/db/migrate/20151215070238_delete_validate_course_contributor.rb b/db/migrate/20151215070238_delete_validate_course_contributor.rb new file mode 100644 index 000000000..704ca893d --- /dev/null +++ b/db/migrate/20151215070238_delete_validate_course_contributor.rb @@ -0,0 +1,13 @@ +class DeleteValidateCourseContributor < ActiveRecord::Migration + def up + course_contributors = CourseContributorScore.where("course_id>? and created_at 20151209085942) do +ActiveRecord::Schema.define(:version => 20151215070238) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From ac8aa9e0a68990e66f07351085df25742d9ea101 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 16 Dec 2015 10:03:51 +0800 Subject: [PATCH 30/80] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E7=95=99=E8=A8=80=E5=92=8C=E8=AF=BE=E7=A8=8B=E7=95=99=E8=A8=80?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/journals_for_message.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index 96853d1c7..396133c7a 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -267,7 +267,7 @@ class JournalsForMessage < ActiveRecord::Base # 课程成员得分(英雄榜) def act_as_student_score - if !self.user.allowed_to?(:as_teacher, self.jour) + if !self.user.allowed_to?(:as_teacher, self.jour) && self.jour_type == "Course" course_member_score(self.jour_id, self.user_id, "JournalForMessage") end end From 02a9f08fe606a2b5d4b6a8b53af7f3711430fb27 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 16 Dec 2015 10:19:48 +0800 Subject: [PATCH 31/80] =?UTF-8?q?=E8=A1=A8=E5=8D=95=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=E5=AF=B9=E9=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 2 +- app/views/issues/_form.html.erb | 4 +-- app/views/issues/new.html.erb | 52 ++++++++++++++++------------ app/views/issues/update.js.erb | 2 +- public/stylesheets/public.css | 3 +- 5 files changed, 36 insertions(+), 27 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 9bb602178..1eb39fb32 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -254,7 +254,7 @@ class IssuesController < ApplicationController if reply_id > 0 JournalReply.add_reply(@issue.current_journal.id, reply_id, User.current.id) end - flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? + #flash[:notice] = l(:notice_successful_update) unless @issue.current_journal.new_record? 去掉这个notice,因为现在更新都是ajax操作 respond_to do |format| format.js format.html { redirect_to issue_url(@issue.id) } diff --git a/app/views/issues/_form.html.erb b/app/views/issues/_form.html.erb index 886ac805a..b96b700d5 100644 --- a/app/views/issues/_form.html.erb +++ b/app/views/issues/_form.html.erb @@ -28,7 +28,7 @@
  • <% if @issue.safe_attribute? 'subject' %> - <%= f.text_field :subject, :class => "w576", :maxlength => 255, :style => "font-size:small", :no_label => true %> + <%= f.text_field :subject, :class => "w606", :maxlength => 255, :style => "font-size:small", :no_label => true %> <%= javascript_tag do %> observeAutocompleteField('issue_subject', @@ -49,7 +49,7 @@ <%= f.label_for_field :description, :required => @issue.required_attribute?('description'), :no_label => true, :class => "label" %> <%#= link_to_function image_tag('edit.png'), '$(this).hide(); $("#issue_description_and_toolbar").show()' unless @issue.new_record? %> <%#= content_tag 'span', :id => "issue_description_and_toolbar" do %> - <%= f.kindeditor :description,:editor_id => "issue_desc_editor", :width=>'87%', :resizeType => 0, :no_label => true %> + <%= f.kindeditor :description,:editor_id => "issue_desc_editor", :width=>'85%', :resizeType => 0, :no_label => true %> <%# end %> <%#= wikitoolbar_for 'issue_description' %> <% end %> diff --git a/app/views/issues/new.html.erb b/app/views/issues/new.html.erb index 9c6ad647c..0e068929d 100644 --- a/app/views/issues/new.html.erb +++ b/app/views/issues/new.html.erb @@ -1,27 +1,35 @@ <%= content_for(:header_tags) do %> <%= import_ke(enable_at: false, prettify: false, init_activity: false) %> <% end %> + +
    +
    +
    新建问题
    +
    +
    + <%= call_hook(:view_issues_new_top, {:issue => @issue}) %> + <%= labelled_form_for @issue, :url => project_issues_path(@project), + :html => {:id => 'issue-form', :multipart => true} do |f| %> + <%= error_messages_for 'issue' %> + <%= hidden_field_tag 'copy_from', params[:copy_from] if params[:copy_from] %> +
    + <%= render :partial => 'issues/form', :locals => {:f => f} %> +
    + + + <%= l(:button_create) %> + + <%#= preview_link preview_new_issue_path(:project_id => @project), 'issue-form', 'preview', {:class => "blue_btn fl ml10"} %> + <% end %> +
    - -
    -

    <%= l(:label_issue_new) %>

    -
    -<%= call_hook(:view_issues_new_top, {:issue => @issue}) %> -<%= labelled_form_for @issue, :url => project_issues_path(@project), - :html => {:id => 'issue-form', :multipart => true} do |f| %> - <%= error_messages_for 'issue' %> - <%= hidden_field_tag 'copy_from', params[:copy_from] if params[:copy_from] %> -
    - <%= render :partial => 'issues/form', :locals => {:f => f} %> + <% content_for :header_tags do %> + <%= robot_exclusion_tag %> + <% end %>
    - - - <%= l(:button_create) %> - - <%#= preview_link preview_new_issue_path(:project_id => @project), 'issue-form', 'preview', {:class => "blue_btn fl ml10"} %> -<% end %> -
    - -<% content_for :header_tags do %> - <%= robot_exclusion_tag %> -<% end %> +
    \ No newline at end of file diff --git a/app/views/issues/update.js.erb b/app/views/issues/update.js.erb index d5f213455..8ff6e5245 100644 --- a/app/views/issues/update.js.erb +++ b/app/views/issues/update.js.erb @@ -6,7 +6,7 @@ $("#reply_div_<%= @issue.id %>").html("<%= escape_javascript(render :partial => $(".homepagePostReplyBannerCount").html('回复(<%= @issue.journals.count %>)') //edit里的编辑器貌似显示不出来,所以手动js生成。 issue_desc_editor = KindEditor.create('#issue_description', - {"width":"87%", + {"width":"85%", "resizeType":0, "no_label":true, "autoHeightMode":true, diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 6c8b71785..003cf90df 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -146,7 +146,8 @@ h4{ font-size:14px; color:#3b3b3b;} .w583{ width:583px;} .w350{ width:350px;} .w610{ width:610px;} -.w600{ width:600px !important;} +.w60{ width:600px !important;} +.w606{ width:606px } .h20{height: 20px;} .h22{ height:22px;} .h26{ height:26px;} From 98d0e6d4111e01f4fa2ec6d37515371c1a3564d0 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 16 Dec 2015 10:53:28 +0800 Subject: [PATCH 32/80] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E2=80=9C?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=98=8E=E7=BB=86=E2=80=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/show.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/repositories/show.html.erb b/app/views/repositories/show.html.erb index aaa740d24..e7616a020 100644 --- a/app/views/repositories/show.html.erb +++ b/app/views/repositories/show.html.erb @@ -53,7 +53,7 @@ - <%=link_to"全部提交次数", {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %> + <%=link_to"提交明细", {:action => 'changes', :path => to_path_param(@path), :id => @project, :repository_id => @repository.identifier_param, :rev => @rev,:page=>1 ,:commit_count =>"#{@changesets_all_count}"} %>
    From bfde278340fa21daffcea250234c7e22f0246ea9 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 16 Dec 2015 11:02:52 +0800 Subject: [PATCH 33/80] =?UTF-8?q?=E5=AD=A6=E7=94=9F=E4=BD=9C=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E7=9A=84=E6=A0=B7=E5=BC=8F=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/courses.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 25d0d6a32..77c839f8d 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -41,7 +41,7 @@ a:hover.news_foot{ color:#787b7e; border:1px solid #d4d4d4;} .pingBoxTit{ float:left; width:625px; margin-left:10px;} .pingText{border:1px solid #CCCCCC; margin:5px; padding:5px; width:610px; height:20px; } .pingBackTit{ float:left; width:573px; margin-left:10px; } -.hworkUl{ height:30px; border-bottom:1px solid #eaeaea; line-height:30px; vertical-align:middle; background-color: #f6f6f6;} +.hworkUl{ height:30px;width:720px; border-bottom:1px solid #eaeaea; line-height:30px; vertical-align:middle; background-color: #f6f6f6;} .hworkH30 {height:30px !important; line-height:30px !important;} .hworkListRow {height:65px; border-bottom:1px dashed #eaeaea; line-height:65px; vertical-align:middle; position: relative;} .hworkListRow:hover {background-color:#f6f6f7;} @@ -1229,4 +1229,4 @@ div.disable_link {background-color: #c1c1c1 !important;} /*新课程资源库*/ .reCon{ margin:5px; width:710px;} -.reTop{width:710px; height:40px; background:#eaeaea; padding:5px;} +.reTop{width:710px; height:40px; background:#eaeaea; padding:5px;} From 5cf88a287b3e343a793adb74adfa126ac5cfa8d7 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 16 Dec 2015 11:37:59 +0800 Subject: [PATCH 34/80] =?UTF-8?q?=E5=88=86=E7=BB=84=E4=BD=9C=E4=B8=9A?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=AD=E7=9A=84=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_user_group_attr.html.erb | 2 +- db/schema.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/users/_user_group_attr.html.erb b/app/views/users/_user_group_attr.html.erb index aa8166a04..652cb723a 100644 --- a/app/views/users/_user_group_attr.html.erb +++ b/app/views/users/_user_group_attr.html.erb @@ -11,7 +11,7 @@

    提醒:勾选后各小组必须在Trustie平台创建项目,教师可随时观察平台对各小组最新进展的实时统计。

    diff --git a/db/schema.rb b/db/schema.rb index 5f53dd5cf..51020f45d 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 => 20151215070238) do +ActiveRecord::Schema.define(:version => 20151215112107) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 2aa241bffa6d49e5922a52f8445e3c8d07e10783 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 16 Dec 2015 11:50:30 +0800 Subject: [PATCH 35/80] issue --- app/views/issues/_list.html.erb | 69 ++++---- app/views/issues/index.html.erb | 283 +++++++++++++++++--------------- public/stylesheets/project.css | 6 +- public/stylesheets/public.css | 1 + 4 files changed, 195 insertions(+), 164 deletions(-) diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index 6fc1898d0..327cc2c75 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -1,35 +1,44 @@ <% issue_list(issues) do |issue, level| -%> - <% if @query.grouped? && (group = @query.group_by_column.value(issue)) != previous_group %> - <% reset_cycle %> - <% previous_group = group %> - <% end %> - -
    - <% column_content = ( query.inline_columns.map {|column| "#{column_content_new(column, issue)}"}) %> - <% unless issue.author.nil? || issue.author.name == "Anonymous" %> - -
    - <%= link_to issue.author.name, user_path(issue.author), :class => "problem_name c_orange fl" %> - <%= l(:label_post_on_issue) %>(<%= "#{raw column_content[2]}" %>): -
    - <%=link_to "#{column_content[4]}#{get_issue_priority(column_content[3])[1]}".html_safe, issue_path(issue.id), :class => "problem_tit_a break_word",:target => "_blank" %> -
    -
    -

    - <% unless issue.assigned_to_id.nil? %> - <%= l(:field_assigned_to) %> - <%=link_to issue.assigned_to(@user), user_path(issue.assigned_to(@user)), :class => "problem_name c_orange f1" %> - <% end %> - <%= l(:label_updated_time_on, format_date(issue.updated_on)).html_safe %> -

    -
    - <%=link_to "#{issue.journals.all.count}".html_safe, issue_path(issue.id), :class => "pro_mes_w" %> + + <%= render :partial => 'users/project_issue', :locals => {:activity => issue, :user_activity_id => issue.id} %> + <% end %>
      <%= pagination_links_full issue_pages, issue_count, :per_page_links => false, :remote => true, :flag => true %>
    \ No newline at end of file diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index 29c038226..df7f9dddc 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -1,10 +1,28 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: true,init_activity: true) %> +<% end %> + -
    -

    <%= l(:label_issue_tracking) %>

    -
    -
    - <% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %> - <%= form_tag({:controller => 'issues', :action => 'index', :project_id => @project},:remote=>'true', :method => :get,:id=>"issue_query_form", :class => 'query_form') do %> - <%= hidden_field_tag 'set_filter', '1' %> - - <%= link_to '新建问题', new_project_issue_path(@project) , :class => "green_u_btn fr ml10" %> -

    <%= l(:label_issues_sum) %>:<%= @project.issues.visible.all.count %> - <%= l(:lable_issues_undo) %>:<%= @project.issues.where('status_id in (1,2,4,6)').visible.all.count %> -

    +
    +
    +
    <%= l(:label_issue_tracking) %>
    +
    +
    + <% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %> + <%= form_tag({:controller => 'issues', :action => 'index', :project_id => @project},:remote=>'true', :method => :get,:id=>"issue_query_form", :class => 'query_form') do %> + <%= hidden_field_tag 'set_filter', '1' %> + + <%#= link_to '新建问题', new_project_issue_path(@project) , :class => "green_u_btn fr ml10" %> +

    <%= l(:label_issues_sum) %>:<%= @project.issues.visible.all.count %> + <%= l(:lable_issues_undo) %>:<%= @project.issues.where('status_id in (1,2,4,6)').visible.all.count %> +

    + +
    +
    + + <%= select( :issue, :user_id, principals_options_for_isuue_list(@project), + { :include_blank => false,:selected=>@assign_to_id ? @assign_to_id : 0 + }, + {:onchange=>"remote_function();",:id=>"assigned_to_id",:name=>"assigned_to_id",:class=>"w90 mr18"} + ) + %> + <%= select( :issue,:prior, [["低",1],["正常",2],["高",3],["紧急",4],["立刻",5]].unshift(["优先级",0]), + { :include_blank => false,:selected=>@priority_id ? @priority_id : 0 + }, + {:onchange=>"remote_function();",:id=>"priority_id",:name=>"priority_id",:class=>"w90 mr18"} + ) + %> + <%= select( :issue,:status, [["新增",1],["正在解决",2],["已解决",3],["反馈",4],["关闭",5],["拒绝",6]].unshift(["状态",0]), + { :include_blank => false,:selected=>@status_id ? @status_id : 0 + }, + {:onchange=>"remote_function();",:id=>"status_id",:name=>"status_id",:class=>"w90 mr18"} + ) + %> + <%= select( :issue,:user_id, @project.members.order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["作者",0]), + { :include_blank => false,:selected=>@author_id ? @author_id : 0 + }, + {:onchange=>"remote_function();",:id=>"author_id",:name=>"author_id",:class=>"w90 mr18"} + ) + %> +
    +
    +
     
    +
    + + <%= text_field_tag 'issue_create_date_start_show', '创建日期起始',:readonly=>true, :size=>15, :nhname=>'date_show',:style=>'float:left;'%> + <%= calendar_for('issue_create_date_start_show') %> +
    +
     - 
    +
    + + <%= text_field_tag 'issue_create_date_end_show', '创建日期结束',:readonly=>true, :size=>15, :nhname=>'date_show',:style=>'float:left;'%> + <%= calendar_for('issue_create_date_end_show') %> +
    +
    +
    + <% end %>
    -
    - - <%= select( :issue, :user_id, principals_options_for_isuue_list(@project), - { :include_blank => false,:selected=>@assign_to_id ? @assign_to_id : 0 - }, - {:onchange=>"remote_function();",:id=>"assigned_to_id",:name=>"assigned_to_id",:class=>"w90"} - ) - %> - <%= select( :issue,:prior, [["低",1],["正常",2],["高",3],["紧急",4],["立刻",5]].unshift(["优先级",0]), - { :include_blank => false,:selected=>@priority_id ? @priority_id : 0 - }, - {:onchange=>"remote_function();",:id=>"priority_id",:name=>"priority_id",:class=>"w90"} - ) - %> - <%= select( :issue,:status, [["新增",1],["正在解决",2],["已解决",3],["反馈",4],["关闭",5],["拒绝",6]].unshift(["状态",0]), - { :include_blank => false,:selected=>@status_id ? @status_id : 0 - }, - {:onchange=>"remote_function();",:id=>"status_id",:name=>"status_id",:class=>"w90"} - ) - %> - <%= select( :issue,:user_id, @project.members.order("lower(users.login)").map{|c| [c.name, c.user_id]}.unshift(["作者",0]), - { :include_blank => false,:selected=>@author_id ? @author_id : 0 - }, - {:onchange=>"remote_function();",:id=>"author_id",:name=>"author_id",:class=>"w90"} - ) - %> -
    -
    -
     
    -
    - - <%= text_field_tag 'issue_create_date_start_show', '创建日期起始',:readonly=>true, :size=>15, :nhname=>'date_show',:style=>'float:left;'%> - <%= calendar_for('issue_create_date_start_show') %> -
    -
     - 
    -
    - - <%= text_field_tag 'issue_create_date_end_show', '创建日期结束',:readonly=>true, :size=>15, :nhname=>'date_show',:style=>'float:left;'%> - <%= calendar_for('issue_create_date_end_show') %> -
    -
    -
    <% end %> +
    -
    - <% end %> -
    -
    - <% if !@query.new_record? && @query.editable_by?(User.current) %> - <%= link_to l(:button_edit), edit_query_path(@query), :class => 'icon icon-edit' %> - <%= delete_link query_path(@query) %> - <% end %> -
    - -<% html_title(@query.new_record? ? l(:label_issue_plural) : @query.name) %> -
    -
    - -<%= error_messages_for 'query' %> - -<% if @query.valid? %> - <% if @issues.empty? %> -

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

    - <% else %> -
    - <%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count} %> -
    - - - <% end %> - -
    - <% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => params.merge(:key => User.current.rss_key) %> - <%= f.link_to 'CSV', :url => params, :onclick => "showModal('csv-export-options', '330px'); return false;" %> - <%= f.link_to 'PDF', :url => params %> +
    + <% if !@query.new_record? && @query.editable_by?(User.current) %> + <%= link_to l(:button_edit), edit_query_path(@query), :class => 'icon icon-edit' %> + <%= delete_link query_path(@query) %> <% end %>
    - \ No newline at end of file diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index aa3297128..c0afe45d5 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -161,9 +161,9 @@ a:hover.invi_search_btn{ background:#0da1b2; border:1px solid #0da1b2;} /*问题跟踪*/ .problem_top{ margin:10px 0 ;} -.problem_search_input{ border:1px solid #64bdd9; width:180px; height:24px; color:#9b9b9b; padding-left:5px; margin-bottom:5px;} -a.problem_search_btn{ background:#64bdd9; color:#fff; text-align: center; width:40px; height:22px;border:1px solid #64bdd9; padding-top:2px; cursor:pointer;} -a:hover.problem_search_btn{ background:#3da1c1; border:1px solid #3da1c1;} +.problem_search_input{ border:1px solid #dddddd; width:180px; height:24px; color:#9b9b9b; padding-left:5px; margin-bottom:5px;} +a.problem_search_btn{ background:#269ac9; color:#fff; text-align: center; width:40px; height:22px;border:1px solid #64bdd9; padding-top:2px; cursor:pointer;} +a:hover.problem_search_btn{ background:#269ac9; border:1px solid #3da1c1;} a.problem_new_btn{ margin-left:10px; border:1px solid #ff7143; color:#ff7143; width:60px; height:21px; font-size:12px; text-align:center; padding-top:3px;} a:hover.problem_new_btn{ background:#ff7143; color:#fff;} .problem_p{ color:#535252; margin-top:5px;} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index 003cf90df..13362dd19 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -87,6 +87,7 @@ h4{ font-size:14px; color:#3b3b3b;} .mr55{ margin-right:55px;} .mr10{ margin-right:10px;} .mr15 {margin-right:15px;} +.mr18 {margin-right:15px;} .mr20{ margin-right:20px;} .mr25 {margin-right:25px;} .mr30{ margin-right:30px;} From dc0f004021426fafd8b5c8864f8fe4289269abaf Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 16 Dec 2015 15:47:30 +0800 Subject: [PATCH 36/80] =?UTF-8?q?=E5=85=B3=E8=81=94=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=9A=84=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/users/_course_homework.html.erb | 27 ++++++++++++++----- .../users/_user_homework_detail.html.erb | 26 +++++++++++++----- public/stylesheets/courses.css | 1 + public/stylesheets/new_user.css | 2 ++ 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index a3aa5d5b1..fe02d9882 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -104,14 +104,29 @@ 已关联项目:
    <% activity.student_work_projects.where("is_leader = 1").each do |pro| %> -
    - <% project = Project.find pro.project_id %> - <% if project.is_public || User.current.member_of?(project) || User.current.admin?%> - <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:alt =>"项目头像" %> + <% project = Project.find pro.project_id %> + +
    + <% if project.is_public || User.current.member_of?(project) || User.current.admin? %> + <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:id=>"project_img_"+project.id.to_s,:alt =>"项目头像" %> <% else %> - <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius") %> + <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius",:id=>"project_img_"+project.id.to_s,:alt =>"项目头像") %> <% end %> -

    <%=project.project_score.score.to_i %>

    +
    + 项目名称:<%=project.name %>
    + 创建者:<%=(User.find project.user_id).show_name %>
    + <% time=project.updated_on %> + <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %> + 更新时间:<%=time_from_now time %> +
    <% end %>
    diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 4217cf1a9..536a9deb6 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -102,18 +102,32 @@ <% if homework_common.homework_type == 3 && !homework_common.student_work_projects.empty? && homework_common.homework_detail_group.base_on_project == 1 %>
    - 已关联项目:
    <% homework_common.student_work_projects.where("is_leader = 1").each do |pro| %> -
    - <% project = Project.find pro.project_id %> + <% project = Project.find pro.project_id %> + +
    <% if project.is_public || User.current.member_of?(project) || User.current.admin? %> - <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:alt =>"项目头像" %> + <%= link_to image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius"),project_path(project.id,:host=>Setting.host_name),:id=>"project_img_"+project.id.to_s,:alt =>"项目头像" %> <% else %> - <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius") %> + <%= image_tag(url_to_avatar(project),:width=>"40",:height => "40",:class => "borderRadius",:id=>"project_img_"+project.id.to_s,:alt =>"项目头像") %> <% end %> -

    <%=project.project_score.score.to_i %>

    +
    + 项目名称:<%=project.name %>
    + 创建者:<%=(User.find project.user_id).show_name %>
    + <% time=project.updated_on %> + <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %> + 更新时间:<%=time_from_now time %> +
    <% end %>
    diff --git a/public/stylesheets/courses.css b/public/stylesheets/courses.css index 77c839f8d..6a6c3a7e7 100644 --- a/public/stylesheets/courses.css +++ b/public/stylesheets/courses.css @@ -1209,6 +1209,7 @@ a:hover.blueCir{ background:#3598db; color:#fff;} .proHelp {background:url(/images/course/hwork_icon.png) -5px -124px no-repeat; display:inline-block; width:15px; height:15px; display:inline-block;} .hworkPrName {width:110px; max-width:110px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; height:18px; line-height:18px; font-size:12px; color:#888888; text-align:center;} .mr150 {margin-right:150px;} +.relatePInfo {position:absolute; background-color:#ffffff; padding:3px 8px; white-space:nowrap; box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5); z-index:999; color:#585858; cursor:pointer; display:none;} /*上传资源弹窗*/ .resourceUploadPopup {width:400px; height:auto; border:3px solid #269ac9 !important; padding-left:16px; padding-bottom:16px; background-color:#ffffff; position:absolute; top:50%; left:50%; margin-left:-200px; z-index:1000;} diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 0ed4df627..5a98211ab 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -1381,3 +1381,5 @@ a:hover.blueCir{ background:#3598db; color:#fff;} .proHelp {background:url(/images/course/hwork_icon.png) -5px -124px no-repeat; display:inline-block; width:15px; height:15px; display:inline-block;} .hworkPrName {width:110px; max-width:110px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; float:left; height:18px; line-height:18px; font-size:12px; color:#888888; text-align:center;} .mr150 {margin-right:150px;} +.relatePInfo {position:absolute; background-color:#ffffff; padding:3px 8px; white-space:nowrap; box-shadow:0px 2px 8px rgba(146, 153, 169, 0.5); z-index:999; color:#585858; cursor:pointer; display:none;} + From b13ae8f599378215f66a71273fa2f7f4cb23a6d9 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 16 Dec 2015 15:55:40 +0800 Subject: [PATCH 37/80] issue --- app/controllers/issues_controller.rb | 2 +- app/views/issues/_list.html.erb | 15 ++++++++++++--- app/views/issues/index.html.erb | 16 ++++++++-------- app/views/issues/index.js.erb | 5 ++--- public/javascripts/application.js | 4 ++++ 5 files changed, 27 insertions(+), 15 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 1eb39fb32..48bf3b568 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -81,7 +81,7 @@ class IssuesController < ApplicationController @status_id = params[:status_id] @subject = params[:subject] @issue_count = @query.issue_count - @issue_pages = Paginator.new @issue_count, @limit, params['page'] + @issue_pages = Paginator.new @issue_count, @limit, params['page'].to_i + 1 @offset ||= @issue_pages.offset @issues = @query.issues(:include => [:assigned_to, :tracker, :priority, :category, :fixed_version], :order => sort_clause, diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index 327cc2c75..c071d57d8 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -39,6 +39,15 @@ <%= render :partial => 'users/project_issue', :locals => {:activity => issue, :user_activity_id => issue.id} %> <% end %> -
      - <%= pagination_links_full issue_pages, issue_count, :per_page_links => false, :remote => true, :flag => true %> -
    \ No newline at end of file + <% if issues.count == 10%> +
    展开更多<%=link_to "", project_issues_path(:project_id => project.id,:page => issue_pages.page),:id => "more_issues_link",:remote => "true",:class => "none" %>
    + <%#= link_to "点击展开更多",user_activities_path(@user.id,:type => type,:page => page),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%> + <% end%> + + + + \ No newline at end of file diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index df7f9dddc..7c358aaed 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -144,19 +144,19 @@

    <% else %>
    - <%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count} %> + <%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count,:project=>@project} %>
    <% end %> -
    - <% other_formats_links do |f| %> - <%= f.link_to 'Atom', :url => params.merge(:key => User.current.rss_key) %> - <%= f.link_to 'CSV', :url => params, :onclick => "showModal('csv-export-options', '330px'); return false;" %> - <%= f.link_to 'PDF', :url => params %> - <% end %> -
    + + + + + + +
  • - <%= student_work.student_score.nil? ? "--" : format("%.1f",student_work.student_score)%> + <%= student_work.student_score.nil? ? "未参与" : format("%.1f",student_work.student_score)%> <% unless student_work.student_score.nil?%> (<%= student_work.student_works_scores.where(:reviewer_role => 3).count%>) @@ -84,7 +84,7 @@ 缺评扣分  <%= student_work.absence_penalty%> 分, 最终成绩为 -  <%= format("%.1f",score)%> 分。 +  <%= format("%.1f",score<0 ? 0 : score)%> 分。
  • <% end%> From c0de5d55de11e13e89386595733639dd08df3eac Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 16 Dec 2015 16:37:00 +0800 Subject: [PATCH 39/80] =?UTF-8?q?=E5=8A=A0=E5=85=A5=E4=BA=86issue=E7=9A=84?= =?UTF-8?q?at=E6=B6=88=E6=81=AF=E6=8F=90=E9=86=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/issue.rb | 8 +++++--- app/views/users/_user_at_message.html.erb | 21 +++++++++++++++++++++ app/views/users/user_messages.html.erb | 2 ++ db/schema.rb | 16 +++++++++++++++- 4 files changed, 43 insertions(+), 4 deletions(-) create mode 100644 app/views/users/_user_at_message.html.erb diff --git a/app/models/issue.rb b/app/models/issue.rb index 11daf670f..5ecb3e36f 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -52,6 +52,7 @@ class Issue < ActiveRecord::Base # ForgeMessage虚拟关联(多态) has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy + has_many :at_messages, class_name: 'AtMessage', as: :at_message ,:dependent => :destroy acts_as_nested_set :scope => 'root_id', :dependent => :destroy acts_as_attachable :before_add => :attachment_added, :after_remove => :attachment_removed @@ -82,7 +83,7 @@ class Issue < ActiveRecord::Base attr_reader :current_journal # fq - after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message + after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message, :act_as_at_message after_update :be_user_score after_destroy :down_user_score # after_create :be_user_score @@ -159,8 +160,9 @@ class Issue < ActiveRecord::Base # at 功能添加消息提醒 def act_as_at_message users = self.description.scan //m - ### xxx 在 xxx 中at了你 - + users && users.flatten.uniq.each do |uid| + self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id) + end end # 更新缺陷 diff --git a/app/views/users/_user_at_message.html.erb b/app/views/users/_user_at_message.html.erb new file mode 100644 index 000000000..0b706c4ce --- /dev/null +++ b/app/views/users/_user_at_message.html.erb @@ -0,0 +1,21 @@ +<% if AtMessage === ma %> +
      +
    • <%=link_to image_tag(url_to_avatar(ma.at_message.author), :width => "30", :height => "30"),user_path(ma.at_message.author) %>
    • +
    • + <%= ma.at_message.author.login %>提到了你: +
    • +
    • + <%= link_to ma.at_message.subject, {:controller => :issues, :action => 'show', :id => ma.at_message.id }, + :class =>"#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", + :onmouseover =>"message_titile_show($(this),event)", + :onmouseout => "message_titile_hide($(this))" %>
    • + +
    • <%= time_tag(ma.created_at).html_safe %>
    • +
    +<% end %> \ No newline at end of file diff --git a/app/views/users/user_messages.html.erb b/app/views/users/user_messages.html.erb index f83e5617c..d690f7e43 100644 --- a/app/views/users/user_messages.html.erb +++ b/app/views/users/user_messages.html.erb @@ -17,6 +17,8 @@ <%# 系统消息 %> <%= render :partial => 'users/user_message_system', :locals => {:ma => ma} %> + <%= render :partial => 'users/user_at_message', :locals => {:ma => ma} %> + <%# 课程消息 %> <%= render :partial => 'users/user_message_course', :locals => {:ma => ma} %> diff --git a/db/schema.rb b/db/schema.rb index 17e613acb..2bf172198 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 => 20151209085942) do +ActiveRecord::Schema.define(:version => 20151216030610) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -66,6 +66,20 @@ ActiveRecord::Schema.define(:version => 20151209085942) do t.datetime "updated_at", :null => false end + create_table "at_messages", :force => true do |t| + t.integer "user_id" + t.integer "at_message_id" + t.string "at_message_type" + t.boolean "viewed" + t.string "container_type" + t.integer "container_id" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + t.integer "sender_id" + end + + add_index "at_messages", ["user_id"], :name => "index_at_messages_on_user_id" + create_table "attachments", :force => true do |t| t.integer "container_id" t.string "container_type", :limit => 30 From a0035a4c1ed46e94ab34255b743323e6ea73341f Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 16 Dec 2015 16:49:33 +0800 Subject: [PATCH 40/80] =?UTF-8?q?issue=20=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/issues_controller.rb | 3 +++ app/views/issues/_list.html.erb | 2 +- app/views/issues/index.html.erb | 2 +- app/views/issues/index.js.erb | 6 +++++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 48bf3b568..3263ebc07 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -87,6 +87,9 @@ class IssuesController < ApplicationController :order => sort_clause, :offset => @offset, :limit => @limit) + if params[:set_filter] + @set_filter = params[:set_filter] + end @issue_count_by_group = @query.issue_count_by_group respond_to do |format| format.js diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb index c071d57d8..115a70e7a 100644 --- a/app/views/issues/_list.html.erb +++ b/app/views/issues/_list.html.erb @@ -40,7 +40,7 @@ <%= render :partial => 'users/project_issue', :locals => {:activity => issue, :user_activity_id => issue.id} %> <% end %> <% if issues.count == 10%> -
    展开更多<%=link_to "", project_issues_path(:project_id => project.id,:page => issue_pages.page),:id => "more_issues_link",:remote => "true",:class => "none" %>
    +
    展开更多<%=link_to "", project_issues_path({:project_id => project.id,:page => issue_pages.page}.merge(params)),:id => "more_issues_link",:remote => "true",:class => "none" %>
    <%#= link_to "点击展开更多",user_activities_path(@user.id,:type => type,:page => page),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%> <% end%> diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb index 7c358aaed..cf0428c27 100644 --- a/app/views/issues/index.html.erb +++ b/app/views/issues/index.html.erb @@ -144,7 +144,7 @@

    <% else %>
    - <%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count,:project=>@project} %> + <%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count,:project=>@project,:subject=>@subject} %>
    diff --git a/app/views/issues/index.js.erb b/app/views/issues/index.js.erb index 9e68f9bc8..9ddc50445 100644 --- a/app/views/issues/index.js.erb +++ b/app/views/issues/index.js.erb @@ -1,2 +1,6 @@ //$("#issue_list").html("<%#= escape_javascript(render :partial => 'issues/list',:locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count})%>"); -$("#show_more_issues").replaceWith("<%= escape_javascript( render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count,:project=>@project} )%>"); +<% if @set_filter && @issue_pages.page == 1%> + $("#issue_list").html("<%= escape_javascript(render :partial => 'issues/list',:locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count,:project=>@project})%>"); +<%else%> + $("#show_more_issues").replaceWith("<%= escape_javascript( render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count,:project=>@project} )%>"); +<%end%> From 66f88cdf5ad02a6c21493eabd086b48238e0bedb Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 16 Dec 2015 16:55:07 +0800 Subject: [PATCH 41/80] =?UTF-8?q?issue=20=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/issues/index.js.erb | 2 +- public/stylesheets/project.css | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/views/issues/index.js.erb b/app/views/issues/index.js.erb index 9ddc50445..399c6a977 100644 --- a/app/views/issues/index.js.erb +++ b/app/views/issues/index.js.erb @@ -1,5 +1,5 @@ //$("#issue_list").html("<%#= escape_javascript(render :partial => 'issues/list',:locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count})%>"); -<% if @set_filter && @issue_pages.page == 1%> +<% if @set_filter && @issue_pages.page == 1%> //只有搜索的第一页才需要替换整个issue_list,其余的都是替换show_more_issues $("#issue_list").html("<%= escape_javascript(render :partial => 'issues/list',:locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count,:project=>@project})%>"); <%else%> $("#show_more_issues").replaceWith("<%= escape_javascript( render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query,:issue_pages=>@issue_pages,:issue_count=>@issue_count,:project=>@project} )%>"); diff --git a/public/stylesheets/project.css b/public/stylesheets/project.css index c0afe45d5..db41a1c5c 100644 --- a/public/stylesheets/project.css +++ b/public/stylesheets/project.css @@ -1078,4 +1078,7 @@ img.date-trigger { } .proInfoBox{ margin-left:60px; border:1px solid #dddddd; height:45px; padding:10px 0; background-color:#f1f1f1;} .proInfoBox ul li{ height:24px;} -.proInfoP{color:#000000 !important; float:left; width:80px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } \ No newline at end of file +.proInfoP{color:#000000 !important; float:left; width:80px; overflow:hidden; white-space: nowrap; text-overflow:ellipsis; } + +a.link_file_a{ background:url(../images/pic_file.png) 0 2px no-repeat; padding-left:20px; } +a:hover.link_file_a{ background:url(../images/pic_file.png) 0 -25px no-repeat; color:#3ca5c6;} \ No newline at end of file From bb23049f5555dcc5455aacf9e664c30c83aaae9a Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 16 Dec 2015 17:04:17 +0800 Subject: [PATCH 42/80] =?UTF-8?q?=E7=89=88=E6=9C=AC=E5=BA=93=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E6=AC=A1=E6=95=B0=E5=B0=81=E8=A3=85=20=E6=8F=90?= =?UTF-8?q?=E4=BA=A4=E9=A1=B5=E9=9D=A2=E6=A0=B7=E5=BC=8F=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/repositories_controller.rb | 37 ++----------------- app/helpers/application_helper.rb | 36 +++++++++++++++++++ app/helpers/project_score_helper.rb | 1 + app/views/repositories/_revisions.html.erb | 42 ++++++++-------------- 4 files changed, 54 insertions(+), 62 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index f0b15e8f8..8eb6a6860 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -348,10 +348,6 @@ update # end # end - - - - @changesets = g.commits(@project.gpid, :ref_name => @rev) # @changesets = @repository.latest_changesets(@path, @rev) # @changesets_count = @repository.latest_changesets(@path, @rev).count @@ -378,19 +374,6 @@ update alias_method :browse, :show - #add by hx - def count_commits(project_id , left , right) - count = 0 - (left..right).each do |page| - if $g.commits(project_id,:page => page).count == 0 - break - else - count = count + $g.commits(project_id,:page => page).count - end - end - return count - end - def changes @entry = @repository.entry(@path, @rev) (show_error_not_found; return) unless @entry @@ -400,26 +383,10 @@ update @commits = g.commits(@project.gpid, page:(params[:page].to_i - 1).to_s) #add by hx - if g.commits(@project.gpid , :page=>200).count > 0 - count = 4020 - elsif g.commits(@project.gpid , :page=>25).count==0 - count = count_commits(@project.gpid , 0 , 25) - elsif g.commits(@project.gpid , :page=>50).count ==0 - count = count_commits(@project.gpid , 25 , 50)+ 25 * 20 - elsif g.commits(@project.gpid , :page=>75).count ==0 - count = count_commits(@project.gpid , 50 , 75)+ 50 * 20 - elsif g.commits(@project.gpid , :page=>100).count== 0 - count = count_commits(@project.gpid , 75 , 100) + 75 * 20 - elsif g.commits(@project.gpid , :page=>125).count==0 - count = count_commits(@project.gpid , 100 , 125) + 100 * 20 - elsif g.commits(@project.gpid , :page=>150).count==0 - count = count_commits(@project.gpid , 125 , 150) + 125 * 20 - else - count = count_commits(@project.gpid , 150 ,200) + 150 * 20 - end + rep_count = commit_count(@project) #页面传递必须要str类型,但是Paginator的初始化必须要num类型,需要类型转化 - @commits_count = count + @commits_count = rep_count @commits_pages = Redmine::Pagination::Paginator.new @commits_count,limit,params[:page] @commit = g.commit(@project.gpid,@rev) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 5a9563b73..667314531 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -668,6 +668,42 @@ module ApplicationHelper return rep.blank? ? true :false end + # 获取Gitlab版本库提交总数 + def commit_count(project) + g = Gitlab.client + #add by hx + if g.commits(project.gpid , :page=>200).count > 0 + count = 4020 + elsif g.commits(project.gpid , :page=>25).count==0 + count = count_commits(project.gpid , 0 , 25) + elsif g.commits(project.gpid , :page=>50).count ==0 + count = count_commits(project.gpid , 25 , 50)+ 25 * 20 + elsif g.commits(project.gpid , :page=>75).count ==0 + count = count_commits(project.gpid , 50 , 75)+ 50 * 20 + elsif g.commits(project.gpid , :page=>100).count== 0 + count = count_commits(project.gpid , 75 , 100) + 75 * 20 + elsif g.commits(project.gpid , :page=>125).count==0 + count = count_commits(project.gpid , 100 , 125) + 100 * 20 + elsif g.commits(project.gpid , :page=>150).count==0 + count = count_commits(project.gpid , 125 , 150) + 125 * 20 + else + count = count_commits(project.gpid , 150 ,200) + 150 * 20 + end + end + + #add by hx + def count_commits(project_id , left , right) + count = 0 + (left..right).each do |page| + if $g.commits(project_id,:page => page).count == 0 + break + else + count = count + $g.commits(project_id,:page => page).count + end + end + return count + end + # 获取单一gitlab项目 def gitlab_repository(project) rep = Repository.where("project_id =? and type =?", project.id,"Repository::Gitlab" ).first diff --git a/app/helpers/project_score_helper.rb b/app/helpers/project_score_helper.rb index 104cd16cb..256e35a7a 100644 --- a/app/helpers/project_score_helper.rb +++ b/app/helpers/project_score_helper.rb @@ -22,6 +22,7 @@ module ProjectScoreHelper #代码提交数量 def changesets_num project + # commit_count(project) project.changesets.count end diff --git a/app/views/repositories/_revisions.html.erb b/app/views/repositories/_revisions.html.erb index b72a05876..4d6e39f88 100644 --- a/app/views/repositories/_revisions.html.erb +++ b/app/views/repositories/_revisions.html.erb @@ -20,42 +20,31 @@
    @@ -65,7 +54,6 @@

    <%#= submit_tag(l(:label_view_diff), :name => nil, :class=>"c_blue") if show_diff %>

    -
      <%= pagination_links_full commits_pages, commits_count, :per_page_links => false, :remote => false, :flag => true %>
    From ffd8d55aa6ef3e5702f7b7da75ec535987d849a6 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 16 Dec 2015 17:08:59 +0800 Subject: [PATCH 43/80] =?UTF-8?q?memo=E6=9B=B4=E6=96=B0=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/memos_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/memos_controller.rb b/app/controllers/memos_controller.rb index 2d2c058d4..a47ddf787 100644 --- a/app/controllers/memos_controller.rb +++ b/app/controllers/memos_controller.rb @@ -159,7 +159,8 @@ class MemosController < ApplicationController @memo.update_column(:content, params[:memo][:content]) && @memo.update_column(:sticky, params[:memo][:sticky]) && @memo.update_column(:lock, params[:memo][:lock]) && - @memo.update_column(:subject,params[:memo][:subject])) + @memo.update_column(:subject,params[:memo][:subject]) && + @memo.update_column(:updated_at,Time.now)) @memo.save_attachments(params[:attachments] || (params[:memo] && params[:memo][:uploads])) @flag = @memo.save # @memo.root.update_attribute(:updated_at, @memo.updated_at) From 71f6a637e06c103e228a0d1d95ee57f4a273bad4 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Wed, 16 Dec 2015 17:26:19 +0800 Subject: [PATCH 44/80] =?UTF-8?q?=E5=B8=96=E5=AD=90=E6=8C=89=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=80=92=E6=8E=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/forums_controller.rb | 4 +-- app/views/forums/show.html.erb | 6 ++-- db/schema.rb | 43 ++++++++++++++++------------ 3 files changed, 31 insertions(+), 22 deletions(-) diff --git a/app/controllers/forums_controller.rb b/app/controllers/forums_controller.rb index efbb4ffab..3332f1207 100644 --- a/app/controllers/forums_controller.rb +++ b/app/controllers/forums_controller.rb @@ -147,8 +147,8 @@ class ForumsController < ApplicationController order = "#{Memo.table_name}.updated_at #{params[:reorder_time]}" @order_str = "reorder_time="+params[:reorder_time] else - order = "last_replies_memos.created_at desc, #{Memo.table_name}.created_at desc" - @order_str = "reorder_complex=desc" + order = "#{Memo.table_name}.updated_at desc" + @order_str = "reorder_time=desc" end @memo = Memo.new(:forum => @forum) @topic_count = @forum.topics.count diff --git a/app/views/forums/show.html.erb b/app/views/forums/show.html.erb index 2a7a02e57..b0ed5a60c 100644 --- a/app/views/forums/show.html.erb +++ b/app/views/forums/show.html.erb @@ -30,9 +30,11 @@ <% end %>
    diff --git a/db/schema.rb b/db/schema.rb index 17e613acb..bcc6b2c80 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -544,26 +544,23 @@ ActiveRecord::Schema.define(:version => 20151209085942) do add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["project_id"], :name => "documents_project_id" - create_table "dts", :primary_key => "Num", :force => true do |t| - t.string "Defect", :limit => 50 - t.string "Category", :limit => 50 - t.string "File" - t.string "Method" - t.string "Module", :limit => 20 - t.string "Variable", :limit => 50 - t.integer "StartLine" - t.integer "IPLine" - t.string "IPLineCode", :limit => 200 - t.string "Judge", :limit => 15 - t.integer "Review", :limit => 1 + create_table "dts", :force => true do |t| + t.string "IPLineCode" t.string "Description" - t.text "PreConditions", :limit => 2147483647 - t.text "TraceInfo", :limit => 2147483647 - t.text "Code", :limit => 2147483647 + t.string "Num" + t.string "Variable" + t.string "TraceInfo" + t.string "Method" + t.string "File" + t.string "IPLine" + t.string "Review" + t.string "Category" + t.string "Defect" + t.string "PreConditions" + t.string "StartLine" t.integer "project_id" - t.datetime "created_at" - t.datetime "updated_at" - t.integer "id", :null => false + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "editor_of_documents", :force => true do |t| @@ -912,6 +909,16 @@ ActiveRecord::Schema.define(:version => 20151209085942) do add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" + create_table "journal_details_copy", :force => true do |t| + t.integer "journal_id", :default => 0, :null => false + t.string "property", :limit => 30, :default => "", :null => false + t.string "prop_key", :limit => 30, :default => "", :null => false + t.text "old_value" + t.text "value" + end + + add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id" + create_table "journal_replies", :id => false, :force => true do |t| t.integer "journal_id" t.integer "user_id" From a8c8dc3cc6a913967f0b2dc29997afc08430b89a Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 16 Dec 2015 17:38:28 +0800 Subject: [PATCH 45/80] =?UTF-8?q?=E5=85=B3=E8=81=94=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=9A=84=E6=8F=90=E7=A4=BA=E4=BF=A1=E6=81=AF=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../student_work/_relate_project.html.erb | 2 +- app/views/users/_course_homework.html.erb | 24 +++++++++++------ .../users/_user_homework_detail.html.erb | 26 ++++++++++++++----- 3 files changed, 36 insertions(+), 16 deletions(-) diff --git a/app/views/student_work/_relate_project.html.erb b/app/views/student_work/_relate_project.html.erb index 43f59c9c9..9a1fcead5 100644 --- a/app/views/student_work/_relate_project.html.erb +++ b/app/views/student_work/_relate_project.html.erb @@ -4,7 +4,7 @@ <%=form_tag url_for(:controller=>'student_work',:action=>'student_work_project',:homework=>@homework.id,:user_activity_id=>@user_activity_id,:is_in_course=>@is_in_course,:course_activity =>@course_activity),:id =>'student_work_relate_project',:class=>'resourcesSearchBox',:remote => true do %>
    - +

      diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index fe02d9882..8112bc521 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -13,7 +13,7 @@ <% end %> TO <%= link_to activity.course.name.to_s+" | 课程作业", homework_common_index_path(:course => activity.course.id, :host=> Setting.host_course), :class => "newsBlue ml15"%>
      - <% end %> -
      截止时间:<%= activity.end_time.to_s %> 23:59
      @@ -93,17 +92,26 @@
      +
      +
      + 匿评开启时间:<%= activity.homework_detail_manual.evaluation_start%> 00:00 +
      +
      + 匿评关闭时间:<%= activity.homework_detail_manual.evaluation_end%> 23:59 +
      +
      +
      <%= render :partial => 'student_work/work_attachments', :locals => {:attachments => activity.attachments} %>
      - <% if activity.homework_type == 3 && !activity.student_work_projects.empty? && activity.homework_detail_group.base_on_project == 1 %> + <% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %>
      + <% projects = activity.student_work_projects.where("is_leader = 1") %>
      - - 已关联项目: + 已关联项目:<%='各小组尚未将小组项目关联到本次作业。' if projects.empty? %>
      - <% activity.student_work_projects.where("is_leader = 1").each do |pro| %> + <% projects.each do |pro| %> <% project = Project.find pro.project_id %>
      -
      -
      问题跟踪
      -
      +
      +
      问题跟踪
      +
      -
      +
      <%= render :partial => 'issues/detail'%> @@ -22,30 +22,32 @@
      -
      -
      -
      回复(<%= @issue.journals.count %>)
      -
      -
      +
      +
      +
      回复(<%= @issue.journals.count %>)
      +
      +
      -
      - <%= render :partial => 'issue_replies',:locals => {:issue=>@issue,:replies_all_i=>0} %> -
      +
      + <%= render :partial => 'issue_replies',:locals => {:issue=>@issue,:replies_all_i=>0} %> +
      -
      - <%= form_for('new_form',:url => add_journal_issue_path(@issue.id),:method => "post", :remote => true) do |f|%> -
      - <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@issue.author_id), :alt => "用户头像" %> -
      - -
      - <%= kindeditor_tag :notes,"",:height=>"33",:minHeight=>"33",:editor_id=>"issues_reply_editor"%> -
      +
      + <%= form_for('new_form',:url => add_journal_issue_path(@issue.id),:method => "post", :remote => true) do |f|%> +
      + <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(@issue.author_id), :alt => "用户头像" %>
      - 发送 -
      - <% end %> -
      -
      - \ No newline at end of file + +
      + <%= kindeditor_tag :notes,"",:height=>"33",:minHeight=>"33",:editor_id=>"issues_reply_editor"%> +
      +
      + 发送 +
      + <% end %> +
      +
      +
      +
      +
      \ No newline at end of file diff --git a/plugins/redmine_ckeditor/app/views/issues/update_form.js.erb b/plugins/redmine_ckeditor/app/views/issues/update_form.js.erb index e7d3e2ad2..23bd5108b 100644 --- a/plugins/redmine_ckeditor/app/views/issues/update_form.js.erb +++ b/plugins/redmine_ckeditor/app/views/issues/update_form.js.erb @@ -9,3 +9,15 @@ $('#all_attributes').html('<%= escape_javascript(render :partial => 'form') %>') <% else %> $('#log_time').hide(); <% end %> +issue_desc_editor = KindEditor.create('#issue_description', + {"width":"85%", + "resizeType":0, + "no_label":true, + "autoHeightMode":true, + "afterCreate":"eval(function(){ if(typeof enablePasteImg ==='function'){enablePasteImg(self);} if(typeof enableAt ==='function'){enableAt(self);} this.loadPlugin(\"autoheight\"),$(this.toolbar.div).hide();})", + "afterFocus":"eval(function(){$(this.toolbar.div).show();})", + "afterBlur":"eval(function(){$(this.toolbar.div).hide();})", + "emotionsBasePath":"http://localhost:3000", + "height":300,"allowFileManager":true, + "uploadJson":"/kindeditor/upload", + "fileManagerJson":"/kindeditor/filemanager"}); \ No newline at end of file From b02cb6fdd4c3056e820eff35881ed3008d2373c4 Mon Sep 17 00:00:00 2001 From: lizanle <491823689@qq.com> Date: Thu, 17 Dec 2015 11:30:52 +0800 Subject: [PATCH 55/80] =?UTF-8?q?issue=E7=9A=84=E4=BF=AE=E6=94=B9=E5=A6=82?= =?UTF-8?q?=E6=9E=9C=E6=9B=B4=E6=94=B9issue=E7=9A=84=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=EF=BC=8C=E9=82=A3=E4=B9=88=E5=B0=B1=E4=BC=9A=E6=9C=89=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E3=80=82=E9=9C=80=E8=A6=81=E9=87=8D=E6=96=B0=E6=96=B0?= =?UTF-8?q?=E5=BB=BAeditor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/issues/_edit.html.erb | 3 +-- app/views/issues/_form.html.erb | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/views/issues/_edit.html.erb b/app/views/issues/_edit.html.erb index b1127a3d3..2879c9592 100644 --- a/app/views/issues/_edit.html.erb +++ b/app/views/issues/_edit.html.erb @@ -10,8 +10,7 @@
      <%= render :partial => 'issues/form', :locals => {:f => f} %> - 确定 - 取消 +
      <%# if @journals.present? %> diff --git a/app/views/issues/_form.html.erb b/app/views/issues/_form.html.erb index b96b700d5..7cda806a1 100644 --- a/app/views/issues/_form.html.erb +++ b/app/views/issues/_form.html.erb @@ -102,3 +102,5 @@ <%= call_hook(:view_issues_form_details_bottom, {:issue => @issue, :form => f}) %> <% end %> + 确定 + 取消 \ No newline at end of file From 721a007779102df75494aaddec312e99649dfae7 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Dec 2015 13:22:41 +0800 Subject: [PATCH 56/80] =?UTF-8?q?=E5=88=A0=E9=99=A4=20=E7=94=B1=E4=BA=8Eco?= =?UTF-8?q?urse=E3=80=81project=E4=B8=80=E5=BC=A0=E8=A1=A8=E8=80=8C?= =?UTF-8?q?=E5=BC=95=E8=B5=B7=E7=9A=84=E5=8E=86=E5=8F=B2=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20151217051447_delete_valid_project.rb | 15 +++++++++++++++ db/schema.rb | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20151217051447_delete_valid_project.rb diff --git a/db/migrate/20151217051447_delete_valid_project.rb b/db/migrate/20151217051447_delete_valid_project.rb new file mode 100644 index 000000000..fd99ac08e --- /dev/null +++ b/db/migrate/20151217051447_delete_valid_project.rb @@ -0,0 +1,15 @@ +class DeleteValidProject < ActiveRecord::Migration + def up + projects = Project.where("project_type =?", 1) + begin + projects.each do |p| + p.delete + end + rescue => e + logger.error "Delete project failed ====>#{e}" + end + end + + def down + end +end diff --git a/db/schema.rb b/db/schema.rb index 5f53dd5cf..27de276b1 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 => 20151215070238) do +ActiveRecord::Schema.define(:version => 20151217051447) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false From 2d2329a1e098d4be0c7e1db1dcfbcee74456c65f Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 17 Dec 2015 14:31:55 +0800 Subject: [PATCH 57/80] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E5=AE=9A=E4=BD=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/repositories/_link_to_functions.html.erb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/repositories/_link_to_functions.html.erb b/app/views/repositories/_link_to_functions.html.erb index fc3784d46..0e2a402ae 100644 --- a/app/views/repositories/_link_to_functions.html.erb +++ b/app/views/repositories/_link_to_functions.html.erb @@ -5,9 +5,9 @@ <% if @repository.supports_cat? %> <%= link_to_if action_name != 'entry', l(:button_view), {:action => 'entry', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(@path), :rev => @rev } %> | <% end %> -<% if @repository.supports_annotate? %> - <%= link_to_if action_name != 'annotate', l(:button_annotate), {:action => 'annotate', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(@path), :rev => @rev } %> | -<% end %> +<%# if @repository.supports_annotate? %> + <%#= link_to_if action_name != 'annotate', l(:button_annotate), {:action => 'annotate', :id => @project, :repository_id => @repository.identifier_param, :path => to_path_param(@path), :rev => @rev } %> +<%# end %> <%= link_to(l(:button_download), {:action => 'raw', :id => @project, :repository_id => @repository.identifier_param, From fc63dfcb7bde22f6d8d01c976aa2e695c6939800 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Thu, 17 Dec 2015 15:14:52 +0800 Subject: [PATCH 58/80] =?UTF-8?q?=E6=B6=88=E6=81=AF=E9=80=9A=E7=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/at_controller.rb | 8 +- app/controllers/boards_controller.rb | 5 + app/controllers/homework_common_controller.rb | 8 ++ app/controllers/issues_controller.rb | 8 ++ app/helpers/users_helper.rb | 3 +- app/models/at_message.rb | 100 ++++++++++++++++++ app/models/journal.rb | 13 ++- app/models/journals_for_message.rb | 10 +- app/models/message.rb | 15 ++- app/models/user.rb | 1 + app/views/boards/_course_show.html.erb | 2 +- app/views/boards/_project_show.html.erb | 6 +- app/views/boards/show.html.erb | 6 +- app/views/users/_user_at_message.html.erb | 16 +-- .../20151216025539_create_at_messages.rb | 15 +++ ...20151216030610_add_sender_to_at_message.rb | 5 + spec/factories/at_messages.rb | 12 +++ spec/models/at_message_spec.rb | 5 + 18 files changed, 218 insertions(+), 20 deletions(-) create mode 100644 app/models/at_message.rb create mode 100644 db/migrate/20151216025539_create_at_messages.rb create mode 100644 db/migrate/20151216030610_add_sender_to_at_message.rb create mode 100644 spec/factories/at_messages.rb create mode 100644 spec/models/at_message_spec.rb diff --git a/app/controllers/at_controller.rb b/app/controllers/at_controller.rb index 5664201f3..8c551d0df 100644 --- a/app/controllers/at_controller.rb +++ b/app/controllers/at_controller.rb @@ -28,11 +28,17 @@ class AtController < ApplicationController find_message(id) when 'HomeworkCommon' find_homework(id) + when 'Topic' + find_topic(id) else nil end end + def find_topic(id) + + end + def find_issue(id) #1. issues list persons #2. project persons @@ -98,7 +104,7 @@ class AtController < ApplicationController def find_message(id) message = Message.find(id) at_persons = message.board.messages.map(&:author) - + (at_persons || []) + (find_project(message.board.project_id)||[]) end #News diff --git a/app/controllers/boards_controller.rb b/app/controllers/boards_controller.rb index 2ec3cac0d..22c0d5317 100644 --- a/app/controllers/boards_controller.rb +++ b/app/controllers/boards_controller.rb @@ -79,6 +79,11 @@ class BoardsController < ApplicationController end end end + + @project.boards.messages.each do |m| + User.current.at_messages.unviewed('Message', m.id).each {|x| x.viewed!} + end + elsif @course query_course_messages = @board.messages query_course_messages.each do |query_course_message| diff --git a/app/controllers/homework_common_controller.rb b/app/controllers/homework_common_controller.rb index a8d6dfe8f..b42868ce1 100644 --- a/app/controllers/homework_common_controller.rb +++ b/app/controllers/homework_common_controller.rb @@ -19,6 +19,14 @@ class HomeworkCommonController < ApplicationController @is_teacher = User.current.logged? && (User.current.admin? || User.current.allowed_to?(:as_teacher,@course)) @is_student = User.current.logged? && (User.current.admin? || (User.current.member_of_course?(@course) && !@is_teacher)) @is_new = params[:is_new] + + #设置at已读 + @homeworks.each do |homework| + homework.journals_for_messages.each do |j| + User.current.at_messages.unviewed('JournalsForMessage', j.id).each {|x| x.viewed!} + end + end + respond_to do |format| format.js format.html diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb index 6f441c29a..44fc7dcba 100644 --- a/app/controllers/issues_controller.rb +++ b/app/controllers/issues_controller.rb @@ -115,6 +115,14 @@ class IssuesController < ApplicationController # 当前用户查看指派给他的缺陷消息,则设置消息为已读 query = ForgeMessage.where("forge_message_type =? and user_id =? and forge_message_id =?", "Issue", User.current, @issue).first query.update_attribute(:viewed, true) unless query.nil? + + # issue 新建的at消息 + User.current.at_messages.unviewed('Issue', @issue.id).each {|x| x.viewed!} + # 回复的at消息 + @issue.journals.each do |j| + User.current.at_messages.unviewed('Journal', j.id).each {|x| x.viewed!} + end + # 缺陷状态更新 query_journals = @issue.journals query_journals.each do |query_journal| diff --git a/app/helpers/users_helper.rb b/app/helpers/users_helper.rb index 2935d018a..963284f7f 100644 --- a/app/helpers/users_helper.rb +++ b/app/helpers/users_helper.rb @@ -89,7 +89,8 @@ module UsersHelper forge_count = ForgeMessage.where("user_id =? and viewed =?", user, 0).count user_feedback_count = UserFeedbackMessage.where("user_id =? and viewed =?", user, 0).count user_memo_count = MemoMessage.where("user_id =? and viewed =?", user, 0).count - messages_count = course_count + forge_count + user_feedback_count + user_memo_count + at_count = user.at_messages.where(viewed: false).count + messages_count = course_count + forge_count + user_feedback_count + user_memo_count + at_count end def user_mail_notification_options(user) diff --git a/app/models/at_message.rb b/app/models/at_message.rb new file mode 100644 index 000000000..1a75c4aae --- /dev/null +++ b/app/models/at_message.rb @@ -0,0 +1,100 @@ +class AtMessage < ActiveRecord::Base + belongs_to :user + belongs_to :sender, class_name: "User", foreign_key: "sender_id" + attr_accessible :at_message, :container, :viewed, :user_id, :sender_id + belongs_to :at_message, polymorphic: true + belongs_to :container, polymorphic: true + + has_many :message_alls, :class_name => 'MessageAll',:as =>:message, :dependent => :destroy + validates :user_id, :sender_id, :at_message_id, :at_message_type, presence: true + + after_create :add_user_message + + scope :unviewed, ->(type, id){ + where(at_message_type: type, at_message_id:id, viewed: false) + } + + def viewed! + update_attribute :viewed, true + end + + def at_valid? + return true if at_message_type == 'Issue' + return true if 'Journal' == at_message_type + return true if 'JournalsForMessage' == at_message_type + return true if 'Message' == at_message_type + false + end + + def add_user_message + if MessageAll.where(message_type: self.class.name,message_id: self.id).empty? + self.message_alls << MessageAll.new(:user_id => self.user_id) + end + end + + def subject + case at_message_type + when "Issue" + "新建问题: " + at_message.subject + when "Journal" + "问题留言: " + at_message.journalized.subject + when 'Message' + if(at_message.topic?) + "发布新帖: " + else + "回复帖子: " + end + at_message.subject + when 'JournalsForMessage' + "作业留言: " + at_message.jour.description + else + logger.error "error type: #{at_message_type}" + end + end + + def description + case at_message_type + when "Issue" + at_message.description + when "Journal" + at_message.notes + when 'Message' + at_message.content + when "JournalsForMessage" + at_message.notes + else + logger.error "error type: #{at_message_type}" + end + end + + def author + case at_message_type + when "Issue" + at_message.author + when "Journal" + at_message.user + when 'Message' + at_message.author + when 'JournalsForMessage' + at_message.user + else + logger.error "error type: #{at_message_type}" + end + end + + def url + case at_message_type + when "Issue" + {controller: :issues, action: :show, id: at_message} + when "Journal" + {controller: :issues, action: :show, id: at_message.journalized} + when 'Message' + {controller: :boards, action: :show, project_id: at_message.board.project, id: at_message.board} + when 'JournalsForMessage' + {controller: :homework_common, action: :index, course: at_message.jour.course_id} + else + logger.error "error type: #{at_message_type}" + end + + end + +end diff --git a/app/models/journal.rb b/app/models/journal.rb index 9ffc5d405..8aec82911 100644 --- a/app/models/journal.rb +++ b/app/models/journal.rb @@ -31,7 +31,9 @@ class Journal < ActiveRecord::Base has_many :forge_acts, :class_name => 'ForgeActivity',:as =>:forge_act ,:dependent => :destroy # 被ForgeMessage虚拟关联 has_many :forge_messages, :class_name => 'ForgeMessage',:as =>:forge_message ,:dependent => :destroy - # end + + has_many :at_messages, as: :at_message, dependent: :destroy + attr_accessor :indice acts_as_event :title =>Proc.new {|o| status = ((s = o.new_status) ? " (#{s})" : nil); "#{o.issue.tracker} ##{o.issue.project_index}#{status}: #{o.issue.subject}" }, @@ -50,7 +52,7 @@ class Journal < ActiveRecord::Base before_create :split_private_notes # fq - after_save :act_as_activity,:be_user_score,:act_as_forge_activity, :act_as_forge_message + after_save :act_as_activity,:be_user_score,:act_as_forge_activity, :act_as_forge_message, :act_as_at_message # end #after_destroy :down_user_score #before_save :be_user_score @@ -184,6 +186,13 @@ class Journal < ActiveRecord::Base end end + def act_as_at_message + users = self.notes.scan //m + users && users.flatten.uniq.each do |uid| + self.at_messages << AtMessage.new(user_id: uid, sender_id: self.user_id) + end + end + # 更新用户分数 -by zjc def be_user_score #新建了缺陷留言且留言不为空,不为空白 diff --git a/app/models/journals_for_message.rb b/app/models/journals_for_message.rb index ec6390408..d1431d31f 100644 --- a/app/models/journals_for_message.rb +++ b/app/models/journals_for_message.rb @@ -64,8 +64,10 @@ class JournalsForMessage < ActiveRecord::Base has_many :course_messages, :class_name => 'CourseMessage',:as =>:course_message ,:dependent => :destroy has_many :user_feedback_messages, :class_name => 'UserFeedbackMessage', :as =>:journals_for_message, :dependent => :destroy + has_many :at_messages, as: :at_message, dependent: :destroy + validates :notes, presence: true, if: :is_homework_jour? - after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_user_feedback_message, :act_as_principal_activity, :act_as_student_score + after_create :act_as_activity, :act_as_course_activity, :act_as_course_message, :act_as_at_message, :act_as_user_feedback_message, :act_as_principal_activity, :act_as_student_score after_create :reset_counters! after_destroy :reset_counters! after_save :be_user_score @@ -240,6 +242,12 @@ class JournalsForMessage < ActiveRecord::Base end end + def act_as_at_message + users = self.notes.scan //m + users && users.flatten.uniq.each do |uid| + self.at_messages << AtMessage.new(user_id: uid, sender_id: self.user_id) + end + end # 用户留言消息通知 def act_as_user_feedback_message # 主留言 diff --git a/app/models/message.rb b/app/models/message.rb index d8f62171a..4cdae1f6e 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -38,7 +38,7 @@ class Message < ActiveRecord::Base # 课程/项目 消息 has_many :course_messages, :class_name =>'CourseMessage', :as => :course_message, :dependent => :destroy has_many :forge_messages, :class_name => 'ForgeMessage', :as => :forge_message, :dependent => :destroy - #end + has_many :at_messages, as: :at_message, dependent: :destroy has_many :ActivityNotifies,:as => :activity, :dependent => :destroy @@ -74,7 +74,7 @@ class Message < ActiveRecord::Base after_update :update_messages_board after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets - after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score + after_create :act_as_activity,:act_as_course_activity,:be_user_score,:act_as_forge_activity, :act_as_system_message, :send_mail, :act_as_student_score, :act_as_at_message #before_save :be_user_score scope :visible, lambda {|*args| @@ -96,6 +96,10 @@ class Message < ActiveRecord::Base end } + def topic? + parent_id.nil? + end + def visible?(user=User.current) if project !user.nil? && user.allowed_to?(:view_messages, project) @@ -237,6 +241,13 @@ class Message < ActiveRecord::Base end end end + + def act_as_at_message + users = self.content.scan //m + users && users.flatten.uniq.each do |uid| + self.at_messages << AtMessage.new(user_id: uid, sender_id: self.author_id) + end + end #更新用户分数 -by zjc def be_user_score diff --git a/app/models/user.rb b/app/models/user.rb index 7043bd039..2714117e9 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -161,6 +161,7 @@ class User < Principal has_many :user_feedback_messages has_one :onclick_time has_many :system_messages + has_many :at_messages # 虚拟转换 has_many :new_jours, :as => :jour, :class_name => 'JournalsForMessage', :conditions => "status=1" diff --git a/app/views/boards/_course_show.html.erb b/app/views/boards/_course_show.html.erb index 074da9af1..00dfc03e3 100644 --- a/app/views/boards/_course_show.html.erb +++ b/app/views/boards/_course_show.html.erb @@ -1,5 +1,5 @@ <%= content_for(:header_tags) do %> - <%= import_ke(enable_at: false, prettify: false) %> + <%= import_ke(enable_at: true, prettify: false) %> <%= javascript_include_tag "init_activity_KindEditor" %> <% end %> diff --git a/app/views/boards/_project_show.html.erb b/app/views/boards/_project_show.html.erb index 5f6275e9d..839d587b2 100644 --- a/app/views/boards/_project_show.html.erb +++ b/app/views/boards/_project_show.html.erb @@ -20,7 +20,7 @@ <% end %>
      -