From 879dee0cd6f4ee97b8f43fa6429a991bc187e73d Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 27 Nov 2015 17:27:55 +0800 Subject: [PATCH 01/15] =?UTF-8?q?=E5=85=B3=E9=97=AD=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E5=85=B3=E8=81=94=E9=A1=B9=E7=9B=AE=E6=88=96=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E5=BC=B9=E7=AA=97=EF=BC=8C=E5=88=B7=E6=96=B0=E6=95=B4=E4=B8=AA?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/_join_course_menu.html.erb | 1 + app/views/organizations/_join_project_menu.html.erb | 1 + 2 files changed, 2 insertions(+) diff --git a/app/views/organizations/_join_course_menu.html.erb b/app/views/organizations/_join_course_menu.html.erb index e66d0bcce..d875550de 100644 --- a/app/views/organizations/_join_course_menu.html.erb +++ b/app/views/organizations/_join_course_menu.html.erb @@ -13,6 +13,7 @@ $(".resourcePopupClose").click(function(){ + location.reload(); $(".resourceSharePopup").css("display","none"); }); }); diff --git a/app/views/organizations/_join_project_menu.html.erb b/app/views/organizations/_join_project_menu.html.erb index 765b4b23a..e13e1416e 100644 --- a/app/views/organizations/_join_project_menu.html.erb +++ b/app/views/organizations/_join_project_menu.html.erb @@ -13,6 +13,7 @@ $(".resourcePopupClose").click(function(){ + location.reload(); $(".resourceSharePopup").css("display","none"); }); }); From 6f9c89d67b7c88b82b8ae5414bd53406df426e65 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 30 Nov 2015 16:04:43 +0800 Subject: [PATCH 02/15] =?UTF-8?q?1.=E6=9B=B4=E6=94=B9=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E5=86=85=E5=AE=B9=EF=BC=8C=E4=B8=8D=E6=98=BE=E7=A4=BA=E4=BD=9C?= =?UTF-8?q?=E8=80=85=E7=AD=89=E4=BF=A1=E6=81=AF=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E9=A6=96=E9=A1=B5=E3=80=81=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E3=80=81=E5=88=A0=E9=99=A4=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E7=AD=89=E5=8A=9F=E8=83=BD=EF=BC=9B=202.=E5=A2=9E=E5=8A=A0edit?= =?UTF-8?q?or=5Fof=5Fdocuments=E8=A1=A8=EF=BC=8C=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E7=BC=96=E8=BE=91=E7=9A=84=E4=BD=9C=E8=80=85?= =?UTF-8?q?=E3=80=81=E6=97=B6=E9=97=B4=E7=AD=89=EF=BC=8C=E5=B9=B6=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E9=A6=96=E9=A1=B5=E7=9A=84=E6=9C=80=E5=90=8E=E7=BC=96?= =?UTF-8?q?=E8=BE=91=E4=BA=BA=EF=BC=9B=203.=E5=9C=A8=E9=A6=96=E9=A1=B5?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=96=87=E7=AB=A0=E5=90=8E=EF=BC=8C=E5=BA=94?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E9=A6=96=E9=A1=B5=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org_document_comments_controller.rb | 15 ++-- app/controllers/organizations_controller.rb | 6 ++ app/models/editor_of_document.rb | 4 ++ app/models/org_document_comment.rb | 2 +- .../org_document_comments/index.html.erb | 2 +- app/views/org_document_comments/show.html.erb | 2 +- .../organizations/_org_activities.html.erb | 2 +- .../organizations/_show_home_page.html.erb | 69 +++++++++++++++++++ .../organizations/_show_org_document.html.erb | 10 +-- .../organizations/cancel_homepage.js.erb | 1 + app/views/organizations/show.html.erb | 4 +- config/routes.rb | 1 + ...20151130032658_create_org_docume_editor.rb | 12 ++++ ...ument_created_at_for_editor_of_document.rb | 12 ++++ 14 files changed, 124 insertions(+), 18 deletions(-) create mode 100644 app/models/editor_of_document.rb create mode 100644 app/views/organizations/_show_home_page.html.erb create mode 100644 app/views/organizations/cancel_homepage.js.erb create mode 100644 db/migrate/20151130032658_create_org_docume_editor.rb create mode 100644 db/migrate/20151130064556_copy_document_created_at_for_editor_of_document.rb diff --git a/app/controllers/org_document_comments_controller.rb b/app/controllers/org_document_comments_controller.rb index 02527bdfc..29b728268 100644 --- a/app/controllers/org_document_comments_controller.rb +++ b/app/controllers/org_document_comments_controller.rb @@ -13,7 +13,7 @@ class OrgDocumentCommentsController < ApplicationController @org_document_comment.content = params[:org_document_comment][:content] if @org_document_comment.save flash.keep[:notice] = l(:notice_successful_create) - OrgActivity + EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document_comment.id, :created_at => @org_document_comment.updated_at) redirect_to organization_org_document_comments_path(@organization) else redirect_to new_org_document_comment_path(:organization_id => @organization.id) @@ -36,13 +36,18 @@ class OrgDocumentCommentsController < ApplicationController if @org_document.parent.nil? act = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", @org_document.id).first act.update_attributes(:updated_at => @org_document.updated_at) + EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document.id, :created_at => Time.now) end respond_to do |format| format.html { if params[:flag].to_i == 0 redirect_to organization_org_document_comments_path(:organization_id => @org_document.organization.id) else - redirect_to org_document_comment_path(@org_document.root.id, :organization_id => @org_document.organization.id) + if params[:flag].to_i == 1 + redirect_to org_document_comment_path(@org_document.root.id, :organization_id => @org_document.organization.id) + else + redirect_to organization_path(@org_document.organization.id) + end end } end @@ -81,10 +86,10 @@ class OrgDocumentCommentsController < ApplicationController def destroy @org_document_comment = OrgDocumentComment.find(params[:id]) org = @org_document_comment.organization + if @org_document_comment.id == org.home_id + org.update_attributes(:home_id => nil) + end if @org_document_comment.destroy - if @org_document_comment.id == org.id - org.home_id == nil - end end respond_to do |format| format.js diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index b326051e6..70ac952ea 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -142,6 +142,12 @@ class OrganizationsController < ApplicationController # end end + def cancel_homepage + @org = Organization.find(params[:id]) + @org.home_id = nil + @org.save + end + def autocomplete_search @project = Project.find(params[:project_id]) #@flag = params[:flag] || false diff --git a/app/models/editor_of_document.rb b/app/models/editor_of_document.rb new file mode 100644 index 000000000..15d9e7e37 --- /dev/null +++ b/app/models/editor_of_document.rb @@ -0,0 +1,4 @@ +class EditorOfDocument < ActiveRecord::Base + belongs_to :user, :class_name => 'User', :foreign_key => 'editor_id' + belongs_to :org_document_comment +end \ No newline at end of file diff --git a/app/models/org_document_comment.rb b/app/models/org_document_comment.rb index 7b9f9cd75..e2ce350ce 100644 --- a/app/models/org_document_comment.rb +++ b/app/models/org_document_comment.rb @@ -3,7 +3,7 @@ class OrgDocumentComment < ActiveRecord::Base include Redmine::SafeAttributes belongs_to :organization belongs_to :creator, :class_name => 'User', :foreign_key => 'creator_id' - + has_many :editor_of_documents, :dependent => :destroy acts_as_tree :order => "#{OrgDocumentComment.table_name}.sticky asc, #{OrgDocumentComment.table_name}.created_at desc" has_many :org_acts, :class_name => 'OrgActivity',:as =>:org_act ,:dependent => :destroy after_create :document_save_as_org_activity diff --git a/app/views/org_document_comments/index.html.erb b/app/views/org_document_comments/index.html.erb index d967c42fd..9a9f74ac6 100644 --- a/app/views/org_document_comments/index.html.erb +++ b/app/views/org_document_comments/index.html.erb @@ -19,6 +19,6 @@ init_activity_KindEditor_data(<%= OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id=?", document.id).first.id %>, null, "87%"); }); - <%= render :partial => 'organizations/show_org_document', :locals => {:document => document, :act => OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id=?", document.id).first} %> + <%= render :partial => 'organizations/show_org_document', :locals => {:document => document, :act => OrgActivity.where("org_act_type='OrgDocumentComment'and org_act_id=?", document.id).first, :flag => 0} %> <% end %> <% end %> \ No newline at end of file diff --git a/app/views/org_document_comments/show.html.erb b/app/views/org_document_comments/show.html.erb index 31e4f7e05..7655f996e 100644 --- a/app/views/org_document_comments/show.html.erb +++ b/app/views/org_document_comments/show.html.erb @@ -25,7 +25,7 @@
发布时间:<%= format_activity_day(@document.created_at) %> <%= format_time(@document.created_at, false) %>
<% unless @document.content.blank? %> -
+
<%= @document.content.html_safe %>
<% end %> diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index 33ac13e76..60238091f 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -22,7 +22,7 @@
<% end %> <% if act.org_act_type == 'OrgDocumentComment' && act.org_act_id != @organization.home_id %> - <%= render :partial => 'show_org_document', :locals => {:document => act.org_act, :act => act} %> + <%= render :partial => 'show_org_document', :locals => {:document => act.org_act, :act => act, :flag => 2} %> <% end %> <% end %> <% if act.container_type == 'Project' %> diff --git a/app/views/organizations/_show_home_page.html.erb b/app/views/organizations/_show_home_page.html.erb new file mode 100644 index 000000000..ade3f7ba8 --- /dev/null +++ b/app/views/organizations/_show_home_page.html.erb @@ -0,0 +1,69 @@ +
+
+ +
+ +
<%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %>
+ + <% unless document.content.blank? %> +
+ <%= document.content.html_safe %> +
+ <% end %> +
+ 发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %> +
+
+
+ 最后编辑:<%= User.find(EditorOfDocument.where("org_document_comment_id =?", document.id).order("created_at desc").first.editor_id).realname %> +
+ + <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id) || User.current.id == document.creator_id) %> +
+
    +
  • +
      +
    • + <%= form_for('new_form', :url => {:controller => 'organizations', :action => 'cancel_homepage', :id => document.organization_id, :home_id => document.id}, :method => "put", :remote => true) do |f| %> + 取消首页 + <% end %> +
    • +
    • + <%= link_to "编辑首页", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id, :flag => 2), :class => "postOptionLink" %> +
    • +
    • + <%= link_to "删除首页", org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :method => 'delete', + :data => {:confirm => l(:text_are_you_sure)}, + :remote => true, :class => 'postOptionLink' %> +
    • +
    +
  • +
