From e80149c6c8b477eed3beb61f8f14b5d0bc68ab84 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Sun, 10 Jan 2016 15:38:45 +0800 Subject: [PATCH 01/84] =?UTF-8?q?@7008=E6=89=BE=E4=B8=8D=E5=88=B0=E7=9A=84?= =?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/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/user.rb b/app/models/user.rb index aa048888c..f3367db59 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -409,7 +409,7 @@ class User < Principal def get_at_show_name name = show_name - name = "#{name} #{self.login}" if name != self.login + (name != self.login) ? "#{name} #{self.login}" : name end #added by nie From 09c772820132f69e818865eae08702e6f0ac28d3 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 11 Jan 2016 10:35:25 +0800 Subject: [PATCH 02/84] =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/stylesheets/share.css | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/public/stylesheets/share.css b/public/stylesheets/share.css index ea45a8b41..bb184a2d6 100644 --- a/public/stylesheets/share.css +++ b/public/stylesheets/share.css @@ -18,6 +18,19 @@ a:hover.userCancel{border:1px solid #888888; } .userCard {width:208px; border:1px solid #dddddd; background-color:#ffffff; margin-top:10px; padding:15px; top:-176px; left:-95px; position:absolute; z-index:999; display:none;} .userCard font {display:block; border-width:8px; position:absolute; bottom:-16px; left:110px; border-style:solid dashed dashed dashed; border-color:#FFF transparent transparent transparent; font-size:0; line-height:0;} .userCard em {display:block; border-width:8px; position:absolute; bottom:-17px; left:110px; border-style:solid dashed dashed dashed; border-color:#eaeaea transparent transparent transparent; font-size:0; line-height:0;} +.userCardM {width:201px; height:20px; border:1px solid #dddddd; resize:none;} +.praviteC {background:url(../images/hwork_icon.png) -79px -255px no-repeat;} +.praviteCP {display:inline-block; width:20px; height:20px; position:absolute; top:10px; left:25px;} +.publicC {background:url(../images/hwork_icon.png) -79px -125px no-repeat;} +.publicCP {display:inline-block; width:20px; height:20px; position:absolute; top:10px; left:25px;} +.shild {background:url(../images/hwork_icon.png) -6px -354px no-repeat;} +.shildP {display:inline-block; width:20px; height:20px; position:absolute; top:10px; right:0px;} +ul.shild:hover li ul {display:block;} +.subNavArrow {background:url(../images/hwork_icon.png) -82px -399px no-repeat; display:inline-block; width:20px; height:20px; position:absolute; top:10px; right:0px;} +ul.subNavArrow:hover li ul {display:block;} +.subNavMenu {line-height:2; font-size:12px; color:#616060; background-color:#ffffff; border:1px solid #eaeaea; border-radius:3px; position:absolute; left:20px; top:-10px; padding:5px 0px; display:none; z-index:999;} +.subNavRow {padding:0px 15px; width:70px;} + a.mesIcon {background:url(../images/mes_icon.png) -5px -73px no-repeat; padding-left:23px;} a.personalIcon {background:url(../images/mes_icon.png) -6px -16px no-repeat; padding-left:23px;} .mesType {background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:10px 15px; left:-50px; font-size:12px; color:#888888; display:none; line-height:2; z-index:999; white-space:nowrap;} From 525d1544c2c2a137e907e3e2d4d143d921f5fea1 Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 11 Jan 2016 10:43:48 +0800 Subject: [PATCH 03/84] =?UTF-8?q?=E4=BB=A3=E7=A0=81=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../users/_resource_share_for_project_popup.html.erb | 8 +++----- app/views/users/search_user_project.js.erb | 9 +-------- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/app/views/users/_resource_share_for_project_popup.html.erb b/app/views/users/_resource_share_for_project_popup.html.erb index 2dba25e56..f15c29e90 100644 --- a/app/views/users/_resource_share_for_project_popup.html.erb +++ b/app/views/users/_resource_share_for_project_popup.html.erb @@ -1,10 +1,8 @@ - -
发送到
- @@ -20,13 +18,13 @@ <%= hidden_field_tag(:send_ids, send_ids) %> <%= submit_tag '',:class=>'searchIcon2',:onfocus=>"this.blur();",:style=>'border-style:none' %> <% end %>
- <%= form_tag add_exist_file_to_project_user_path(user),:remote=>true,:id=>'projects_list_form' %> + <%= form_tag add_exist_file_to_project_user_path(user), :remote => true, :id=>'projects_list_form' %>
<%= hidden_field_tag(:send_id, send_id) %> diff --git a/app/views/users/search_user_project.js.erb b/app/views/users/search_user_project.js.erb index 0632ebb98..5218c22ab 100644 --- a/app/views/users/search_user_project.js.erb +++ b/app/views/users/search_user_project.js.erb @@ -1,11 +1,4 @@ - -//var popupHeight = $(".resourceSharePopup").outerHeight(true); -//$(".resourceSharePopup").css("marginTop",-popupHeight/2); -// -//$("#upload_box").css('left','').css('top',''); -//$("#upload_box").html('<%#= escape_javascript( render :partial => "resource_share_for_project_popup" ,:locals => {:projects=>@projects,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>'); -//$("#upload_box").css('display','block'); -$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_for_project_popup' ,:locals => {:projects=>@projects,:user=>@user,:send_id=>@send_id,:send_ids=>@send_ids})%>'); +$("#ajax-modal").html('<%= escape_javascript( render :partial => 'users/resource_share_for_project_popup', :locals => {:projects => @projects, :user => @user, :send_id => @send_id, :send_ids => @send_ids}) %>'); showModal('ajax-modal', '452px'); $('#ajax-modal').siblings().remove(); $('#ajax-modal').before(""); From f3b732460cef51a3f58e37e035862f504a725e2d Mon Sep 17 00:00:00 2001 From: huang Date: Mon, 11 Jan 2016 14:57:52 +0800 Subject: [PATCH 04/84] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/_development_group.html.erb | 2 +- ...60111064927_add_issues_count_to_project.rb | 5 +++ ...065137_add_attachments_count_to_project.rb | 5 +++ ...60111065215_add_boards_count_to_project.rb | 5 +++ ...0160111065530_add_news_count_to_project.rb | 5 +++ db/schema.rb | 33 +++++++++++++++++-- 6 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 db/migrate/20160111064927_add_issues_count_to_project.rb create mode 100644 db/migrate/20160111065137_add_attachments_count_to_project.rb create mode 100644 db/migrate/20160111065215_add_boards_count_to_project.rb create mode 100644 db/migrate/20160111065530_add_news_count_to_project.rb diff --git a/app/views/projects/_development_group.html.erb b/app/views/projects/_development_group.html.erb index 83b65fe90..47a1f2a94 100644 --- a/app/views/projects/_development_group.html.erb +++ b/app/views/projects/_development_group.html.erb @@ -6,7 +6,7 @@
<% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %> @@ -193,7 +203,7 @@ 项目 <% if is_current_user%> - <%=link_to "", new_project_path(:host=> Setting.host_name), :class => "homepageMenuSetting fr", :title => "新建项目"%> + <%=link_to "", new_project_path(:host=> Setting.host_name), :class => "homepageMenuSetting fr", :style => "margin-right:10px;", :title => "新建项目"%> <% end%>
<% projects = @user.projects.visible.select("projects.*,(SELECT MAX(created_at) FROM `forge_activities` WHERE forge_activities.project_id = projects.id) AS a").order("a desc").limit(5)%> diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index de837c66f..b8af1e85e 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -2,6 +2,7 @@
  • 已有栏目
  • 状态
  • 类型
  • +
  • 域名目录
  • @@ -26,6 +27,7 @@
  • 新增
  • <%= field.field_type == "Post" ? "帖子" : "资源" %>
  • + <%#= link_to "隐藏", hide_org_subfield_organizations_path(field), :method => 'post', :remote => true, :id => "hide_#{field.id}", :class => "linkBlue fr mr5" %> <%= field.hide==0?"设为隐藏":"设为可见" %> <%= link_to "删除", org_subfield_path(field), :method => 'delete', :remote => true, :confirm => "您确定删除吗?", :class => "linkBlue fr mr10" %> diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index 2e9058c40..40cc295d9 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -111,20 +111,26 @@ :subfields => @organization.org_subfields.where("field_type != 'default'") } %>
    -
    +

    新增栏目

    <%= form_tag url_for(:controller => 'org_subfields', :action => 'create', :organization_id => @organization.id), :id=> 'add_subfield_form',:remote => true do %> - + +
    +

    域名目录(用户自定义url,可选)

    + micros.trustie.net/ +
    +
    • 栏目类型
    • -
    • +
    • -
    • +
    • +
    确定 diff --git a/db/migrate/20151231012634_add_last_term_to_course.rb b/db/migrate/20151231012634_add_last_term_to_course.rb deleted file mode 100644 index 1b342eaaf..000000000 --- a/db/migrate/20151231012634_add_last_term_to_course.rb +++ /dev/null @@ -1,17 +0,0 @@ -class AddLastTermToCourse < ActiveRecord::Migration - def change - add_column :courses, :end_time, :integer - add_column :courses, :end_term, :string - - count = Course.all.count / 30 + 2 - transaction do - for i in 1 ... count do - Course.page(i).per(30).each do |course| - course.end_time = course.time - course.end_term = course.term - course.save - end - end - end - end -end diff --git a/db/schema.rb b/db/schema.rb index e816d1d6e..b21b5057d 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -982,8 +982,8 @@ ActiveRecord::Schema.define(:version => 20160108093752) do t.text "notes" t.integer "status" t.integer "reply_id" - t.datetime "created_on", :null => false - t.datetime "updated_on", :null => false + t.datetime "created_on", :null => false + t.datetime "updated_on", :null => false t.string "m_parent_id" t.boolean "is_readed" t.integer "m_reply_count" diff --git a/public/stylesheets/new_user.css b/public/stylesheets/new_user.css index 7456c904b..830ed797e 100644 --- a/public/stylesheets/new_user.css +++ b/public/stylesheets/new_user.css @@ -581,7 +581,7 @@ a.homepageImageNumber:hover {color:#269ac9;} .homepageLeftMenuCourses {font-size:13px; border-bottom:1px solid #dddddd;} .homepageLeftMenuCoursesLine {height:38px; line-height:38px; vertical-align:middle;} .homepageLeftMenuCoursesLine:hover {background-color:#269ac9;} -a.coursesLineGrey {padding-left:25px; color:#808080; display:block;} +a.coursesLineGrey {padding-left:25px; padding-right:25px; color:#808080; display:block;} a.coursesLineGrey:hover {color:#ffffff;} .homepageLeftMenuMore {height:18px;} .homepageLeftMenuMore:hover {background-color:#269ac9;} diff --git a/public/stylesheets/org.css b/public/stylesheets/org.css index 2279f0fe5..02e6ce340 100644 --- a/public/stylesheets/org.css +++ b/public/stylesheets/org.css @@ -18,11 +18,11 @@ .orgUrlInput {width:200px; outline:none; border:1px solid #eaeaea; height:22px;} a.saveBtn {padding:3px 5px; background-color:#269ac9; color:#ffffff;} a.saveBtn:hover {background-color:#297fb8;} -.orgMemberList {width:410px; float:left;} +.orgMemberList {width:460px; float:left;} .orgListRow {border-bottom:1px solid #e4e4e4; padding-bottom:5px;} -.orgListUser {width:119px; float:left;} +.orgListUser {width:85px; float:left;} .orgListRole {width:180px; float:left;} -.orgMemContainer {width:278px;} +.orgMemContainer {width:228px;} .orgMemberAdd {float:right; width:240px;} .orgAddSearch {border:1px solid #dddddd; outline:none; width:180px; height:22px; color:#9b9b9b;} .undis {display:none;} @@ -73,6 +73,7 @@ a.linkGrey8:hover {color:#585858;} .org_login_list a {color:#269ac9;} .orgListStatus {width:55px; float:left;} +.personalUrl {border:1px solid #dddddd; width:75px; outline:none; white-space:nowrap; padding-left:2px;} .reCon{ margin:5px; width:710px;} .retop{width:710px; height:40px; background:#eaeaea; padding:5px;} .resources {width:718px; background-color:#ffffff; padding:15px; border:1px solid #dddddd;float: right} diff --git a/public/stylesheets/public.css b/public/stylesheets/public.css index dcb1a34f2..8047504e1 100644 --- a/public/stylesheets/public.css +++ b/public/stylesheets/public.css @@ -511,7 +511,7 @@ a.homepageImageNumber:hover {color:#15bccf;} .homepageLeftMenuCourses {font-size:14px; border-bottom:1px solid #dddddd;} .homepageLeftMenuCoursesLine {height:38px; line-height:38px; vertical-align:middle;} .homepageLeftMenuCoursesLine:hover {background-color:#b3e0ee;} -a.coursesLineGrey {padding-left:25px; color:#15bccf; display:block;} +a.coursesLineGrey {padding-left:25px; padding-right:25px; color:#808080; display:block;} a.coursesLineGrey:hover {color:#ffffff;} .homepageLeftMenuMore {height:18px;} .homepageLeftMenuMore:hover {background-color:#b3e0ee;} diff --git a/public/stylesheets/share.css b/public/stylesheets/share.css index 59b3b63f9..b36d80082 100644 --- a/public/stylesheets/share.css +++ b/public/stylesheets/share.css @@ -18,6 +18,19 @@ a:hover.userCancel{border:1px solid #888888; } .userCard {width:208px; border:1px solid #dddddd; background-color:#ffffff; margin-top:10px; padding:15px; top:-176px; left:-95px; position:absolute; z-index:999; display:none;} .userCard font {display:block; border-width:8px; position:absolute; bottom:-16px; left:110px; border-style:solid dashed dashed dashed; border-color:#FFF transparent transparent transparent; font-size:0; line-height:0;} .userCard em {display:block; border-width:8px; position:absolute; bottom:-17px; left:110px; border-style:solid dashed dashed dashed; border-color:#eaeaea transparent transparent transparent; font-size:0; line-height:0;} +.userCardM {width:201px; height:20px; border:1px solid #dddddd; resize:none;} +.praviteC {background:url(../images/hwork_icon.png) -79px -255px no-repeat;} +.praviteCP {display:inline-block; width:20px; height:20px; position:absolute; top:10px; left:25px;} +.publicC {background:url(../images/hwork_icon.png) -79px -125px no-repeat;} +.publicCP {display:inline-block; width:20px; height:20px; position:absolute; top:10px; left:25px;} +.shild {background:url(../images/hwork_icon.png) -6px -354px no-repeat;} +.shildP {display:inline-block; width:20px; height:20px; position:absolute; top:10px; right:0px;} +ul.shild:hover li ul {display:block;} +.subNavArrow {background:url(../images/hwork_icon.png) -82px -399px no-repeat; display:inline-block; width:20px; height:20px; position:absolute; top:10px; right:0px;} +ul.subNavArrow:hover li ul {display:block;} +.subNavMenu {line-height:2; font-size:12px; color:#616060; background-color:#ffffff; border:1px solid #eaeaea; border-radius:3px; position:absolute; left:20px; top:-10px; padding:5px 0px; display:none; z-index:999;} +.subNavRow {padding:0px 15px; width:70px;} + a.mesIcon {background:url(../images/mes_icon.png) -5px -73px no-repeat; padding-left:23px;} a.personalIcon {background:url(../images/mes_icon.png) -6px -16px no-repeat; padding-left:23px;} .mesType {background-color:#ffffff; float:left; list-style:none; position:absolute; border:1px solid #eaeaea; border-radius:5px; top:15px; padding:10px 15px; left:-50px; font-size:12px; color:#888888; display:none; line-height:2; z-index:999; white-space:nowrap;} From 2f5ada2d7b696b401afa765c0c4ec5e8a3ba9135 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 11 Jan 2016 16:56:57 +0800 Subject: [PATCH 06/84] =?UTF-8?q?=E5=8D=9A=E5=AE=A2=E8=AE=BE=E4=B8=BA?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=90=8E=EF=BC=8C=E6=98=BE=E7=A4=BA=E5=9C=A8?= =?UTF-8?q?=E4=B8=AA=E4=BA=BA=E4=B8=BB=E9=A1=B5=E5=A4=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/blogs/_article.html.erb | 21 +++++++++++++++------ app/views/blogs/_article_list.html.erb | 5 ----- app/views/blogs/_homepage.html.erb | 2 +- app/views/users/show.html.erb | 6 ++++++ 4 files changed, 22 insertions(+), 12 deletions(-) diff --git a/app/views/blogs/_article.html.erb b/app/views/blogs/_article.html.erb index 0b813c4a7..cc0825652 100644 --- a/app/views/blogs/_article.html.erb +++ b/app/views/blogs/_article.html.erb @@ -26,12 +26,21 @@ ) if User.current && User.current.id == activity.author.id %>
  • - <%= link_to( - l(:button_set_homepage), - {:controller => 'blogs',:action => 'set_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id}, - :method => :post, - :class => 'postOptionLink' - ) if User.current && User.current.id == activity.blog.author_id %> + <% if activity.id == activity.blog.homepage_id %> + <%= link_to( + l(:button_cancel_homepage), + {:controller => 'blogs',:action => 'cancel_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id}, + :method => :post, + :class => 'postOptionLink' + ) if User.current && User.current.id == activity.blog.author_id %> + <% else %> + <%= link_to( + l(:button_set_homepage), + {:controller => 'blogs',:action => 'set_homepage',:user_id=>activity.author_id,:id=>activity.blog_id, :article_id => activity.id}, + :method => :post, + :class => 'postOptionLink' + ) if User.current && User.current.id == activity.blog.author_id %> + <% end %>
  • diff --git a/app/views/blogs/_article_list.html.erb b/app/views/blogs/_article_list.html.erb index 182db9dd0..ca85c0ba2 100644 --- a/app/views/blogs/_article_list.html.erb +++ b/app/views/blogs/_article_list.html.erb @@ -43,11 +43,6 @@
    - <% if blog.homepage_id and BlogComment.where("id=?", blog.homepage_id).count > 0 %> - <% homepage = BlogComment.find(blog.homepage_id) %> - <%= render :partial => 'blogs/homepage', :locals => {:activity => homepage, :user_activity_id => homepage.id} %> - <% end %> - <% if User.current.logged? && User.current.id == @user.id %> <%= labelled_form_for @article, :url =>{:controller=>'blog_comments',:action => 'create',:user_id=>user.id , :blog_id => blog.id}, :html => {:nhname=>'form',:multipart => true, :id => 'message-form'} do |f| %> diff --git a/app/views/blogs/_homepage.html.erb b/app/views/blogs/_homepage.html.erb index 30e1b69a5..99835c87d 100644 --- a/app/views/blogs/_homepage.html.erb +++ b/app/views/blogs/_homepage.html.erb @@ -36,7 +36,7 @@
    <%end%>
    - + +<% if @user.blog.homepage_id and BlogComment.where("id=?", @user.blog.homepage_id).count > 0 %> + <% homepage = BlogComment.find(@user.blog.homepage_id) %> + <%= render :partial => 'blogs/homepage', :locals => {:activity => homepage, :user_activity_id => homepage.id} %> +<% end %> + <%= render :partial => 'users/user_activities', :locals => {:user_activities => @user_activities,:page => 0,:type => @type} %> From 48f931debab51d0c2e2cb8d9a8b53998b7e46c6c Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 11 Jan 2016 17:02:01 +0800 Subject: [PATCH 07/84] =?UTF-8?q?=E9=9A=90=E8=97=8F=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E7=9A=84=E8=AF=BE=E7=A8=8B/=E9=A1=B9=E7=9B=AE=E5=BF=AB?= =?UTF-8?q?=E6=8D=B7=E8=8F=9C=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/layouts/_org_courses.html.erb | 38 ++++++++++++------------ app/views/layouts/_org_projects.html.erb | 36 +++++++++++----------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/app/views/layouts/_org_courses.html.erb b/app/views/layouts/_org_courses.html.erb index b2bd8e428..4085cce22 100644 --- a/app/views/layouts/_org_courses.html.erb +++ b/app/views/layouts/_org_courses.html.erb @@ -2,25 +2,25 @@ <%# pro = Project.find course.course_id %>
  • <%= link_to course.name, course_path(course.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => course.name%> -
    -
      - -
    -
    + + + + + + + + + + + + + + + + + + +
  • <% end %> <% if courses.size == 5%> diff --git a/app/views/layouts/_org_projects.html.erb b/app/views/layouts/_org_projects.html.erb index 00c5db642..7df93e40b 100644 --- a/app/views/layouts/_org_projects.html.erb +++ b/app/views/layouts/_org_projects.html.erb @@ -2,24 +2,24 @@ <%# pro = Project.find project.project_id %>
  • <%= link_to project.name, project_path(project.id,:host=>Setting.host_name), :class => "coursesLineGrey hidden", :title => project.name%> -
    -
      - -
    -
    + + + + + + + + + + + + + + + + + +
  • <% end %> <% if projects.size == 5%> From 1239a8b5af025d4fb153026ca04b13b25bdeef7a Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 12 Jan 2016 10:38:50 +0800 Subject: [PATCH 08/84] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/project.rb | 32 +++++++++---------- .../20160111071348_static_project_boards.rb | 19 +++++++++++ .../20160111071411_static_project_issues.rb | 12 +++++++ .../20160111071529_static_project_news.rb | 12 +++++++ ...160111071558_static_project_attachments.rb | 12 +++++++ ...0160111080833_add_acts_count_to_project.rb | 5 +++ .../20160111080914_static_project_acts.rb | 12 +++++++ 7 files changed, 88 insertions(+), 16 deletions(-) create mode 100644 db/migrate/20160111071348_static_project_boards.rb create mode 100644 db/migrate/20160111071411_static_project_issues.rb create mode 100644 db/migrate/20160111071529_static_project_news.rb create mode 100644 db/migrate/20160111071558_static_project_attachments.rb create mode 100644 db/migrate/20160111080833_add_acts_count_to_project.rb create mode 100644 db/migrate/20160111080914_static_project_acts.rb diff --git a/app/models/project.rb b/app/models/project.rb index cd4036810..f17124478 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -155,7 +155,7 @@ class Project < ActiveRecord::Base # 创建project之后默认创建一个board,之后的board去掉了board的概念 after_create :create_board_sync,:acts_as_forge_activities,:create_project_ealasticsearch_index before_destroy :delete_all_members,:delete_project_ealasticsearch_index - after_update :update_project_ealasticsearch_index + # after_update :update_project_ealasticsearch_index def remove_references_before_destroy return if self.id.nil? Watcher.delete_all ['watchable_id = ?', id] @@ -1223,21 +1223,21 @@ class Project < ActiveRecord::Base self.__elasticsearch__.index_document end end - def update_project_ealasticsearch_index - if self.is_public #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性 - begin - self.__elasticsearch__.update_document - rescue => e - self.__elasticsearch__.index_document - end - else #如果是更新成为私有的,那么索引就要被删除 - begin - self.__elasticsearch__.delete_document - rescue => e - - end - end - end + # def update_project_ealasticsearch_index + # if self.is_public #如果是初次更新成为公开的情况,会报错,那么这条记录尚未被索引过。没有报错就是更新的其他属性 + # begin + # self.__elasticsearch__.update_document + # rescue => e + # self.__elasticsearch__.index_document + # end + # else #如果是更新成为私有的,那么索引就要被删除 + # begin + # self.__elasticsearch__.delete_document + # rescue => e + # + # end + # end + # end def delete_project_ealasticsearch_index begin self.__elasticsearch__.delete_document diff --git a/db/migrate/20160111071348_static_project_boards.rb b/db/migrate/20160111071348_static_project_boards.rb new file mode 100644 index 000000000..1d85860c6 --- /dev/null +++ b/db/migrate/20160111071348_static_project_boards.rb @@ -0,0 +1,19 @@ +class StaticProjectBoards < ActiveRecord::Migration + def up + begin + Project.all.each do |project| + puts project.id + unless project.boards.first.nil? + boards_count = project.boards.first.topics.count + project.update_attribute(:boards_count, boards_count) + end + end + ensure + self.down + end + end + + def down + Project.update_all(:boards_count => false) + end +end diff --git a/db/migrate/20160111071411_static_project_issues.rb b/db/migrate/20160111071411_static_project_issues.rb new file mode 100644 index 000000000..273527164 --- /dev/null +++ b/db/migrate/20160111071411_static_project_issues.rb @@ -0,0 +1,12 @@ +class StaticProjectIssues < ActiveRecord::Migration + def up + Project.all.each do |project| + issues_count = project.issues.count + project.update_attribute(:issues_count, boards_count) + end + end + + def down + Project.all.update_all(:issues_count => false) + end +end diff --git a/db/migrate/20160111071529_static_project_news.rb b/db/migrate/20160111071529_static_project_news.rb new file mode 100644 index 000000000..6ccefbc32 --- /dev/null +++ b/db/migrate/20160111071529_static_project_news.rb @@ -0,0 +1,12 @@ +class StaticProjectNews < ActiveRecord::Migration + def up + Project.all.each do |project| + news_count = project.news.count + project.update_attribute(:news_count, news_count) + end + end + + def down + Project.all.update_all(:news_count => false) + end +end diff --git a/db/migrate/20160111071558_static_project_attachments.rb b/db/migrate/20160111071558_static_project_attachments.rb new file mode 100644 index 000000000..af4a282ed --- /dev/null +++ b/db/migrate/20160111071558_static_project_attachments.rb @@ -0,0 +1,12 @@ +class StaticProjectAttachments < ActiveRecord::Migration + def up + Project.all.each do |project| + attachments_count = project.attachments.count + project.update_attribute(:attachments_count, attachments_count) + end + end + + def down + Project.all.update_all(:attachments_count => false) + end +end diff --git a/db/migrate/20160111080833_add_acts_count_to_project.rb b/db/migrate/20160111080833_add_acts_count_to_project.rb new file mode 100644 index 000000000..a990302bc --- /dev/null +++ b/db/migrate/20160111080833_add_acts_count_to_project.rb @@ -0,0 +1,5 @@ +class AddActsCountToProject < ActiveRecord::Migration + def change + add_column :projects, :acts_count, :integer, :default => false + end +end diff --git a/db/migrate/20160111080914_static_project_acts.rb b/db/migrate/20160111080914_static_project_acts.rb new file mode 100644 index 000000000..6f0d4a2e6 --- /dev/null +++ b/db/migrate/20160111080914_static_project_acts.rb @@ -0,0 +1,12 @@ +class StaticProjectActs < ActiveRecord::Migration + def up + Project.all.each do |project| + acts_count = ForgeActivity.where("project_id = ?", project.id).count + project.update_attribute(:acts_count, acts_count) + end + end + + def down + Project.all.update_all(:acts_count => false) + end +end From 500527a12d4386033ab140fcad19de6be0c1912b Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 12 Jan 2016 10:42:25 +0800 Subject: [PATCH 09/84] =?UTF-8?q?gitlab=E5=90=8C=E6=AD=A5=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/trustie/gitlab/manage_member.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/trustie/gitlab/manage_member.rb b/lib/trustie/gitlab/manage_member.rb index 433b101f5..5c75d9d6e 100644 --- a/lib/trustie/gitlab/manage_member.rb +++ b/lib/trustie/gitlab/manage_member.rb @@ -5,6 +5,8 @@ module Trustie module Gitlab module ManageMember + attr :g + include Helper def self.included(base) base.class_eval { before_create :add_gitlab_member From 83881766b2546217a26213c85f3b1d289e28b78b Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 12 Jan 2016 11:01:58 +0800 Subject: [PATCH 10/84] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=80=BB=E6=95=B0?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=8E=B7=E5=8F=96=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 | 2 +- app/helpers/application_helper.rb | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/app/controllers/repositories_controller.rb b/app/controllers/repositories_controller.rb index 1674055ac..0f3724d6f 100644 --- a/app/controllers/repositories_controller.rb +++ b/app/controllers/repositories_controller.rb @@ -357,7 +357,7 @@ update @changesets = g.commits(@project.gpid, :ref_name => @rev) # @changesets = @repository.latest_changesets(@path, @rev) # @changesets_count = @repository.latest_changesets(@path, @rev).count - @changesets_all_count = @project.gpid.nil? ? 0 : g.commits_total_count(@project.gpid).count + @changesets_all_count = @project.gpid.nil? ? 0 : g.project(@project.gpid).commit_count @changesets_latest_coimmit = @changesets[0] @properties = @repository.properties(@path, @rev) @repositories = @project.repositories diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 9b7888bf2..4fcb43172 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -2784,8 +2784,7 @@ int main(int argc, char** argv){ #代码提交数量 def changesets_num project g = Gitlab.client - project.gpid.nil? ? 0 : g.commits_total_count(project.gpid).count - # # commits_total_count(project.gpid) + project.gpid.nil? ? 0 : g.project(project.gpid).commit_count # project.changesets.count end end From 8758235364534050144a5866acd3db1051d58308 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 12 Jan 2016 15:10:02 +0800 Subject: [PATCH 11/84] =?UTF-8?q?issue=E5=88=9B=E5=BB=BA=E5=92=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E7=9A=84=E6=97=B6=E5=80=99=EF=BC=8Cissues=5Fcount+1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/issue.rb | 16 ++++++++++++++-- .../20160111071348_static_project_boards.rb | 5 ----- .../20160111071411_static_project_issues.rb | 3 +-- db/migrate/20160111071529_static_project_news.rb | 7 ++++--- .../20160111071558_static_project_attachments.rb | 7 ++++--- db/migrate/20160111080914_static_project_acts.rb | 10 +++++++--- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/app/models/issue.rb b/app/models/issue.rb index 5ecb3e36f..4d2776ff7 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -83,9 +83,9 @@ 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, :act_as_at_message + after_create :act_as_activity,:be_user_score_new_issue,:act_as_forge_activity, :act_as_forge_message, :act_as_at_message, :add_issues_count after_update :be_user_score - after_destroy :down_user_score + after_destroy :down_user_score, :decrease_issues_count # after_create :be_user_score # end @@ -165,6 +165,18 @@ class Issue < ActiveRecord::Base end end + # 创建issue的时候,issues_count加1 + def add_issues_count + issue_count = self.project.issues_count + 1 + self.project.update_attribute(:issues_count, issue_count) + end + + # 删除issue的时候,issues_count减1 + def decrease_issues_count + issue_count = self.project.issues_count - 1 + self.project.update_attribute(:issues_count, issue_count) + end + # 更新缺陷 #def act_as_forge_message_update # unless self.author_id == self.assigned_to_id diff --git a/db/migrate/20160111071348_static_project_boards.rb b/db/migrate/20160111071348_static_project_boards.rb index 1d85860c6..4b82be23c 100644 --- a/db/migrate/20160111071348_static_project_boards.rb +++ b/db/migrate/20160111071348_static_project_boards.rb @@ -1,6 +1,5 @@ class StaticProjectBoards < ActiveRecord::Migration def up - begin Project.all.each do |project| puts project.id unless project.boards.first.nil? @@ -8,12 +7,8 @@ class StaticProjectBoards < ActiveRecord::Migration project.update_attribute(:boards_count, boards_count) end end - ensure - self.down - end end def down - Project.update_all(:boards_count => false) end end diff --git a/db/migrate/20160111071411_static_project_issues.rb b/db/migrate/20160111071411_static_project_issues.rb index 273527164..d9a3a24ff 100644 --- a/db/migrate/20160111071411_static_project_issues.rb +++ b/db/migrate/20160111071411_static_project_issues.rb @@ -2,11 +2,10 @@ class StaticProjectIssues < ActiveRecord::Migration def up Project.all.each do |project| issues_count = project.issues.count - project.update_attribute(:issues_count, boards_count) + project.update_attribute(:issues_count, issues_count) end end def down - Project.all.update_all(:issues_count => false) end end diff --git a/db/migrate/20160111071529_static_project_news.rb b/db/migrate/20160111071529_static_project_news.rb index 6ccefbc32..f013a929d 100644 --- a/db/migrate/20160111071529_static_project_news.rb +++ b/db/migrate/20160111071529_static_project_news.rb @@ -1,12 +1,13 @@ class StaticProjectNews < ActiveRecord::Migration def up Project.all.each do |project| - news_count = project.news.count - project.update_attribute(:news_count, news_count) + unless project.news.nil? + news_count = project.news.count + project.update_attribute(:news_count, news_count) + end end end def down - Project.all.update_all(:news_count => false) end end diff --git a/db/migrate/20160111071558_static_project_attachments.rb b/db/migrate/20160111071558_static_project_attachments.rb index af4a282ed..692ca68eb 100644 --- a/db/migrate/20160111071558_static_project_attachments.rb +++ b/db/migrate/20160111071558_static_project_attachments.rb @@ -1,12 +1,13 @@ class StaticProjectAttachments < ActiveRecord::Migration def up Project.all.each do |project| - attachments_count = project.attachments.count - project.update_attribute(:attachments_count, attachments_count) + unless project.attachments.nil? + attachments_count = project.attachments.count + project.update_attribute(:attachments_count, attachments_count) + end end end def down - Project.all.update_all(:attachments_count => false) end end diff --git a/db/migrate/20160111080914_static_project_acts.rb b/db/migrate/20160111080914_static_project_acts.rb index 6f0d4a2e6..c368507a3 100644 --- a/db/migrate/20160111080914_static_project_acts.rb +++ b/db/migrate/20160111080914_static_project_acts.rb @@ -1,12 +1,16 @@ class StaticProjectActs < ActiveRecord::Migration def up Project.all.each do |project| - acts_count = ForgeActivity.where("project_id = ?", project.id).count - project.update_attribute(:acts_count, acts_count) + acts = ForgeActivity.where("project_id = ?", project.id) + unless acts.blank? + acts_count = acts.count + puts project.id + puts "acts_count is #{acts_count}" + project.update_attribute(:acts_count, acts_count) + end end end def down - Project.all.update_all(:acts_count => false) end end From a74e5f9d308b6ff1a82d2e7cefbe218dd9146523 Mon Sep 17 00:00:00 2001 From: huang Date: Tue, 12 Jan 2016 15:18:40 +0800 Subject: [PATCH 12/84] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=95=B0=E8=BF=81=E7=A7=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- db/migrate/20160111080914_static_project_acts.rb | 6 +++--- db/schema.rb | 3 ++- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/db/migrate/20160111080914_static_project_acts.rb b/db/migrate/20160111080914_static_project_acts.rb index c368507a3..3f07cbb03 100644 --- a/db/migrate/20160111080914_static_project_acts.rb +++ b/db/migrate/20160111080914_static_project_acts.rb @@ -3,10 +3,10 @@ class StaticProjectActs < ActiveRecord::Migration Project.all.each do |project| acts = ForgeActivity.where("project_id = ?", project.id) unless acts.blank? - acts_count = acts.count + count = acts.count puts project.id - puts "acts_count is #{acts_count}" - project.update_attribute(:acts_count, acts_count) + puts "acts_count is #{count}" + project.update_attribute(:acts_count, count) end end end diff --git a/db/schema.rb b/db/schema.rb index c8d649ccd..6197c2c76 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 => 20160111065530) do +ActiveRecord::Schema.define(:version => 20160111080914) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1415,6 +1415,7 @@ ActiveRecord::Schema.define(:version => 20160111065530) do t.integer "attachments_count", :default => 0 t.integer "boards_count", :default => 0 t.integer "news_count", :default => 0 + t.integer "acts_count", :default => 0 end add_index "projects", ["lft"], :name => "index_projects_on_lft" From d5fc0277a266482126ef39d5ebc82f88f6d7b6cb Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 12 Jan 2016 16:43:40 +0800 Subject: [PATCH 13/84] =?UTF-8?q?3.2=E7=BB=84=E7=BB=87=E8=B5=84=E6=BA=90?= =?UTF-8?q?=E7=9A=84=E6=A0=B7=E5=BC=8F=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 1 + app/controllers/org_subfields_controller.rb | 23 ++-- app/views/files/_org_subfield_list.html.erb | 126 ++++++++++-------- app/views/files/_subfield_files.html.erb | 123 +++++++++++------ app/views/files/index.js.erb | 2 + .../files/search_files_in_subfield.js.erb | 9 +- .../_org_left_subfield_list.html.erb | 2 +- config/routes.rb | 1 + public/javascripts/org.js | 24 ++++ public/stylesheets/org.css | 8 +- public/stylesheets/share.css | 10 +- 11 files changed, 218 insertions(+), 111 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index c6773ef57..4bbb8a444 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -380,6 +380,7 @@ class FilesController < ApplicationController @organization = Organization.find(@containers.first.organization_id) show_attachments @containers @tag_list = attachment_tag_list @all_attachments + @page = params[:page] || 1 render :layout => 'base_org' # @subfield = params[:org_subfield_id] end diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index 66a236b5b..5db82436b 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -7,15 +7,22 @@ class OrgSubfieldsController < ApplicationController end def show - @org_subfield = OrgSubfield.find(params[:id]) - @organization = @org_subfield.organization.id - @messages = [] - @messages << @org_subfield.org_document_comments - @messages << @org_subfield.messages - @messages.sort{|a, b| b.updated_at <=> a.updated_at} - respond_to do |format| - format.html{render :layout => 'base_org'} + @organization = Organization.find(params[:id]) + @subfield = @organization.org_subfields.first + if @subfield.field_type == 'Post' + redirect_to organization_path(@organization, :org_subfield_id => @subfield.id) + else + end + # @org_subfield = OrgSubfield.find(params[:id]) + # @organization = @org_subfield.organization.id + # @messages = [] + # @messages << @org_subfield.org_document_comments + # @messages << @org_subfield.messages + # @messages.sort{|a, b| b.updated_at <=> a.updated_at} + # respond_to do |format| + # format.html{render :layout => 'base_org'} + # end end def destroy @subfield = OrgSubfield.find(params[:id]) diff --git a/app/views/files/_org_subfield_list.html.erb b/app/views/files/_org_subfield_list.html.erb index ad90550d4..504558b15 100644 --- a/app/views/files/_org_subfield_list.html.erb +++ b/app/views/files/_org_subfield_list.html.erb @@ -1,59 +1,77 @@ <% delete_allowed = User.current.admin? %> -
    -

    共有 <%= all_attachments.count%> 个资源

    -

    - <% if order == "asc" %> - 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /  - <%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"downloads"} %> /  - <%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序 - <% else %> - 按 <%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"created_on"} %> /  - <%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"downloads"} %>  /  - <%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: sort,order:order,current:"quotes"} %> 排序 - <% end %> -

    -
    -
    -
    - <%= render :partial => "files/subfield_tags", :locals => {:tag_list => @tag_list,:org_subfield => @org_subfield,:tag_name => @tag_name}%> -
    -
    -
    - <% org_subfield_attachments.each do |file| %> - <% if 1 %> -
    -
    - <%= link_to truncate(file.filename,length: 35, omission: '...'), - download_named_attachment_path(file.id, file.filename), - :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> +<% org_subfield_attachments.each do |file| %> +
    +
    +
    + <%= link_to image_tag(url_to_avatar(file.author), :width => 50, :height => 50), user_path(file.author) %> +
    +
    +
    + <%= link_to truncate(file.filename,length: 35, omission: '...'), + download_named_attachment_path(file.id, file.filename), + :title => file.filename+"\n"+file.description.to_s, :style => "overflow: hidden; white-space: nowrap;text-overflow: ellipsis;",:class => "c_dblue f_14 f_b f_l" %> + <%= file_preview_eye(file, class: 'preview') %> + + <% if file.is_public? == false%> + 私有 + <%end %> + +
    +
    + 上传时间:<%= format_date(file.created_on)%> + <% if file.tag_list.length > 0%> + 上传类型:<%= file.tag_list[0] %> + <% end %> +

    文件大小:<%= number_to_human_size(file.filesize) %>

    +

    下载<%= file.downloads%>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

    +
    +
    +
    + <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6"} %> + <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6"} %> +
    +
    +
      +
    • <% if User.current.logged? %> - <% if !@org_subfield.attachments.all.include?file %> - <%= link_to("选入栏目",quote_resource_show_org_subfield_org_subfield_file_path(:org_subfield_id => @org_subfield.id, :id => file.id),:class => "f_l re_select c_lorange",:remote => true) %> - <% elsif @org_subfield.organization.org_subfields.where("field_type='Resource'").count > 1 %> - <%= link_to("选入组织其他栏目",quote_resource_show_org_subfield_org_subfield_file_path(:org_subfield_id => @org_subfield.id, :id => file.id),:class => "f_l re_select c_lorange",:remote => true) %> + <% if (delete_allowed || User.current.id == file.author_id) && file.container_id == org_subfield.id && file.container_type == "OrgSubfield" %> +
        +
      • <%= link_to("发       送".html_safe, 'javascript:void(0)',:class => "postOptionLink",:onclick=>"show_send('#{file.id}')") %>
      • +
      • <%= link_to '更新版本',attachments_versions_path(file),:class => "postOptionLink",:remote=>true %>
      • +
      • + + <%= link_to (file.is_public? ? "设为私有":"设为公开"), update_file_dense_attachments_path(:attachmentid=>file.id,:newtype=>(file.is_public? ? 0:1)),:remote=>true,:class=>"postOptionLink",:method => :post %> + +
      • +
      • + <%= link_to( '删除资源', attachment_path(file), + :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == org_subfield.id && file.container_type == "OrgSubfield" && file.destroyable %> +
      • +
      + <%else%> +
        +
      • <%= link_to("发  送".html_safe, 'javascript:void(0)',:class => "postOptionLink2",:onclick=>"show_send('#{file.id}')") %>
      • +
      <% end %> - <%= file_preview_tag(file, class: 'f_l re_open', style:'text-align: center;') %> <% end %> -
    -
    -
    -

    文件大小:<%= number_to_human_size(file.filesize) %>

    - <%= link_to( l(:button_delete), attachment_path(file), - :data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "f_r re_de") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @org_subfield.id && file.container_type == "OrgSubfield"%> -

    <%= time_tag(file.created_on).html_safe %><%= l(:label_bids_published_ago) %>  |  下载<%= file.downloads %>  |  引用<%= file.quotes.nil? ? 0:file.quotes %>

    -
    -
    -
    - <%= render :partial => 'tags/tag_new', :locals => {:obj => file, :object_flag => "6"} %> - <%= render :partial => 'tags/tag_add', :locals => {:obj => file, :object_flag => "6"} %> -
    -
    -
    - <% end %> - <% end %> -
    -
      - <%= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => @is_remote, :flag => true%> -
    -
    + + + +
    +
    +
    +
    + +
    +<% end %> + +<% if org_subfield_attachments.count == 10 %> + <% if params[:action] == 'search_files_in_subfield' %> + <%=link_to "点击展开更多", search_files_in_subfield_org_subfield_files_path({:org_subfield_id => org_subfield.id,:page => @obj_pages.nil? ? @feedback_pages.page + 1 : @obj_pages.page + 1}.merge(params)),:id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %> + <% else %> + + <%=link_to "点击展开更多", org_subfield_files_path(:org_subfield_id => org_subfield.id, :page => @page + 1), :id => "show_more_attachments",:remote => "true",:class => "loadMore mt10 f_grey" %> + <%end%> +<% end%> + diff --git a/app/views/files/_subfield_files.html.erb b/app/views/files/_subfield_files.html.erb index 09f74d3cd..15d7f4cff 100644 --- a/app/views/files/_subfield_files.html.erb +++ b/app/views/files/_subfield_files.html.erb @@ -1,4 +1,4 @@ -<%= stylesheet_link_tag 'courses' %> +<%= stylesheet_link_tag 'courses'%> -
    -
    -
    - <%= form_tag( search_files_in_subfield_org_subfield_files_path(@org_subfield), method: 'get',:class => "re_search f_l",:remote=>true) do %> - <%= text_field_tag 'name', params[:name], name: "name", :class => 're_schbox',:style=>"padding: 0px"%> - <%= submit_tag "栏目内搜索", :class => "re_schbtn b_lblue",:style => 'width:72px;',:name => "inorg_subfield",:id => "inorg_subfield", :onmouseover => "presscss('inorg_subfield')",:onmouseout =>"buttoncss()" %> - <%= submit_tag "全站搜索", :class => "re_schbtn b_lblue",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> +
    +
    +
    <%= org_subfield.name %>
    + +
    +
    +
    + <%= form_tag( search_files_in_subfield_org_subfield_files_path(@org_subfield), method: 'get',:class => "re_search",:remote=>true) do %> + <%= text_field_tag 'name', params[:name], name: "name", :class => 'researchBox fl',:style=>"padding: 0px"%> + <%= submit_tag "栏目内搜索", :class => "blueBtn mr5 fl",:style => 'width:72px;',:name => "inorg_subfield",:id => "inorg_subfield", :onmouseover => "presscss('inorg_subfield')",:onmouseout =>"buttoncss()" %> + <%= submit_tag "全站搜索", :class => "blueBtn mr5 fl",:name => "insite",:id => "insite",:onmouseover => "presscss('insite')",:onmouseout =>"buttoncss()" %> + + <%#= link_to "上传资源",subfield_upload_file_org_subfield_files_path(@org_subfield.id, :in_org => 1),:method => "post",:class=>"blueBtn fr mr5",:remote => true %> <% end %> - <%# if is_org_subfield_teacher(User.current,@org_subfield) || (@org_subfield.publish_resource==1 && User.current.member_of_org_subfield?(@org_subfield) ) %> - -

    - 上传: - - 软件 |  - 媒体 |  - 代码 |  - - 其他 -

    - <%# end %>
    -
    - <%= render :partial => 'org_subfield_list',:locals => {org_subfield: @org_subfield,all_attachments: @all_attachments,sort:@sort,order:@order,org_subfield_attachments:@obj_attachments} %> -
    - +
    +
    +
    + <%= render :partial => "files/subfield_tags", :locals => {:tag_list => @tag_list,:org_subfield => @org_subfield,:tag_name => @tag_name}%> +
    +
    +

    共有 <%= @all_attachments.count %> 个资源

    +

    + <% if @order == "asc" %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /  + <%= link_to "下载次数",params.merge(:sort=>"downloads:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %> /  + <%= link_to "引用次数",params.merge(:sort=>"quotes:desc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序 + <% else %> + 按 <%= link_to "时间",params.merge(:sort=>"created_on:asc"),:class => "f_b c_grey" ,:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"created_on"} %> /  + <%= link_to "下载次数",params.merge(:sort=>"downloads:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"downloads"} %>  /  + <%= link_to "引用次数",params.merge(:sort=>"quotes:asc"),:class => "f_b c_grey",:remote => @is_remote %><%= render partial: 'files/arrow_show',locals: { sort: @sort,order:@order,current:"quotes"} %> 排序 + <% end %> +

    +
    +
    +
    +
    + <%= render :partial => 'org_subfield_list',:locals => {org_subfield: @org_subfield,all_attachments: @all_attachments,sort:@sort,order:@order,org_subfield_attachments:@obj_attachments} %> +
    +
    -<% html_title(l(:label_attachment_plural)) -%> \ No newline at end of file +<% html_title(l(:label_attachment_plural)) -%> + \ No newline at end of file diff --git a/app/views/files/index.js.erb b/app/views/files/index.js.erb index fe24c9be0..49e7ac714 100644 --- a/app/views/files/index.js.erb +++ b/app/views/files/index.js.erb @@ -2,4 +2,6 @@ $("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/course_list',:locals => {course:@course,all_attachments: @all_attachments,sort:@sort,order:@order,curse_attachments:@obj_attachments} )%>"); <% elsif @project %> $("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/project_list', :locals => {project:@project, all_attachments:@all_attachments, sort:@sort, order:@order, project_attachments:@obj_attachments})%>"); +<% elsif @org_subfield %> + $("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/org_subfield_list', :locals => {org_subfield:@org_subfield, all_attachments:@all_attachments, sort:@sort, order:@order, org_subfield_attachments:@obj_attachments})%>"); <%end %> \ No newline at end of file diff --git a/app/views/files/search_files_in_subfield.js.erb b/app/views/files/search_files_in_subfield.js.erb index deed2d5d3..dfaa56a6c 100644 --- a/app/views/files/search_files_in_subfield.js.erb +++ b/app/views/files/search_files_in_subfield.js.erb @@ -1,2 +1,7 @@ -$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'org_subfield_list', - :locals => {org_subfield: @org_subfield,all_attachments: @result,sort:@sort,order:@order,org_subfield_attachments:@searched_attach})%>"); \ No newline at end of file +<% if (@obj_pages &&( @obj_pages.page > 1)) || (@feedback_pages && (@feedback_pages.page > 1)) %> + $("#show_more_attachments").replaceWith("<%= escape_javascript( render :partial => 'files/org_subfield_list', + :locals => {org_subfield: @org_subfield,all_attachments: @result,sort:@sort,order:@order,org_subfield_attachments:@searched_attach} )%>"); +<% else %> + $("#org_subfield_list").html("<%= escape_javascript(render :partial => 'org_subfield_list', + :locals => {org_subfield: @org_subfield,all_attachments: @result,sort:@sort,order:@order,org_subfield_attachments:@searched_attach})%>"); +<% end %> \ No newline at end of file diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index 8280a2be7..cbce501e5 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -75,7 +75,7 @@ <%=link_to "", new_organization_org_document_comment_path(organization, :field_id => field.id), :method => "get", :class => "homepageMenuSetting fr", :title => "发布帖子"%> <% end %> <% else %> - <%= link_to "#{field.name}", org_subfield_files_path(field), :class => "homepageMenuText" %> + <%= link_to "#{field.name}", show_org_subfield_organization_path(:id => organization.id, :name => field.name), :class => "homepageMenuText" %> <% if User.current.member_of_org?organization %> <%= link_to "", subfield_upload_file_org_subfield_files_path(field.id, :in_org => 1),:method => "post", :remote => true, :class => "homepageMenuSetting fr", :title => "上传资源" %> diff --git a/config/routes.rb b/config/routes.rb index 133203a8b..1f04f65d5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -54,6 +54,7 @@ RedmineApp::Application.routes.draw do post 'logout' post 'apply_subdomain' get 'org_resources_subfield' + get '/:name', :to => 'org_subfields#show', :as => 'show_org_subfield' end collection do get 'check_uniq' diff --git a/public/javascripts/org.js b/public/javascripts/org.js index 1e1951006..636b84baa 100644 --- a/public/javascripts/org.js +++ b/public/javascripts/org.js @@ -50,4 +50,28 @@ function show_more_org_course(url){ {page: $("#org_course_page_num").val()}, function (data){} ); +} + +function search_tag_attachment(url,tag_name,q,course_id,sort) +{ + //alert("111"); + //clearTimeout(clickFunction); + clickFunction = setTimeout(function() { + search_func() + }, 500); + function search_func(){ + if(isdb!= false ) return; + $.get( + url, + { + tag_name: tag_name, + q: q, + org_subfield_id:course_id + }, + function (data) { + + } + ); + } + } \ No newline at end of file diff --git a/public/stylesheets/org.css b/public/stylesheets/org.css index 02e6ce340..2ebdcf654 100644 --- a/public/stylesheets/org.css +++ b/public/stylesheets/org.css @@ -108,4 +108,10 @@ div.flash {margin-top :0px !important} .w80{ width:80px;} .relatePInfo {text-align: left; 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;} -.captainName {max-width:40px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; display: inline-block;} \ No newline at end of file +.captainName {max-width:40px; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; display: inline-block;} +.researchBox { width:240px; height:24px; border:1px solid #dddddd; color:#666666; outline:none;} +.blueBtn{ width:60px; height:26px; color:#FFF; border:none; background-color:#269ac9; cursor:pointer; padding-left:0px; text-align:center;} +.blueBtn:hover {background-color:#298fbd;} +/*文本描述展开高度*/ +.maxh360 {max-height: 810px;} +.lh18 { line-height: 18px;} \ No newline at end of file diff --git a/public/stylesheets/share.css b/public/stylesheets/share.css index b36d80082..0c0597507 100644 --- a/public/stylesheets/share.css +++ b/public/stylesheets/share.css @@ -41,4 +41,12 @@ a.greyBtn2 {float:right; text-align:center; font-size:12px; color:#ffffff; backg a.grey_btn{ background:#d9d9d9; color:#656565;font-size:14px; font-weight:normal; text-align:center; margin-left:10px; margin-bottom:10px; padding:2px 10px;} a.blue_btn{background:#64bdd9;color:#fff;font-size:14px; font-weight:normal; padding:2px 8px; text-align:center;cursor: pointer;} .homepageImageSex {top:116px; left:5px; width:20px; height:20px; background:url(../images/homepage_icon.png) -10px -112px no-repeat; float:left;} -.homepageImageName {font-size:16px; color:#484848; margin-left:15px; margin-right:8px; height:21px; float:left;} \ No newline at end of file +.homepageImageName {font-size:16px; color:#484848; margin-left:15px; margin-right:8px; height:21px; float:left;} + +a.resourcesTypeAll {background:url(images/homepage_icon.png) -180px -89px no-repeat; padding-left:23px;} + +.mediaIcon {background:url(../images/hwork_icon.png) -5px -160px no-repeat; padding-left:23px;} +.codeIcon {background:url(../images/hwork_icon.png) -78px -160px no-repeat; padding-left:23px;} +.othersIcon {background:url(../images/hwork_icon.png) -3px -210px no-repeat; padding-left:23px;} +.thesisIcon {background:url(../images/hwork_icon.png) -78px -212px no-repeat; padding-left:23px;} +.softwareIcon {background:url(../images/hwork_icon.png) -5px -254px no-repeat; padding-left:23px;} \ No newline at end of file From 5d9ce929d9440848d982f7054134df22fbad18f8 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 13 Jan 2016 09:34:33 +0800 Subject: [PATCH 14/84] =?UTF-8?q?=E7=BB=84=E7=BB=87=E6=A0=8F=E7=9B=AE?= =?UTF-8?q?=E5=AD=90=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_subfields_controller.rb | 60 +- app/models/org_subfield.rb | 1 + app/models/subfield_subdomain_dir.rb | 4 + app/views/org_subfields/show.html.erb | 581 ++++++++++++++++++ .../reject_apply_subdomain.js.erb | 0 app/views/organizations/setting.html.erb | 44 +- ...160108093752_add_status_to_org_messages.rb | 5 + ...12085834_create_subfield_subdomain_dirs.rb | 9 + db/schema.rb | 9 +- spec/factories/subfield_subdomain_dirs.rb | 6 + spec/models/subfield_subdomain_dir_spec.rb | 5 + 11 files changed, 701 insertions(+), 23 deletions(-) create mode 100644 app/models/subfield_subdomain_dir.rb create mode 100644 app/views/organizations/reject_apply_subdomain.js.erb create mode 100644 db/migrate/20160108093752_add_status_to_org_messages.rb create mode 100644 db/migrate/20160112085834_create_subfield_subdomain_dirs.rb create mode 100644 spec/factories/subfield_subdomain_dirs.rb create mode 100644 spec/models/subfield_subdomain_dir_spec.rb diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index 5db82436b..df81ccaff 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -3,6 +3,13 @@ class OrgSubfieldsController < ApplicationController @subfield = OrgSubfield.create(:name => params[:name]) @organization = Organization.find(params[:organization_id]) @organization.org_subfields << @subfield + if !params[:sub_dir].blank? + sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+ + "and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'" + if SubfieldSubdomainDir.find_by_sql(sql).count == 0 + SubfieldSubdomainDir.create(:org_subfield_id => @org_subfield.id, :name => params[:sub_dir]) + end + end @subfield.update_attributes(:priority => @subfield.id, :field_type => params[:field_type]) end @@ -11,9 +18,58 @@ class OrgSubfieldsController < ApplicationController @subfield = @organization.org_subfields.first if @subfield.field_type == 'Post' redirect_to organization_path(@organization, :org_subfield_id => @subfield.id) - else - end + @org_subfield = OrgSubfield.find_by_sql("select distinct org_subfields.* from org_subfields,"+ + "subfield_subdomain_dirs where org_subfields.id = subfield_subdomain_dirs.org_subfield_id and "+ + " org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name=#{params[:name]}").first + if params[:sort] + params[:sort].split(",").each do |sort_type| + order_by = sort_type.split(":") + + case order_by[0] + when "filename" + attribute = "filename" + when "size" + attribute = "filesize" + when "attach_type" + attribute = "attachtype" + when "content_type" + attribute = "created_on" + when "field_file_dense" + attribute = "is_public" + when "downloads" + attribute = "downloads" + when "created_on" + attribute = "created_on" + when "quotes" + attribute = "quotes" + else + attribute = "created_on" + end + @sort = order_by[0] + @order = order_by[1] + if order_by.count == 1 && attribute + sort += "#{Attachment.table_name}.#{attribute} asc " + if sort_type != params[:sort].split(",").last + sort += "," + end + elsif order_by.count == 2 && order_by[1] + sort += "#{Attachment.table_name}.#{attribute} #{order_by[1]} " + if sort_type != params[:sort].split(",").last + sort += "," + end + end + end + else + sort = "#{Attachment.table_name}.created_on desc" + end + @container_type = 2 + @containers = [ OrgSubfield.includes(:attachments).reorder(sort).find(@org_subfield.id)] + @organization = Organization.find(@containers.first.organization_id) + show_attachments @containers + @tag_list = attachment_tag_list @all_attachments + @page = params[:page] || 1 + render :layout => 'base_org' # @org_subfield = OrgSubfield.find(params[:id]) # @organization = @org_subfield.organization.id # @messages = [] diff --git a/app/models/org_subfield.rb b/app/models/org_subfield.rb index 0747114ca..146323a32 100644 --- a/app/models/org_subfield.rb +++ b/app/models/org_subfield.rb @@ -1,5 +1,6 @@ class OrgSubfield < ActiveRecord::Base belongs_to :organization, :foreign_key => :organization_id + has_one :subfield_subdomain_dir has_many :org_document_comments, :dependent => :destroy has_many :files has_many :org_subfield_messages, :dependent => :destroy diff --git a/app/models/subfield_subdomain_dir.rb b/app/models/subfield_subdomain_dir.rb new file mode 100644 index 000000000..9897e19ac --- /dev/null +++ b/app/models/subfield_subdomain_dir.rb @@ -0,0 +1,4 @@ +class SubfieldSubdomainDir < ActiveRecord::Base + # attr_accessible :title, :body + belongs_to :org_subfield +end diff --git a/app/views/org_subfields/show.html.erb b/app/views/org_subfields/show.html.erb index e69de29bb..660322c29 100644 --- a/app/views/org_subfields/show.html.erb +++ b/app/views/org_subfields/show.html.erb @@ -0,0 +1,581 @@ + +
    + <%= render :partial => 'files/subfield_files', locals: {org_subfield: @org_subfield} %> +
    + + + + + diff --git a/app/views/organizations/reject_apply_subdomain.js.erb b/app/views/organizations/reject_apply_subdomain.js.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index 40cc295d9..59e2f2ad9 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -114,26 +114,30 @@

    新增栏目

    <%= form_tag url_for(:controller => 'org_subfields', :action => 'create', :organization_id => @organization.id), :id=> 'add_subfield_form',:remote => true do %> - -
    -

    域名目录(用户自定义url,可选)

    - micros.trustie.net/ -
    -
    -
      -
    • 栏目类型
    • -
    • - - -
    • -
    • - - -
    • -
    • -
    -
    - 确定 + +
    +

    域名目录(用户自定义url,可选)

    + <% if @organization.domain %> + <%= @organization.domain %>.trustie.net/ + <% else %> + 您还没有子域名,请先在左侧信息栏申请子域名 + <% end %> +
    +
    +
      +
    • 栏目类型
    • +
    • + + +
    • +
    • + + +
    • +
    • +
    +
    + 确定 <% end %>
    diff --git a/db/migrate/20160108093752_add_status_to_org_messages.rb b/db/migrate/20160108093752_add_status_to_org_messages.rb new file mode 100644 index 000000000..4fbe41fe1 --- /dev/null +++ b/db/migrate/20160108093752_add_status_to_org_messages.rb @@ -0,0 +1,5 @@ +class AddStatusToOrgMessages < ActiveRecord::Migration + def change + add_column :org_messages, :status, :integer, :default => 0 + end +end diff --git a/db/migrate/20160112085834_create_subfield_subdomain_dirs.rb b/db/migrate/20160112085834_create_subfield_subdomain_dirs.rb new file mode 100644 index 000000000..0ef66a94c --- /dev/null +++ b/db/migrate/20160112085834_create_subfield_subdomain_dirs.rb @@ -0,0 +1,9 @@ +class CreateSubfieldSubdomainDirs < ActiveRecord::Migration + def change + create_table :subfield_subdomain_dirs do |t| + t.integer :org_subfield_id + t.string :name + t.timestamps + end + end +end diff --git a/db/schema.rb b/db/schema.rb index b21b5057d..85eec4d85 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 => 20160108093752) do +ActiveRecord::Schema.define(:version => 20160112085834) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1656,6 +1656,13 @@ ActiveRecord::Schema.define(:version => 20160108093752) do add_index "students_for_courses", ["course_id"], :name => "index_students_for_courses_on_course_id" add_index "students_for_courses", ["student_id"], :name => "index_students_for_courses_on_student_id" + create_table "subfield_subdomain_dirs", :force => true do |t| + t.integer "org_subfield_id" + t.string "name" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false + end + create_table "system_messages", :force => true do |t| t.integer "user_id" t.string "content" diff --git a/spec/factories/subfield_subdomain_dirs.rb b/spec/factories/subfield_subdomain_dirs.rb new file mode 100644 index 000000000..3a9878a82 --- /dev/null +++ b/spec/factories/subfield_subdomain_dirs.rb @@ -0,0 +1,6 @@ +FactoryGirl.define do + factory :subfield_subdomain_dir do + + end + +end diff --git a/spec/models/subfield_subdomain_dir_spec.rb b/spec/models/subfield_subdomain_dir_spec.rb new file mode 100644 index 000000000..330a35c54 --- /dev/null +++ b/spec/models/subfield_subdomain_dir_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe SubfieldSubdomainDir, :type => :model do + pending "add some examples to (or delete) #{__FILE__}" +end From 8ead573872e00b47a50f7b8b935bc6196be5fed2 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 13 Jan 2016 09:56:24 +0800 Subject: [PATCH 15/84] =?UTF-8?q?=E7=BB=84=E7=BB=87=E8=AE=BE=E7=BD=AEurl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_subfields_controller.rb | 23 +++++++++++-------- app/views/org_subfields/create.js.erb | 18 +++++++++------ .../organizations/_subfield_list.html.erb | 2 +- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index df81ccaff..3f781c4cc 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -1,16 +1,21 @@ class OrgSubfieldsController < ApplicationController def create - @subfield = OrgSubfield.create(:name => params[:name]) - @organization = Organization.find(params[:organization_id]) - @organization.org_subfields << @subfield - if !params[:sub_dir].blank? - sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+ - "and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'" - if SubfieldSubdomainDir.find_by_sql(sql).count == 0 - SubfieldSubdomainDir.create(:org_subfield_id => @org_subfield.id, :name => params[:sub_dir]) + if OrgSubfield.where("organization_id=#{params[:organization_id]} and name=?",params[:name]).count == 0 + @res = true + @subfield = OrgSubfield.create(:name => params[:name]) + @organization = Organization.find(params[:organization_id]) + @organization.org_subfields << @subfield + if !params[:sub_dir].blank? + sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+ + "and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'" + if SubfieldSubdomainDir.find_by_sql(sql).count == 0 + SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir]) + end end + @subfield.update_attributes(:priority => @subfield.id, :field_type => params[:field_type]) + else + @res = false end - @subfield.update_attributes(:priority => @subfield.id, :field_type => params[:field_type]) end def show diff --git a/app/views/org_subfields/create.js.erb b/app/views/org_subfields/create.js.erb index 345c8f60f..61ac95f71 100644 --- a/app/views/org_subfields/create.js.erb +++ b/app/views/org_subfields/create.js.erb @@ -1,7 +1,11 @@ -$("#org_subfield_list").html(""); -$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list', - :locals => {:default_fields => @organization.org_subfields.where("field_type='default'"), - :subfields => @organization.org_subfields.where("field_type != 'default'") }) %>"); -$("#sub_field_left_lists").html(""); -$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); -$("#subfield_name").val(""); \ No newline at end of file +<% if @res %> + $("#org_subfield_list").html(""); + $("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list', + :locals => {:default_fields => @organization.org_subfields.where("field_type='default'"), + :subfields => @organization.org_subfields.where("field_type != 'default'") }) %>"); + $("#sub_field_left_lists").html(""); + $("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); + $("#subfield_name").val(""); +<% else %> + $("#subfield_name").val(""); +<% end %> \ No newline at end of file diff --git a/app/views/organizations/_subfield_list.html.erb b/app/views/organizations/_subfield_list.html.erb index b8af1e85e..19e9eb3c2 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -27,7 +27,7 @@
  • 新增
  • <%= field.field_type == "Post" ? "帖子" : "资源" %>
  • - + <%#= link_to "隐藏", hide_org_subfield_organizations_path(field), :method => 'post', :remote => true, :id => "hide_#{field.id}", :class => "linkBlue fr mr5" %> <%= field.hide==0?"设为隐藏":"设为可见" %> <%= link_to "删除", org_subfield_path(field), :method => 'delete', :remote => true, :confirm => "您确定删除吗?", :class => "linkBlue fr mr10" %> From e04926f2e798fd1e4256a093d8053e79860f97c8 Mon Sep 17 00:00:00 2001 From: cxt Date: Wed, 13 Jan 2016 10:04:42 +0800 Subject: [PATCH 16/84] =?UTF-8?q?=E5=85=B3=E8=81=94=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E7=9A=84=E6=8F=90=E4=BA=A4=E6=AC=A1=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/_org_course_homework.html.erb | 2 +- app/views/users/_course_homework.html.erb | 2 +- app/views/users/_user_homework_detail.html.erb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/organizations/_org_course_homework.html.erb b/app/views/organizations/_org_course_homework.html.erb index 4f2a7b662..564b27b35 100644 --- a/app/views/organizations/_org_course_homework.html.erb +++ b/app/views/organizations/_org_course_homework.html.erb @@ -173,7 +173,7 @@ <% time=project.updated_on %> <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>

    <%=(User.find project.user_id).show_name %>(组长)

    -

    <%=time_from_now time %>

    +

    <%=time_from_now time %>  <%=changesets_num project %>提交

    项目名称:<%=project.name %>
    创建者:<%=(User.find project.user_id).show_name %>(组长)
    diff --git a/app/views/users/_course_homework.html.erb b/app/views/users/_course_homework.html.erb index 7c6959935..793f5ba39 100644 --- a/app/views/users/_course_homework.html.erb +++ b/app/views/users/_course_homework.html.erb @@ -173,7 +173,7 @@ <% time=project.updated_on %> <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>

    <%=(User.find project.user_id).show_name %>(组长)

    -

    <%=time_from_now time %>

    +

    <%=time_from_now time %>  <%=changesets_num project %>提交

    项目名称:<%=project.name %>
    创建者:<%=(User.find project.user_id).show_name %>(组长)
    diff --git a/app/views/users/_user_homework_detail.html.erb b/app/views/users/_user_homework_detail.html.erb index 85e426e92..05077eb26 100644 --- a/app/views/users/_user_homework_detail.html.erb +++ b/app/views/users/_user_homework_detail.html.erb @@ -174,7 +174,7 @@ <% time=project.updated_on %> <% time=ForgeActivity.where("project_id=?",project.id).last.updated_at if ForgeActivity.where("project_id=?",project.id).last %>

    <%=(User.find project.user_id).show_name %>(组长)

    -

    <%=time_from_now time %>

    +

    <%=time_from_now time %>  <%=changesets_num project %>提交

    项目名称:<%=project.name %>
    创建者:<%=(User.find project.user_id).show_name %>(组长)
    From 64088f5a212fe49584ce36bb32688dea41f3a264 Mon Sep 17 00:00:00 2001 From: huang Date: Wed, 13 Jan 2016 10:08:48 +0800 Subject: [PATCH 17/84] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=AD=98=E5=85=A5=E6=95=B0=E6=8D=AE=E5=BA=93=EF=BC=88=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E6=95=B0=E6=8D=AE=E7=9B=B4=E6=8E=A5=E4=BB=8E=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=BA=93=E8=8E=B7=E5=8F=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/files_controller.rb | 17 ++++++++-------- app/models/attachment.rb | 11 +++++++++- app/models/forge_activity.rb | 19 ++++++++++++++++-- app/models/message.rb | 20 +++++++++++++++++-- app/models/news.rb | 16 +++++++++++++-- app/views/layouts/base_projects.html.erb | 17 ++++++++-------- .../projects/_development_group.html.erb | 16 +++++++-------- app/views/projects/_friend_group.html.erb | 12 +++++------ app/views/projects/_research_team.html.erb | 16 +++++++-------- 9 files changed, 98 insertions(+), 46 deletions(-) diff --git a/app/controllers/files_controller.rb b/app/controllers/files_controller.rb index 59b0f6f03..1506061b2 100644 --- a/app/controllers/files_controller.rb +++ b/app/controllers/files_controller.rb @@ -17,14 +17,14 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. class FilesController < ApplicationController - - layout 'base_projects' #by young + layout 'base_projects' #by young menu_item :files before_filter :auth_login1, :only => [:index] before_filter :logged_user_by_apptoken,:only => [:index] before_filter :find_project_by_project_id#, :except => [:getattachtype] - before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project,:search_tag_attachment,:subfield_upload_file,:search_org_subfield_tag_attachment,:search_tag_attachment,:quote_resource_show_org_subfield,:find_org_subfield_attache,:search_files_in_subfield] + before_filter :authorize, :except => [:create,:getattachtype,:quote_resource_show,:search,:searchone4reload,:search_project,:quote_resource_show_project,:search_tag_attachment,:subfield_upload_file, + :search_org_subfield_tag_attachment,:search_tag_attachment,:quote_resource_show_org_subfield,:find_org_subfield_attache,:search_files_in_subfield] helper :sort include SortHelper @@ -450,6 +450,9 @@ class FilesController < ApplicationController end end end + # 更新资源总数, 根据上传的附件数累加 + @project.update_attribute(:attachments_count, @project.attachments_count + attachments[:files].count) + # end # TODO: 临时用 nyan sort_init 'created_on', 'desc' sort_update 'created_on' => "#{Attachment.table_name}.created_on", @@ -478,9 +481,6 @@ class FilesController < ApplicationController if !attachments.empty? && !attachments[:files].blank? && Setting.notified_events.include?('file_added') Mailer.run.attachments_added(attachments[:files]) end - # 更新课程英雄榜得分 - update_contributor_score(@course, attachments[:files].first) - # end if params[:course_attachment_type] && params[:course_attachment_type].is_a?(Array) params[:course_attachment_type].each do |type| tag_name = get_tag_name_by_type_number type @@ -502,8 +502,9 @@ class FilesController < ApplicationController end end end - - + # 更新课程英雄榜得分 + update_contributor_score(@course, attachments[:files].first) + # end # TODO: 临时用 nyan sort_init 'created_on', 'desc' sort_update 'created_on' => "#{Attachment.table_name}.created_on", diff --git a/app/models/attachment.rb b/app/models/attachment.rb index d90b0368e..3088714ee 100644 --- a/app/models/attachment.rb +++ b/app/models/attachment.rb @@ -90,7 +90,7 @@ class Attachment < ActiveRecord::Base before_save :files_to_final_location,:act_as_course_activity after_create :office_conver, :be_user_score,:act_as_forge_activity,:create_attachment_ealasticsearch_index after_update :office_conver, :be_user_score,:update_attachment_ealasticsearch_index - after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index + after_destroy :delete_from_disk,:down_user_score,:delete_attachment_ealasticsearch_index#, :decrease_attchments_count # add by nwb # 获取所有可公开的资源文件列表 @@ -617,6 +617,7 @@ class Attachment < ActiveRecord::Base self.__elasticsearch__.index_document end end + def update_attachment_ealasticsearch_index if self.is_public == 1 && ( ((self.container_type == 'Project' or self.container_type == 'Version') && Project.find(self.container_id).is_public == 1) || ( self.container_type == 'Course' && Course.find(self.container_id).is_public == 1) || @@ -632,12 +633,20 @@ class Attachment < ActiveRecord::Base end end end + def delete_attachment_ealasticsearch_index begin self.__elasticsearch__.delete_document rescue => e end end + + # def decrease_attchments_count + # if self.container_type == "Project" + # count = self.container.attachments_count + # #self.container.update_attribute(:attachments_count, self.container.attachments_count - 1) + # end + # end end # Delete the previous articles index in Elasticsearch diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index c98c5475b..310d194a0 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -20,8 +20,8 @@ class ForgeActivity < ActiveRecord::Base validates :forge_act_id,presence: true validates :forge_act_type, presence: true has_many :user_acts, :class_name => 'UserAcivity',:as =>:act - after_save :add_user_activity, :add_org_activity - before_destroy :destroy_user_activity, :destroy_org_activity + after_save :add_user_activity, :add_org_activity, :add_acts_count + before_destroy :destroy_user_activity, :destroy_org_activity, :decrease_acts_count #在个人动态里面增加当前动态 def add_user_activity @@ -45,6 +45,21 @@ class ForgeActivity < ActiveRecord::Base end end + # 更新动态数 + def add_acts_count + if self.project + count = self.project.acts_count + 1 + self.project.update_attribute(:acts_count, count) + end + end + + def decrease_acts_count + if self.project + count = self.project.acts_count - 1 + self.project.update_attribute(:acts_count, count) + end + end + def add_org_activity org_activity = OrgActivity.where("org_act_type = '#{self.forge_act_type.to_s}' and org_act_id = #{self.forge_act_id}").first if org_activity diff --git a/app/models/message.rb b/app/models/message.rb index 3bb08f481..1d3ae7681 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -74,9 +74,9 @@ class Message < ActiveRecord::Base validates_length_of :subject, :maximum => 255 validate :cannot_reply_to_locked_topic, :on => :create - after_create :add_author_as_watcher, :reset_counters! + after_create :add_author_as_watcher, :reset_counters!, :add_boards_count after_update :update_messages_board - after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets + after_destroy :reset_counters!,:down_user_score,:delete_kindeditor_assets, :decrease_boards_count 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 @@ -125,6 +125,14 @@ class Message < ActiveRecord::Base end end + # 发帖精辟更新发帖总数 + def add_boards_count + if self.parent_id.nil? + count = self.project.boards_count + 1 + self.project.update_attribute(:boards_count, count) + end + end + def reset_counters! if parent && parent.id Message.update_all({:last_reply_id => parent.children.maximum(:id)}, {:id => parent.id}) @@ -303,6 +311,14 @@ class Message < ActiveRecord::Base delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::MESSAGE end + # 删除帖子的时候更新帖子总数, 删除回复的时候总数不减少 + def decrease_boards_count + if self.parent_id.nil? + count = self.project.boards_count - 1 + self.project.update_attribute(:boards_count, count) + end + end + # 课程成员得分(英雄榜) def act_as_student_score if self.course diff --git a/app/models/news.rb b/app/models/news.rb index a7407c91f..807206f40 100644 --- a/app/models/news.rb +++ b/app/models/news.rb @@ -55,9 +55,9 @@ class News < ActiveRecord::Base :author_key => :author_id acts_as_watchable - after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_system_message, :add_author_as_watcher, :send_mail + after_create :act_as_activity,:act_as_forge_activity, :act_as_course_activity,:act_as_system_message, :add_author_as_watcher, :send_mail, :add_news_count - after_destroy :delete_kindeditor_assets + after_destroy :delete_kindeditor_assets, :decrease_news_count scope :visible, lambda {|*args| includes(:project).where(Project.allowed_to_condition(args.shift || User.current, :view_news, *args)) @@ -107,10 +107,17 @@ class News < ActiveRecord::Base end private + def add_news_count + if self.project + count = self.project.news_count + 1 + self.project.update_attribute(:news_count, count) + end + end def add_author_as_watcher Watcher.create(:watchable => self, :user => author) end + ## fq def act_as_activity self.acts << Activity.new(:user_id => self.author_id) @@ -161,6 +168,11 @@ class News < ActiveRecord::Base delete_kindeditor_assets_from_disk self.id,OwnerTypeHelper::NEWS end + def decrease_news_count + count = self.project.news_count - 1 + self.project.update_attribute(:news_count, count) + end + def send_mail Mailer.run.news_added(self) if Setting.notified_events.include?('news_added') end diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 6716a3aaa..90ac0291a 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -91,12 +91,11 @@ <%= l(:label_member) %>(<%= link_to "#{@project.members.count}", project_member_path(@project), :class => 'info_foot_num c_blue', :id => 'project_members_number' %>) <%= l(:label_user_watcher) %>(<%= link_to "#{@project.watcher_users.count}", {:controller=>"projects", :action=>"watcherlist", :id => @project.id}, :class => 'info_foot_num c_blue' %>) - <% attaments_num = @project.attachments.count %> <% unless @project.enabled_modules.where("name = 'files'").empty? %> <%= l(:project_module_attachments) %>( - <% attaments_num %> - <%= link_to "#{attaments_num}", project_files_path(@project), :class => 'info_foot_num c_blue', :id=>'project_files_count_info' %>) + <% @project.attachments_count %> + <%= link_to "#{@project.attachments_count}", project_files_path(@project), :class => 'info_foot_num c_blue', :id=>'project_files_count_info' %>) <% end %>
    @@ -120,11 +119,11 @@
    <% if @project.project_new_type == 1 || @project.project_new_type.nil? %> - <%= render :partial => 'projects/development_group', :locals => {:project => @project, :attaments_num => attaments_num} %> + <%= render :partial => 'projects/development_group', :locals => {:project => @project} %> <% elsif @project.project_new_type == 2 %> - <%= render :partial => 'projects/research_team', :locals => {:project => @project, :attaments_num => attaments_num} %> + <%= render :partial => 'projects/research_team', :locals => {:project => @project} %> <% else %> - <%= render :partial => 'projects/friend_group', :locals => {:project => @project, :attaments_num => attaments_num} %> + <%= render :partial => 'projects/friend_group', :locals => {:project => @project} %> <% end %>
    @@ -213,19 +212,19 @@ if(data == 1) { $("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_development_team), 1))%>"); - $("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/development_group', :locals => {:project => @project, :attaments_num => attaments_num})) %>'); + $("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/development_group', :locals => {:project => @project})) %>'); $("#close_light").attr("onClick","close_window('development_group');"); } else if(data == 2) { $("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_research_group), 2))%>"); - $("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/research_team', :locals => {:project => @project, :attaments_num => attaments_num})) %>'); + $("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/research_team', :locals => {:project => @project})) %>'); $("#close_light").attr("onClick","close_window('research_group');"); } else if(data == 3) { $("#setting_project_type").replaceWith("<%= escape_javascript(project_type_link(l(:label_friend_organization), 3))%>"); - $("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/friend_group', :locals => {:project => @project, :attaments_num => attaments_num})) %>'); + $("#project_memu_list").html('<%= escape_javascript(render(:partial => 'projects/friend_group', :locals => {:project => @project})) %>'); $("#close_light").attr("onClick","close_window('friend_organization');"); } else diff --git a/app/views/projects/_development_group.html.erb b/app/views/projects/_development_group.html.erb index 47a1f2a94..0c33f70a6 100644 --- a/app/views/projects/_development_group.html.erb +++ b/app/views/projects/_development_group.html.erb @@ -1,14 +1,14 @@ <% unless @project.enabled_modules.where("name = 'issue_tracking'").empty? %>