+
+
+ <% end %> +
+
+ +
+ + \ No newline at end of file diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb index 888cbbf68..4d1393897 100644 --- a/app/views/organizations/_show_org_document.html.erb +++ b/app/views/organizations/_show_org_document.html.erb @@ -8,24 +8,20 @@ <%= link_to User.find(document.creator_id), user_path(document.creator.id), :class => "newsBlue mr15" %> TO  <%= link_to document.organization.name, organization_path(document.organization), :class => "newsBlue" %> | - <% if document.organization.home_id == document.id %> - 首页 - <% else %> 组织文章 - <% end %>
<%= link_to document.title, org_document_comment_path(:id => document.id, :organization_id => document.organization.id) %>
发布时间:<%= format_activity_day(document.created_at) %> <%= format_time(document.created_at, false) %>
<% unless document.content.blank? %> -
+
<%= document.content.html_safe %>
<% end %> - <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id) || User.current.id == document.creator_id) %> + <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id)) || User.current.id == document.creator_id %>
  • @@ -36,7 +32,7 @@ <% end %>
  • - <%= link_to "编辑文章", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id, :flag => 0), :class => "postOptionLink" %> + <%= link_to "编辑文章", edit_org_document_comment_path(:id => document.id, :organization_id => document.organization_id, :flag => flag), :class => "postOptionLink" %>
  • <%= link_to "删除文章", org_document_comment_path(:id => document.id, :organization_id => document.organization_id), :method => 'delete', diff --git a/app/views/organizations/cancel_homepage.js.erb b/app/views/organizations/cancel_homepage.js.erb new file mode 100644 index 000000000..bf9eb798c --- /dev/null +++ b/app/views/organizations/cancel_homepage.js.erb @@ -0,0 +1 @@ +window.location.href = "<%= organization_path(@org) %>"; \ No newline at end of file diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index e44e0778d..9e0fc365c 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -52,14 +52,14 @@
-<% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 %> +<% 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 %> - <%= render :partial => 'show_org_document', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id, :act => act} %> + <%= render :partial => 'show_home_page', :locals => {:document => OrgDocumentComment.find(@organization.home_id), :home_id => @organization.home_id, :act => act} %> <% end %> <% if @org_activities %> <%= render :partial => 'organizations/org_activities', diff --git a/config/routes.rb b/config/routes.rb index d12a38425..bb6d7b940 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -36,6 +36,7 @@ RedmineApp::Application.routes.draw do get 'setting'#, :action => 'settings', :as => 'settings' get 'clear_org_avatar_temp' put 'set_homepage' + put 'cancel_homepage' get 'members' get 'more_org_projects' get 'more_org_courses' diff --git a/db/migrate/20151130032658_create_org_docume_editor.rb b/db/migrate/20151130032658_create_org_docume_editor.rb new file mode 100644 index 000000000..0dc9857ba --- /dev/null +++ b/db/migrate/20151130032658_create_org_docume_editor.rb @@ -0,0 +1,12 @@ +class CreateOrgDocumeEditor < ActiveRecord::Migration + def up + create_table :editor_of_documents do |t| + t.integer :editor_id + t.integer :org_document_comment_id + t.timestamp :created_at + end + end + + def down + end +end diff --git a/db/migrate/20151130064556_copy_document_created_at_for_editor_of_document.rb b/db/migrate/20151130064556_copy_document_created_at_for_editor_of_document.rb new file mode 100644 index 000000000..2361db3dd --- /dev/null +++ b/db/migrate/20151130064556_copy_document_created_at_for_editor_of_document.rb @@ -0,0 +1,12 @@ +class CopyDocumentCreatedAtForEditorOfDocument < ActiveRecord::Migration + def up + OrgDocumentComment.all.each do |doc| + if doc.parent.nil? + EditorOfDocument.create(:editor_id => doc.creator_id, :org_document_comment_id => doc.id, :created_at => doc.updated_at) + end + end + end + + def down + end +end From 3750a49b6541b4201146129f905a2b66d36f6392 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Mon, 30 Nov 2015 16:10:29 +0800 Subject: [PATCH 03/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E4=B8=8B=E6=8B=89=E6=A1=86=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/_show_home_page.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/organizations/_show_home_page.html.erb b/app/views/organizations/_show_home_page.html.erb index ade3f7ba8..3628b4929 100644 --- a/app/views/organizations/_show_home_page.html.erb +++ b/app/views/organizations/_show_home_page.html.erb @@ -20,7 +20,7 @@ - <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id) || User.current.id == document.creator_id) %> + <% if User.current.admin? || User.current.admin_of_org?(Organization.find(document.organization_id)) || User.current.id == document.creator_id %>
  • From 0aba11f175e767f186890f7ec5bcc9c3f0f02b79 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 1 Dec 2015 11:28:33 +0800 Subject: [PATCH 04/15] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=9C=A8360=E6=B5=8F=E8=A7=88=E5=99=A8?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E4=B8=8D=E5=85=BC=E5=AE=B9=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/setting.html.erb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index 82b28fb8a..96fef706a 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -45,13 +45,11 @@ <%= render :partial=>"new_org_avatar_form",:locals=> {source:@organization} %> -
    组织名称: - +
    组织名称:
    -
    组织描述: - +
    组织描述:
    From 95b071a8f727080e5f67cc27952d4a54098f88f3 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 2 Dec 2015 16:48:49 +0800 Subject: [PATCH 05/15] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/org_document_comments/add_reply.js.erb | 2 +- app/views/organizations/_show_org_document.html.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/org_document_comments/add_reply.js.erb b/app/views/org_document_comments/add_reply.js.erb index 40ed2eeb2..1906cae95 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}) %>"); +$("#organization_document_<%= @act.id %>").replaceWith("<%= escape_javascript(render :partial => 'organizations/show_org_document', :locals => {:document => @document,:flag => params[:flag], :act => @act}) %>"); init_activity_KindEditor_data(<%= @act.id %>,"","87%"); \ No newline at end of file diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb index 4d1393897..7588c7f6f 100644 --- a/app/views/organizations/_show_org_document.html.erb +++ b/app/views/organizations/_show_org_document.html.erb @@ -88,7 +88,7 @@
    - <%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id, :act_id => act.id), :method => "post", :remote => true) do |f| %> + <%= form_for('new_form', :url => add_reply_org_document_comment_path(:id => document.id, :act_id => act.id, :flag => flag), :method => "post", :remote => true) do |f| %> From 9baeb850a3ac9a099c2dcab0cca715428a519cf8 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 2 Dec 2015 17:34:21 +0800 Subject: [PATCH 06/15] =?UTF-8?q?=E5=9C=A8=E7=AE=A1=E7=90=86=E5=91=98?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E4=B8=AD=EF=BC=8C=E6=B7=BB=E5=8A=A0=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E7=9A=84=E7=BC=96=E8=BE=91=E5=92=8C=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 13 +++ app/views/organizations/destroy.js.erb | 0 app/views/organizations/edit.html.erb | 108 ++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 app/views/organizations/destroy.js.erb create mode 100644 app/views/organizations/edit.html.erb diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 70ac952ea..85f57917b 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -37,6 +37,19 @@ class OrganizationsController < ApplicationController @organization = Organization.new render :layout => 'new_base' end + + def edit + @organization = Organization.find(params[:id]) + end + + def destroy + @organization = Organization.find(params[:id]) + @organization.destroy + respond_to do |format| + format.html{ redirect_to admin_organization_path } + end + end + def create @organization = Organization.new @organization.name = params[:organization][:name] diff --git a/app/views/organizations/destroy.js.erb b/app/views/organizations/destroy.js.erb new file mode 100644 index 000000000..e69de29bb diff --git a/app/views/organizations/edit.html.erb b/app/views/organizations/edit.html.erb new file mode 100644 index 000000000..c2e918708 --- /dev/null +++ b/app/views/organizations/edit.html.erb @@ -0,0 +1,108 @@ + +<% @nav_dispaly_organization_label = 1 + @nav_dispaly_forum_label = 1 %> +<%= error_messages_for 'organization' %> +
    +

    编辑组织

    +
    +
    + + + <%#= form_for( @organization,{:controller => 'organizations',:action => 'update',:id=>@organization,:html=>{:id=>'update_org_form',:method=>'put'}}) do %> + <%= labelled_form_for @organization, :html => {:id => "edit_organization_#{@organization.id}"} do |f|%> + <%= render :partial=>"new_org_avatar_form",:locals=> {source:@organization} %> + + +
    组织名称: +
    +
    +
    +
    组织描述: +
    +
    +
    + + + + + + + + +
    公开 : + class="ml3" /> +
    + 保存 + <% end %> +
    +
    + +<% html_title(l(:label_organization_new)) -%> + + + From cf41b13f3ab81c5b25a4ae6ffe1bf8875c245425 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 2 Dec 2015 17:38:41 +0800 Subject: [PATCH 07/15] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E8=A1=A8=E5=92=8C=E7=BB=84=E7=BB=87=E8=AF=BE=E7=A8=8B=E8=A1=A8?= =?UTF-8?q?=E7=9A=84=E5=85=B3=E8=81=94=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/models/course.rb | 2 +- app/models/organization.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/course.rb b/app/models/course.rb index ec1afd611..143358abe 100644 --- a/app/models/course.rb +++ b/app/models/course.rb @@ -18,7 +18,7 @@ class Course < ActiveRecord::Base :conditions => "#{Principal.table_name}.type='Group' OR (#{Principal.table_name}.type='User' AND #{Principal.table_name}.status=#{Principal::STATUS_ACTIVE})" has_many :principals, :through => :member_principals, :source => :principal has_many :users, :through => :members - has_many :org_courses + has_many :org_courses, :dependent => :destroy has_many :organizations, :through => :org_courses # has_many :homeworks, :through => :homework_for_courses, :source => :bid, :dependent => :destroy has_many :journals_for_messages, :as => :jour, :dependent => :destroy diff --git a/app/models/organization.rb b/app/models/organization.rb index d3755b5ee..a35f68c26 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -5,7 +5,7 @@ class Organization < ActiveRecord::Base has_many :projects,:through => :org_projects has_many :courses, :through => :org_courses has_many :org_document_comments, :dependent => :destroy - has_many :org_courses + has_many :org_courses, :dependent => :destroy has_many :users, :through => :org_members validates_uniqueness_of :name after_create :save_as_org_activity From 2855c0e409e104d66ef612fb88056e117442e5c7 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 4 Dec 2015 10:59:09 +0800 Subject: [PATCH 08/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A1=B9=E7=9B=AE?= =?UTF-8?q?=E5=8A=A8=E6=80=81=EF=BC=8C=E4=BD=BF=E5=85=B6=E4=B8=8E=E8=AF=BE?= =?UTF-8?q?=E7=A8=8B=E5=8A=A8=E6=80=81=E5=8F=8A=E4=B8=AA=E4=BA=BA=E5=8A=A8?= =?UTF-8?q?=E6=80=81=E7=9A=84=E6=A0=B7=E5=BC=8F=E4=B8=80=E8=87=B4=EF=BC=8C?= =?UTF-8?q?=E5=8C=85=E6=8B=AC=E6=9C=89=E5=9B=9E=E5=A4=8D=E6=A1=86=E3=80=81?= =?UTF-8?q?=E8=BF=87=E6=BB=A4=E8=8F=9C=E5=8D=95=E3=80=81=E5=AE=BD=E5=BA=A6?= =?UTF-8?q?=E3=80=81=E9=97=B4=E8=B7=9D=E7=AD=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 5 + app/controllers/projects_controller.rb | 13 +- app/models/forge_activity.rb | 6 +- app/views/comments/create.js.erb | 5 +- app/views/layouts/base_projects.html.erb | 2 +- app/views/projects/_attachment_acts.html.erb | 35 +++++ .../projects/_project_activities.html.erb | 102 ++++++++++++ app/views/projects/_project_create.html.erb | 38 +++++ app/views/projects/_project_news.html.erb | 106 +++++++++++++ app/views/projects/show.html.erb | 145 ++++-------------- app/views/projects/show.js.erb | 1 + 11 files changed, 340 insertions(+), 118 deletions(-) create mode 100644 app/views/projects/_attachment_acts.html.erb create mode 100644 app/views/projects/_project_activities.html.erb create mode 100644 app/views/projects/_project_create.html.erb create mode 100644 app/views/projects/_project_news.html.erb create mode 100644 app/views/projects/show.js.erb diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 9b090de9a..6f173b7c2 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -169,6 +169,11 @@ class MessagesController < ApplicationController course_activity.updated_at = Time.now course_activity.save end + forge_activity = ForgeActivity.where("forge_act_type='Message' and forge_act_id=#{@topic.id}").first + if forge_activity + forge_activity.updated_at = Time.now + forge_activity.save + end user_activity = UserActivity.where("act_type='Message' and act_id =#{@topic.id}").first if user_activity user_activity.updated_at = Time.now diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 715f56d3d..200bd4d69 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -320,9 +320,20 @@ class ProjectsController < ApplicationController @activity.scope_select {|t| !has["show_#{t}"].nil?} =end + @page = params[:page] ? params[:page].to_i + 1 : 0 # 根据私密性,取出符合条件的所有数据 if User.current.member_of?(@project) || User.current.admin? - @events_pages = ForgeActivity.where("project_id = ? and forge_act_type != ?",@project, "Document" ).order("created_at desc").page(params['page'|| 1]).per(20); + case params[:type] + when nil + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type in ('Issue', 'Message','News', 'ProjectCreateInfo')",@project).order("updated_at desc").limit(10).offset(@page * 10) + when 'issue' + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Issue'",@project).order("updated_at desc").limit(10).offset(@page * 10) + when 'news' + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'News'",@project).order("updated_at desc").limit(10).offset(@page * 10) + when 'message' + @events_pages = ForgeActivity.where("project_id = ? and forge_act_type = 'Message'",@project).order("updated_at desc").limit(10).offset(@page * 10) + end + #events = @activity.events(@date_from, @date_to) else @events_pages = ForgeActivity.includes(:project).where("forge_activities.project_id = ? and projects.is_public diff --git a/app/models/forge_activity.rb b/app/models/forge_activity.rb index bb5f30442..115575289 100644 --- a/app/models/forge_activity.rb +++ b/app/models/forge_activity.rb @@ -48,8 +48,10 @@ class ForgeActivity < ActiveRecord::Base def add_org_activity if self.forge_act_type == 'Message' && !self.forge_act.parent_id.nil? org_activity = OrgActivity.where("org_act_type = 'Message' and org_act_id = #{self.forge_act.parent.id}").first - org_activity.created_at = self.created_at - org_activity.save + if org_activity + org_activity.created_at = self.created_at + org_activity.save + end else OrgActivity.create(:user_id => self.user_id, :org_act_id => self.forge_act_id, diff --git a/app/views/comments/create.js.erb b/app/views/comments/create.js.erb index ea904a63f..b0354b53f 100644 --- a/app/views/comments/create.js.erb +++ b/app/views/comments/create.js.erb @@ -1,3 +1,6 @@ +<% if @course %> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); - +<% else %> +$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'projects/project_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id}) %>"); +<% end %> init_activity_KindEditor_data('<%= @user_activity_id%>',"","87%"); diff --git a/app/views/layouts/base_projects.html.erb b/app/views/layouts/base_projects.html.erb index 9e9bd688f..1d68c9fa0 100644 --- a/app/views/layouts/base_projects.html.erb +++ b/app/views/layouts/base_projects.html.erb @@ -12,7 +12,7 @@ <%= favicon %> <%= javascript_heads %> <%= heads_for_theme %> - <%= stylesheet_link_tag 'public', 'pleft', 'project','prettify','jquery/jquery-ui-1.9.2','header','repository' %> + <%= stylesheet_link_tag 'public', 'pleft', 'project','courses','prettify','jquery/jquery-ui-1.9.2','header','repository' %> <%= javascript_include_tag 'cookie','project', 'header','prettify','select_list_move','attachments' %> <%= call_hook :view_layouts_base_html_head %> diff --git a/app/views/projects/_attachment_acts.html.erb b/app/views/projects/_attachment_acts.html.erb new file mode 100644 index 000000000..2baa8791a --- /dev/null +++ b/app/views/projects/_attachment_acts.html.erb @@ -0,0 +1,35 @@ +
    +
    +
    + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> +
    +
    +
    + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% end %> TO + <%= link_to activity.project.name.to_s+" | 项目附件", project_news_index_path(activity.project), :class => "newsBlue ml15" %> +
    + +
    +
    + 发布时间:<%= format_time(activity.created_on) %> +
    +

    <%= textAreailizable act, :description %>

    +
    +
    + <%#= activity.description.html_safe %> +
    +
    +
    + +
    +
    +
    + +
    \ No newline at end of file diff --git a/app/views/projects/_project_activities.html.erb b/app/views/projects/_project_activities.html.erb new file mode 100644 index 000000000..f97646d3c --- /dev/null +++ b/app/views/projects/_project_activities.html.erb @@ -0,0 +1,102 @@ +<%= javascript_include_tag "/assets/kindeditor/kindeditor", '/assets/kindeditor/pasteimg', "init_activity_KindEditor" %> + +<% unless forge_acts.empty? %> + <% forge_acts.each do |activity| -%> + + + <% case activity.forge_act_type %> + <% when "ProjectCreateInfo" %> + <%= render :partial => 'projects/project_create', :locals => {:activity => activity, :user_activity_id => activity.id} %> + + <% when "Issue" %> + <%= render :partial => 'users/project_issue', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id} %> + + + <% when "Message" %> + <%= render :partial => 'users/project_message', :locals => {:activity => activity.forge_act,:user_activity_id =>activity.id} %> + + <% when "News" %> + <% if !activity.forge_act.nil? and activity.forge_act.project %> + <%= render :partial => 'projects/project_news', :locals => {:activity=>activity.forge_act, :user_activity_id=>activity.id} %> + <% end %> + + <% when "Attachment" %> + <%= render :partial => 'projects/attachment_acts', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id } %> + + + + + + + + + <%#= link_to format_activity_title("#{l(:label_attachment)}: #{act.filename}"), {:controller => 'attachments', :action => 'show', :id => act.id}, :class => "problem_tit fl fb" %> + + + + + + + + + <% end %> + <% end %> +<% end %> + +<% if forge_acts.count == 10 %> +
    展开更多<%= link_to "", project_path(@project.id, :type => type, :page => page), :id => "more_forge_activities_link", :remote => "true", :class => "none" %>
    +<% end %> + + \ No newline at end of file diff --git a/app/views/projects/_project_create.html.erb b/app/views/projects/_project_create.html.erb new file mode 100644 index 000000000..d966d8e18 --- /dev/null +++ b/app/views/projects/_project_create.html.erb @@ -0,0 +1,38 @@ +<% project = Project.find(activity.project_id) %> +<% user = User.find(project.user_id)%> +
    +
    +
    + <%= link_to image_tag(url_to_avatar(user), :width => "50", :height => "50"), user_path(user), :alt => "用户头像" %> +
    +
    +
    + <% if user.try(:realname) == ' ' %> + <%= link_to user, user_path(user), :class => "newsBlue mr15" %> + <% else %> + <%= link_to user.try(:realname), user_path(user), :class => "newsBlue mr15" %> + <% end %> + TO + <%= link_to project.to_s+" | 项目", project_path(project.id,:host=>Setting.host_course), :class => "newsBlue ml15" %> +
    +
    + <%= link_to project.name, project_path(project.id,:host=>Setting.host_course), :class => "postGrey" %> +
    +
    + 创建时间:<%= format_time(project.created_on) %> +
    + +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/projects/_project_news.html.erb b/app/views/projects/_project_news.html.erb new file mode 100644 index 000000000..919abc11e --- /dev/null +++ b/app/views/projects/_project_news.html.erb @@ -0,0 +1,106 @@ +
    +
    +
    + <%= link_to image_tag(url_to_avatar(activity.author), :width => "50", :height => "50"), user_path(activity.author_id), :alt => "用户头像" %> +
    +
    +
    + <% if activity.try(:author).try(:realname) == ' ' %> + <%= link_to activity.try(:author), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% else %> + <%= link_to activity.try(:author).try(:realname), user_path(activity.author_id), :class => "newsBlue mr15" %> + <% end %> TO + <%= link_to activity.project.name.to_s+" | 项目新闻", project_news_index_path(activity.project), :class => "newsBlue ml15" %> +
    + + <% if activity.sticky == 1%> + 置顶 + <% end%> +
    +
    + 发布时间:<%= format_time(activity.created_on) %> +
    +
    +
    + <%= activity.description.html_safe %> +
    +
    +
    + + +
    +
    +
    +
    + <% count=activity.comments.count %> +
    +
    +
    +
    + 回复(<%= count %>) +
    +
    <%#= format_date(activity.updated_on) %>
    + <%if count>3 %> + + <% end %> +
    + + <% replies_all_i = 0 %> + <% if count > 0 %> +
    +
      + <% activity.comments.reorder("created_on desc").each do |comment| %> + + <% replies_all_i = replies_all_i + 1 %> +
    • +
      + <%= link_to image_tag(url_to_avatar(comment.author), :width => "33", :height => "33"), user_path(comment.author_id), :alt => "用户头像" %> +
      +
      +
      + <% if comment.try(:author).try(:realname) == ' ' %> + <%= link_to comment.try(:author), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to comment.try(:author).try(:realname), user_path(comment.author_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(comment.created_on) %> +
      +
      + <%= comment.comments.html_safe %>
      +
      +
      +
    • + <% end %> +
    +
    + <% end %> + +
    +
    <%= link_to image_tag(url_to_avatar(User.current), :width => "33", :height => "33"), user_path(activity.author_id), :alt => "用户头像" %>
    +
    +
    + <%= form_for('new_form',:url => {:controller => 'comments', :action => 'create', :id => activity},:method => "post", :remote => true) do |f|%> + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    +
    +
    \ No newline at end of file diff --git a/app/views/projects/show.html.erb b/app/views/projects/show.html.erb index a3a2845f8..a58aeb281 100644 --- a/app/views/projects/show.html.erb +++ b/app/views/projects/show.html.erb @@ -1,114 +1,33 @@ -<%= javascript_include_tag "jquery.infinitescroll.js" %> -
    -

    <%= l(:label_activity) %>

    -
    - -<% unless @events_pages.empty? %> - <% @events_pages.each do |e| -%> - - <% if e.forge_act_type == "ProjectCreateInfo"%> -
    - <%= image_tag(url_to_avatar(e.user), :width => "42", :height => "42") %> -
    - <%= link_to e.user, user_path(e.user), :class => "problem_name c_orange fl" %> <%= l(:label_project_create) %> : - <%= link_to e.project.name,{} ,:class => "problem_tit fl fb" %>
    -


    <%= l :label_create_time %> :<%= format_time(e.project.created_on) %>

    -
    -
    -
    - <% end %> - <% next if e.forge_act_type.safe_constantize.nil? - act = e.forge_act; - next if act.nil? %> - - <% if e.forge_act_type == "Issue" %> - - - <% elsif e.forge_act_type == "Journal" %> - - - <% elsif e.forge_act_type == "Message" %> -
    - <%= image_tag(url_to_avatar(e.user), :width => "42", :height => "42") %> -
    - - <%= h(e.project) if @project.nil? || @project.id != e.project_id %> - <%= link_to h(e.user), user_path(e.user_id), :class => "problem_name c_orange fl" %> <%= l(:label_new_activity) %> : +<%#= stylesheet_link_tag 'courses' %> + + +
    +
    +
    项目动态
    +
      +
    • +
        +
      • +
          +
        • <%= link_to "全部动态", {:controller => "projects", :action => "show", :type => nil}, :class => "homepagePostTypeAll postTypeGrey" %>
        • +
        • <%= link_to "问题动态", {:controller => "projects", :action => "show", :type => "issue"}, :class => "homepagePostTypeMessage postTypeGrey" %>
        • + +
        • <%= link_to "新闻动态", {:controller => "projects", :action => "show", :type => "news"}, :class => "homepagePostTypeNotice postTypeGrey" %>
        • + +
        • <%= link_to "讨论区动态", {:controller => "projects", :action => "show", :type => "message"}, :class => "homepagePostTypeForum postTypeGrey" %>
        • + +
        +
      • +
      +
    • +
    + - <%= link_to format_activity_title("#{act.board.name}: #{act.subject}"), - project_boards_path(@project,:topic_id => act.id), - :class => "problem_tit fl fb " %> -
    -

    <%= textAreailizable act,:content %>
    -

    - <%= l :label_create_time %> :<%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %>

    -
    -
    -
    - - <% elsif e.forge_act_type == "News" %> - - - - <% elsif e.forge_act_type == "Attachment" %> -
    - <%= image_tag(url_to_avatar(e.user), :width => "42", :height => "42") %> -
    - - <%= h(e.project) if @project.nil? || @project.id != e.project_id %> - <%= link_to h(e.user), user_path(e.user_id), :class => "problem_name c_orange fl" %> <%= l(:label_new_activity) %> : - <%= link_to format_activity_title("#{l(:label_attachment)}: #{act.filename}"), {:controller => 'attachments', :action => 'show', :id => act.id}, :class => "problem_tit fl fb" %>
    -

    <%= textAreailizable act,:description %>
    - <%= l :label_create_time %> :<%= format_activity_day(act.created_on) %> <%= format_time(act.created_on, false) %>

    -
    -
    -
    - <% end %> - <% end %> -<% end %> -<%= paginate @events_pages, :left => 3, :right => 3 %> +
    + <%= render :partial => "project_activities", :locals => {:forge_acts => @events_pages, :page => 0, :type => @type} %> +
    \ No newline at end of file diff --git a/app/views/projects/show.js.erb b/app/views/projects/show.js.erb new file mode 100644 index 000000000..384c111d1 --- /dev/null +++ b/app/views/projects/show.js.erb @@ -0,0 +1 @@ +$("#show_more_forge_activities").replaceWith("<%= escape_javascript( render :partial => 'projects/project_activities',:locals => {:forge_acts => @events_pages, :page => @page,:type => @type} )%>"); From ab4d0e46785d92818b0f5771426d72f3f7787b4d Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 4 Dec 2015 17:34:48 +0800 Subject: [PATCH 09/15] =?UTF-8?q?=E7=BB=84=E7=BB=87=E7=95=8C=E9=9D=A2?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=88=86=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../javascripts/org_subfields.js.coffee | 3 + app/assets/stylesheets/org_subfields.css.scss | 3 + app/controllers/org_subfields_controller.rb | 19 ++++++ app/helpers/org_subfields_helper.rb | 2 + app/models/org_subfield.rb | 3 + app/models/organization.rb | 1 + app/views/layouts/base_org.html.erb | 55 +---------------- app/views/org_subfields/create.js.erb | 4 ++ app/views/org_subfields/destroy.js.erb | 4 ++ app/views/org_subfields/update.js.erb | 1 + .../_org_left_subfield_list.html.erb | 60 +++++++++++++++++++ .../organizations/_subfield_list.html.erb | 51 ++++++++++++++++ app/views/organizations/setting.html.erb | 27 ++++++++- config/routes.rb | 4 ++ .../20151204030143_create_org_subfields.rb | 13 ++++ public/stylesheets/org.css | 12 +++- .../org_subfields_controller_spec.rb | 5 ++ 17 files changed, 211 insertions(+), 56 deletions(-) create mode 100644 app/assets/javascripts/org_subfields.js.coffee create mode 100644 app/assets/stylesheets/org_subfields.css.scss create mode 100644 app/controllers/org_subfields_controller.rb create mode 100644 app/helpers/org_subfields_helper.rb create mode 100644 app/models/org_subfield.rb create mode 100644 app/views/org_subfields/create.js.erb create mode 100644 app/views/org_subfields/destroy.js.erb create mode 100644 app/views/org_subfields/update.js.erb create mode 100644 app/views/organizations/_org_left_subfield_list.html.erb create mode 100644 app/views/organizations/_subfield_list.html.erb create mode 100644 db/migrate/20151204030143_create_org_subfields.rb create mode 100644 spec/controllers/org_subfields_controller_spec.rb diff --git a/app/assets/javascripts/org_subfields.js.coffee b/app/assets/javascripts/org_subfields.js.coffee new file mode 100644 index 000000000..761567942 --- /dev/null +++ b/app/assets/javascripts/org_subfields.js.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ diff --git a/app/assets/stylesheets/org_subfields.css.scss b/app/assets/stylesheets/org_subfields.css.scss new file mode 100644 index 000000000..19263385e --- /dev/null +++ b/app/assets/stylesheets/org_subfields.css.scss @@ -0,0 +1,3 @@ +// Place all the styles related to the org_subfields controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb new file mode 100644 index 000000000..da20b6fcf --- /dev/null +++ b/app/controllers/org_subfields_controller.rb @@ -0,0 +1,19 @@ +class OrgSubfieldsController < ApplicationController + def create + @subfield = OrgSubfield.create(:name => params[:name]) + @organization = Organization.find(params[:organization_id]) + @organization.org_subfields << @subfield + @subfield.update_attributes(:priority => @subfield.id) + end + + def destroy + @subfield = OrgSubfield.find(params[:id]) + @organization = Organization.find(@subfield.organization_id) + @subfield.destroy + end + + def update + @subfield = OrgSubfield.find(params[:id]) + @subfield.update_attributes(:name => params[:name]) + end +end diff --git a/app/helpers/org_subfields_helper.rb b/app/helpers/org_subfields_helper.rb new file mode 100644 index 000000000..a9f8a396f --- /dev/null +++ b/app/helpers/org_subfields_helper.rb @@ -0,0 +1,2 @@ +module OrgSubfieldsHelper +end diff --git a/app/models/org_subfield.rb b/app/models/org_subfield.rb new file mode 100644 index 000000000..1660310f8 --- /dev/null +++ b/app/models/org_subfield.rb @@ -0,0 +1,3 @@ +class OrgSubfield < ActiveRecord::Base + belongs_to :organization, :foreign_key => :organization_id +end \ No newline at end of file diff --git a/app/models/organization.rb b/app/models/organization.rb index a35f68c26..350dc3080 100644 --- a/app/models/organization.rb +++ b/app/models/organization.rb @@ -6,6 +6,7 @@ class Organization < ActiveRecord::Base has_many :courses, :through => :org_courses has_many :org_document_comments, :dependent => :destroy has_many :org_courses, :dependent => :destroy + has_many :org_subfields, :dependent => :destroy has_many :users, :through => :org_members validates_uniqueness_of :name after_create :save_as_org_activity diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index b071a7c3b..aa46c35ee 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -81,59 +81,8 @@ <%= link_to '成员', members_organization_path(@organization.id) %> (<%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %>)
    -
    -
    - <%= link_to "动态",organization_path(@organization), :class => "homepageMenuText" %> -
    -
    - 项目 - <%=link_to "", join_project_menu_organization_path(@organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> - - - - - - - - - - - - - -
    -
    -
      - <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>@organization.projects.reorder('created_at').uniq.limit(5),:org_id=>@organization.id,:page=>1}%> - - - - -
    -
    -
    - 课程 - <%=link_to "", join_course_menu_organization_path(@organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> - <%#= link_to "关联课程",join_course_menu_organization_path(@organization),:remote => true,:class => "menuGrey",:method => "post"%> - - - - - - - - - - - - - -
    -
    -
      - <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>@organization.courses.reorder('created_at').uniq.limit(5),:org_id=>@organization.id,:page=>1}%> -
    -
    +
    + <%= render :partial => "organizations/org_left_subfield_list", :locals => {:organization => @organization} %>
    diff --git a/app/views/org_subfields/create.js.erb b/app/views/org_subfields/create.js.erb new file mode 100644 index 000000000..8a676e93e --- /dev/null +++ b/app/views/org_subfields/create.js.erb @@ -0,0 +1,4 @@ +$("#org_subfield_list").html(""); +$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',:locals => {:subfields => @organization.org_subfields }) %>"); +$("#sub_field_left_lists").html(""); +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); \ No newline at end of file diff --git a/app/views/org_subfields/destroy.js.erb b/app/views/org_subfields/destroy.js.erb new file mode 100644 index 000000000..8a676e93e --- /dev/null +++ b/app/views/org_subfields/destroy.js.erb @@ -0,0 +1,4 @@ +$("#org_subfield_list").html(""); +$("#org_subfield_list").html("<%= escape_javascript(render :partial => 'organizations/subfield_list',:locals => {:subfields => @organization.org_subfields }) %>"); +$("#sub_field_left_lists").html(""); +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); \ No newline at end of file diff --git a/app/views/org_subfields/update.js.erb b/app/views/org_subfields/update.js.erb new file mode 100644 index 000000000..2def5c5f8 --- /dev/null +++ b/app/views/org_subfields/update.js.erb @@ -0,0 +1 @@ +$("#subfield_show_<%= @subfield.id %>").html("<%= @subfield.name %>"); \ 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 new file mode 100644 index 000000000..7c30aa600 --- /dev/null +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -0,0 +1,60 @@ +
    + <%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %> +
    +
    + 项目 + <%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> + + + + + + + + + + + + + +
    +
    +
      + <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> + + + + +
    +
    +
    + 课程 + <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> + <%#= link_to "关联课程",join_course_menu_organization_path(organization),:remote => true,:class => "menuGrey",:method => "post"%> + + + + + + + + + + + + + +
    +
    +
      + <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> +
    +
    +<% organization.org_subfields.each do |field| %> +
    + <%= field.name %> + <%=link_to "", :title => "关联#{field.name}"%> +
    +
    +
    +<% 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 new file mode 100644 index 000000000..f148fc561 --- /dev/null +++ b/app/views/organizations/_subfield_list.html.erb @@ -0,0 +1,51 @@ + +
      +
    • 已有栏目
    • +
    • 状态
    • +
      +
    +
      +
    • 动态
    • +
    • 默认
    • +
      +
    +
      +
    • 项目
    • +
    • 默认
    • +
      +
    +
      +
    • 课程
    • +
    • 默认
    • +
      +
    + <% subfields.each do |field| %> +
      +
    • <%= field.name %>
    • +
    • 新增
    • + <%= link_to "删除",org_subfield_path(field), :method => 'delete',:remote => true, :confirm => "您确定删除吗?", :class => "linkBlue fr mr5" %> + 编辑 +
      +
    + <% end %> + + \ No newline at end of file diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index 96fef706a..138a7993a 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -2,7 +2,7 @@ function g(o){return document.getElementById(o);} function HoverLi(n){ //如果有N个标签,就将i<=N; - for(var i=1;i<=2;i++){ + for(var i=1;i<=3;i++){ g('orgSetting_'+i).className='orgSettingOp'; g('orgContent_'+i).className='undis';} g('orgContent_'+n).className='dis ml15 mr15'; @@ -34,6 +34,7 @@
    • 信息
    • 成员
    • +
    • 分栏
    @@ -104,4 +105,26 @@
    -
\ No newline at end of file +
+
+ <%= render :partial => 'organizations/subfield_list', :locals => {:subfields => @organization.org_subfields } %> +
+
+
+

新增栏目

+ <%= form_tag url_for(:controller => 'org_subfields', :action => 'create', :organization_id => @organization.id), :id=> 'add_subfield_form',:remote => true do %> + +
+ 确定 + <% end %> +
+
+
+
+
+ \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index bb6d7b940..27e9d7861 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -70,6 +70,10 @@ RedmineApp::Application.routes.draw do end end + resources :org_subfields do + + end + resources :org_document_comments do member do post 'add_reply' diff --git a/db/migrate/20151204030143_create_org_subfields.rb b/db/migrate/20151204030143_create_org_subfields.rb new file mode 100644 index 000000000..2727cdef0 --- /dev/null +++ b/db/migrate/20151204030143_create_org_subfields.rb @@ -0,0 +1,13 @@ +class CreateOrgSubfields < ActiveRecord::Migration + def up + create_table :org_subfields do |t| + t.integer :organization_id + t.integer :priority + t.string :name + t.timestamps + end + end + + def down + end +end diff --git a/public/stylesheets/org.css b/public/stylesheets/org.css index a0118b263..897eb8734 100644 --- a/public/stylesheets/org.css +++ b/public/stylesheets/org.css @@ -54,4 +54,14 @@ a.cancelBtn:hover {background-color:#717171; color:#ffffff;} /*关联项目弹窗*/ .projectRelate {float:left; max-height:118px;margin-right:16px;margin-bottom:10px; overflow:auto; overflow-x:hidden; width:288px;} -.relateText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; display:inline-block; font-weight: bold;} \ No newline at end of file +.relateText {font-size:16px; color:#269ac9; line-height:16px; padding-top:20px; display:inline-block; font-weight: bold;} + +/*组织首页新151204Tim*/ +.orgNav {width:1000px; height:30px; background-color:#cfcfcf; margin:0 auto;} +.orgContainer {width:100%; margin:0 auto; background-color:#cfcfcf;} +.navOrgLogo {width:21px; height:30px; margin-left:2px; margin-right:15px;} +.navOrgMenu {display:inline-block;height:30px; line-height:30px; vertical-align:middle;} +a.linkGrey8 {color:#888888;} +a.linkGrey8:hover {color:#585858;} +.orgBorder {width:583px; height:21px; border-bottom:3px solid #e4e4e4; float:left;} +.orgListRow {border-bottom:1px solid #e4e4e4; padding-bottom:5px; color:#555555;} \ No newline at end of file diff --git a/spec/controllers/org_subfields_controller_spec.rb b/spec/controllers/org_subfields_controller_spec.rb new file mode 100644 index 000000000..4bc89dae0 --- /dev/null +++ b/spec/controllers/org_subfields_controller_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe OrgSubfieldsController, :type => :controller do + +end From 5b0bdb5069f7f5c4faae4853187890ae1545da5c Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Fri, 4 Dec 2015 18:19:35 +0800 Subject: [PATCH 10/15] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E6=A0=8F=E7=9B=AE=E7=9A=84=E5=86=85=E5=AE=B9=E5=8F=8A=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../organizations/_org_left_subfield_list.html.erb | 4 ++-- app/views/organizations/_subfield_list.html.erb | 11 ++++++++--- app/views/organizations/setting.html.erb | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/views/organizations/_org_left_subfield_list.html.erb b/app/views/organizations/_org_left_subfield_list.html.erb index 7c30aa600..52201fd52 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -45,7 +45,7 @@ -
+
    <%= render :partial => 'layouts/org_courses',:locals=>{:courses=>organization.courses.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%>
@@ -55,6 +55,6 @@ <%= field.name %> <%=link_to "", :title => "关联#{field.name}"%>
-
+ <% 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 f148fc561..6ba60245a 100644 --- a/app/views/organizations/_subfield_list.html.erb +++ b/app/views/organizations/_subfield_list.html.erb @@ -34,7 +34,12 @@ function edit(show_id, edit_id){ $(show_id).toggle(); $(edit_id).toggle(); - $(edit_id).focus(); + $(edit_id).find('input').focus(); + $(edit_id).find('input').on('keypress',function(e){ + if(e.keyCode == 13){ + this.blur(); + } + }) } function update_subfield(show_id, edit_id, field_id, input_value) { if ($(show_id).html().trim() != input_value.trim()) { @@ -44,8 +49,8 @@ type :'put' }); } - $(show_id).show(); - $(edit_id).hide(); + $(show_id).show(); + $(edit_id).hide(); // $(edit_id).focus(); } \ No newline at end of file diff --git a/app/views/organizations/setting.html.erb b/app/views/organizations/setting.html.erb index 138a7993a..e0f262b99 100644 --- a/app/views/organizations/setting.html.erb +++ b/app/views/organizations/setting.html.erb @@ -34,7 +34,7 @@
  • 信息
  • 成员
  • -
  • 分栏
  • +
  • 栏目
From 01b82e59d80d0ad3e5cf1381b68f8f2e5b682bef Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Sat, 5 Dec 2015 11:30:05 +0800 Subject: [PATCH 11/15] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/org_subfields_controller.rb | 1 + app/controllers/organizations_controller.rb | 13 +- app/views/layouts/base_organization.html.erb | 113 ++++++++++++++++++ app/views/org_subfields/update.js.erb | 4 +- .../_org_left_subfield_list.html.erb | 34 +----- app/views/organizations/show.html.erb | 4 +- public/images/home_logo.png | Bin 0 -> 1213 bytes 7 files changed, 134 insertions(+), 35 deletions(-) create mode 100644 app/views/layouts/base_organization.html.erb create mode 100644 public/images/home_logo.png diff --git a/app/controllers/org_subfields_controller.rb b/app/controllers/org_subfields_controller.rb index da20b6fcf..6fdf0ae40 100644 --- a/app/controllers/org_subfields_controller.rb +++ b/app/controllers/org_subfields_controller.rb @@ -14,6 +14,7 @@ class OrgSubfieldsController < ApplicationController def update @subfield = OrgSubfield.find(params[:id]) + @organization = Organization.find(@subfield.organization_id) @subfield.update_attributes(:name => params[:name]) end end diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index 85f57917b..47a0930a5 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -94,7 +94,11 @@ class OrganizationsController < ApplicationController end @page = params[:page] respond_to do |format| - format.html + format.html { + if !params[:show_homepage].nil? + render :layout => 'base_organization' + end + } format.js end else @@ -102,6 +106,13 @@ class OrganizationsController < ApplicationController end end + def homepage + @organization = Organization.find(params[:id]) + respond_to do |format| + format.html {render :layout => 'base_organization'} + end + end + def update @organization = Organization.find(params[:id]) @organization.name = params[:organization][:name] diff --git a/app/views/layouts/base_organization.html.erb b/app/views/layouts/base_organization.html.erb new file mode 100644 index 000000000..653708bab --- /dev/null +++ b/app/views/layouts/base_organization.html.erb @@ -0,0 +1,113 @@ + + +<%= stylesheet_link_tag 'pleft','prettify','jquery/jquery-ui-1.9.2','header','new_user','repository','org' %> +<%= javascript_include_tag 'cookie','project', 'header','prettify','select_list_move','org'%> + + + 课程主页 + + + + + + + + + +
+
+ + + +
+
+
+
+
+
+ + + +
+ <%= link_to @organization.name, organization_path(@organization.id), :class=>"pr_info_name fl c_dark fb break_word" %> + <% if @organization.is_public? %> + <%= l(:label_public)%> + <% else %> + <%= l(:label_private)%> + <% end %> +
+ + <% if User.current.admin_of_org?(@organization) and params[:show_homepage].nil? %> + 配置 + <% end %> + +
+
+ <%= link_to '文章', organization_org_document_comments_path(@organization) %> ( + <%= link_to OrgDocumentComment.where("organization_id =? and parent_id is null", @organization.id).count, organization_org_document_comments_path(@organization), :class => "linkBlue" %> + ) |  + <%= link_to '成员', members_organization_path(@organization.id) %> (<%= link_to @organization.org_members.count, members_organization_path(@organization.id), :id => 'org_members_count_id', :class => "linkBlue" %>) +
+
+
+ <%= render :partial => "organizations/org_left_subfield_list", :locals => {:organization => @organization} %> +
+
+
+ <%= render_flash_messages %> + <%= yield %> + <%= call_hook :view_layouts_base_content %> +
+
+
+
+
+ + + diff --git a/app/views/org_subfields/update.js.erb b/app/views/org_subfields/update.js.erb index 2def5c5f8..06982ccfc 100644 --- a/app/views/org_subfields/update.js.erb +++ b/app/views/org_subfields/update.js.erb @@ -1 +1,3 @@ -$("#subfield_show_<%= @subfield.id %>").html("<%= @subfield.name %>"); \ No newline at end of file +$("#subfield_show_<%= @subfield.id %>").html("<%= @subfield.name %>"); +$("#sub_field_left_lists").html(""); +$("#sub_field_left_lists").html("<%= escape_javascript(render :partial => 'organizations/org_left_subfield_list', :locals => {:organization => @organization}) %>"); \ 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 52201fd52..3bfabf5ae 100644 --- a/app/views/organizations/_org_left_subfield_list.html.erb +++ b/app/views/organizations/_org_left_subfield_list.html.erb @@ -1,49 +1,21 @@ +
+ <%= link_to "组织首页",organization_path(@organization, :show_homepage => 1), :class => 'homepageMenuText', :target => '_blank' %> +
<%= link_to "动态",organization_path(organization), :class => "homepageMenuText" %>
项目 <%=link_to "", join_project_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联项目"%> - - - - - - - - - - - - -
    <%= render :partial => 'layouts/org_projects',:locals=>{:projects=>organization.projects.reorder('created_at').uniq.limit(5),:org_id=>organization.id,:page=>1}%> - - - -
课程 <%=link_to "", join_course_menu_organization_path(organization),:remote => true, :method => "post", :class => "homepageMenuSetting fr", :title => "关联课程"%> - <%#= link_to "关联课程",join_course_menu_organization_path(organization),:remote => true,:class => "menuGrey",:method => "post"%> - - - - - - - - - - - - -
    diff --git a/app/views/organizations/show.html.erb b/app/views/organizations/show.html.erb index 9e0fc365c..9ee9d11c0 100644 --- a/app/views/organizations/show.html.erb +++ b/app/views/organizations/show.html.erb @@ -12,6 +12,7 @@ .homepagePostReplyInputContainer .ke-inline-block {display: none;} .homepagePostReplyInputContainer .ke-container {float: left;} +<% if params[:show_homepage].nil? %>
    最新动态
      @@ -49,9 +50,8 @@
-
- +<% end %> <% if !@organization.home_id.nil? and OrgDocumentComment.where("id = ?", @organization.home_id).count > 0 %>