From 77e0f0cd08f331109505ca2dd6d77bf7766a6452 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 29 Dec 2015 15:49:24 +0800 Subject: [PATCH 01/10] =?UTF-8?q?=E8=BD=AC=E5=8F=91=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E6=96=B0=E5=BB=BA=E5=B8=96=E5=AD=90=EF=BC=8C=E5=B9=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=9B=B8=E5=85=B3=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 21 +++++++++++++------ app/views/layouts/base_org.html.erb | 2 +- .../20151229022049_add_quotes_to_messages.rb | 5 +++++ db/schema.rb | 3 ++- 4 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 db/migrate/20151229022049_add_quotes_to_messages.rb diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index b9fe14aba..f4ad88757 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -316,13 +316,22 @@ class MessagesController < ApplicationController # @message.update_attribute(:updated_on, Time.now) type = @message.board.course_id.nil? ? "Project":"Course" org_subfield_ids.each do |field_id| - OrgSubfieldMessage.create(:org_subfield_id => field_id.to_i, :message_id => @message.id, :message_type => type) - org_acts = OrgActivity.where("container_type='OrgSubfield' and container_id=? and org_act_type='Message' and org_act_id=?", field_id.to_i, @message.id) - if org_acts.all.size() > 0 - org_acts.first.update_attribute(:updated_at, Time.now) - else - OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'Message', :org_act_id => @message.id, :user_id => User.current.id) + @message.quotes = @message.quotes.nil? ? 1 : (@message.quotes + 1) + @message.save + mes = Message.create(:board_id => @message.board_id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id, + :created_on => Time.now, :updated_on => Time.now, :locked => @message.locked, :sticky => @message.sticky) + @message.attachments.each do |attach| + mes.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, + :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, + :is_public => attach.is_public, :quotes => 0) end + OrgSubfieldMessage.create(:org_subfield_id => field_id.to_i, :message_id => mes.id, :message_type => type) + # org_acts = OrgActivity.where("container_type='OrgSubfield' and container_id=? and org_act_type='Message' and org_act_id=?", field_id.to_i, @message.id) + # if org_acts.all.size() > 0 + # org_acts.first.update_attribute(:updated_at, Time.now) + # else + OrgActivity.create(:container_type => 'OrgSubfield', :container_id => field_id.to_i, :org_act_type=>'Message', :org_act_id => mes.id, :user_id => User.current.id) + # end end end diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index 4ece1ba8c..808e80239 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -161,7 +161,7 @@
diff --git a/db/migrate/20151229022049_add_quotes_to_messages.rb b/db/migrate/20151229022049_add_quotes_to_messages.rb new file mode 100644 index 000000000..6311f0231 --- /dev/null +++ b/db/migrate/20151229022049_add_quotes_to_messages.rb @@ -0,0 +1,5 @@ +class AddQuotesToMessages < ActiveRecord::Migration + def change + add_column :messages, :quotes, :integer + end +end diff --git a/db/schema.rb b/db/schema.rb index 6448833c6..72ca3c649 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 => 20151223062932) do +ActiveRecord::Schema.define(:version => 20151229022049) do create_table "activities", :force => true do |t| t.integer "act_id", :null => false @@ -1045,6 +1045,7 @@ ActiveRecord::Schema.define(:version => 20151223062932) do t.boolean "locked", :default => false t.integer "sticky", :default => 0 t.integer "reply_id" + t.integer "quotes" end add_index "messages", ["author_id"], :name => "index_messages_on_author_id" From dd88742b78a072aba63c016c96badeeba65876ed Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 29 Dec 2015 16:00:12 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E5=88=A4=E6=96=ADorg.org=5Fact=5Fid?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/_org_activities.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index 4e4ee3d4c..e7a4f6afa 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -50,7 +50,7 @@ <% end %> <% end %> <% if act.container_type == 'OrgSubfield' %> - <% if act.org_act_type == 'Message' %> + <% if act.org_act_type == 'Message' and act.org_act_id %> <% message = Message.find(act.org_act_id) %> <% if !message.board.course_id.nil? %> <%= render :partial => 'org_course_message', :locals => {:activity => message,:user_activity_id =>act.id} %> From 15cff47c9268f0389a0a7aa8fc215e5f7b897d0c Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Tue, 29 Dec 2015 17:13:48 +0800 Subject: [PATCH 03/10] =?UTF-8?q?1.=E8=BD=AC=E5=8F=91=E5=B8=96=E5=AD=90?= =?UTF-8?q?=E6=97=B6=EF=BC=8C=E5=BD=93=E7=BB=84=E7=BB=87=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E8=B5=84=E6=BA=90=E6=A0=8F=E7=9B=AE=E6=97=B6=EF=BC=8C=E7=BB=99?= =?UTF-8?q?=E5=87=BA=E6=8F=90=E7=A4=BA=EF=BC=9B=202.=E7=BB=84=E7=BB=87?= =?UTF-8?q?=E6=96=87=E7=AB=A0=E7=9A=84=E9=99=84=E4=BB=B6=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E5=9C=A8=E7=BB=84=E7=BB=87=E5=8A=A8=E6=80=81/=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E6=96=87=E7=AB=A0=E5=88=97=E8=A1=A8=E4=B8=AD=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/organizations_controller.rb | 2 +- app/views/messages/_show_org_subfields.html.erb | 12 ++++++++---- app/views/organizations/_show_org_document.html.erb | 3 +++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/app/controllers/organizations_controller.rb b/app/controllers/organizations_controller.rb index aba656750..466fbd8e3 100644 --- a/app/controllers/organizations_controller.rb +++ b/app/controllers/organizations_controller.rb @@ -14,7 +14,7 @@ class OrganizationsController < ApplicationController include PollHelper helper :user_score helper :journals - + helper :attachments # added by liuping 关注 helper :watchers diff --git a/app/views/messages/_show_org_subfields.html.erb b/app/views/messages/_show_org_subfields.html.erb index 659e1230e..cbd316ea4 100644 --- a/app/views/messages/_show_org_subfields.html.erb +++ b/app/views/messages/_show_org_subfields.html.erb @@ -2,10 +2,14 @@ <% if !org.nil? %> 组织:<%= org.name %> - <% org.org_subfields.where("field_type='Post'").each do |subfield| %> -
  • - -
  • + <% if org.org_subfields.where("field_type='Post'").count > 0 %> + <% org.org_subfields.where("field_type='Post'").each do |subfield| %> +
  • + +
  • + <% end %> + <% else %> +
  • 暂无资源栏目
  • <% end %> <% else %> 请在左侧选择组织 diff --git a/app/views/organizations/_show_org_document.html.erb b/app/views/organizations/_show_org_document.html.erb index 2b0f11cdd..25f6d5044 100644 --- a/app/views/organizations/_show_org_document.html.erb +++ b/app/views/organizations/_show_org_document.html.erb @@ -18,6 +18,9 @@ <%= document.content.html_safe %> <% end %> +
    + <%= link_to_attachments_course document, :author => false %> +
    From 887d2f9f00f554c09c1f24a579a2da638e9fff41 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 30 Dec 2015 13:14:32 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E6=B7=BB=E5=8A=A0micros=E5=92=8Cnubot?= =?UTF-8?q?=E7=9A=84=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/routes.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/routes.rb b/config/routes.rb index d82a9de8a..9fb56a2d4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -62,6 +62,9 @@ RedmineApp::Application.routes.draw do end end + get '/', to: 'organizations#show', defaults: { id: 5 }, constraints: {subdomain: 'micros'} + get '/', to: 'organizations#show', defaults: { id: 23 }, constraints: {subdomain: 'nubot'} + resources :org_member do member do From 941d6d09d57cf37ca59d059bd9ab5353771b8c43 Mon Sep 17 00:00:00 2001 From: guange <8863824@gmail.com> Date: Wed, 30 Dec 2015 13:18:30 +0800 Subject: [PATCH 05/10] =?UTF-8?q?=E6=9F=A5=E7=9C=8B=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E5=9C=A8firefox=E4=B8=AD=E6=98=BE=E7=A4=BA=E4=B8=8D=E4=BA=86?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/student_work/show.js.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/student_work/show.js.erb b/app/views/student_work/show.js.erb index 1a133a5d3..477f06e0f 100644 --- a/app/views/student_work/show.js.erb +++ b/app/views/student_work/show.js.erb @@ -25,7 +25,7 @@ else{ indentUnit: 2, matchBrackets: true, readOnly: true, - value: document.getElementById("work-src").innerText + value: $("#work-src").text() } ); From dcfe89c544edd943b344fe3060ced6f2f960ae41 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 30 Dec 2015 15:46:01 +0800 Subject: [PATCH 06/10] =?UTF-8?q?=E5=B8=96=E5=AD=90=E5=8F=91=E9=80=81?= =?UTF-8?q?=E5=88=B0=E7=BB=84=E7=BB=87=E8=B5=84=E6=BA=90=E6=A0=8F=E7=9B=AE?= =?UTF-8?q?=EF=BC=8C=E5=90=8C=E6=97=B6=E5=A2=9E=E5=8A=A0=E5=A2=9E=E5=88=A0?= =?UTF-8?q?=E6=9F=A5=E6=94=B9=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/messages_controller.rb | 43 +++- app/models/message.rb | 12 +- .../_org_subfield_message_edit.html.erb | 16 ++ app/views/boards/_org_subfield_new.html.erb | 74 +++++++ app/views/layouts/base_org.html.erb | 2 +- app/views/messages/_course_show.html.erb | 2 +- .../messages/_org_subfield_show.html.erb | 199 ++++++++++++++++++ app/views/messages/_project_show.html.erb | 2 +- app/views/messages/edit.html.erb | 12 ++ app/views/messages/reply.js.erb | 2 + app/views/messages/show.html.erb | 2 + .../organizations/_org_activities.html.erb | 6 +- .../_org_subfield_message.html.erb | 118 +++++++++++ .../org_subfield_message_edit.html.erb | 16 ++ config/routes.rb | 1 + public/javascripts/organization.js | 39 ++++ 16 files changed, 532 insertions(+), 14 deletions(-) create mode 100644 app/views/boards/_org_subfield_message_edit.html.erb create mode 100644 app/views/boards/_org_subfield_new.html.erb create mode 100644 app/views/messages/_org_subfield_show.html.erb create mode 100644 app/views/organizations/_org_subfield_message.html.erb create mode 100644 app/views/organizations/org_subfield_message_edit.html.erb create mode 100644 public/javascripts/organization.js diff --git a/app/controllers/messages_controller.rb b/app/controllers/messages_controller.rb index 543521e0f..ae13b7e78 100644 --- a/app/controllers/messages_controller.rb +++ b/app/controllers/messages_controller.rb @@ -75,7 +75,7 @@ class MessagesController < ApplicationController @replies = paginateHelper messages_replies,10 @reply = Message.new(:subject => "RE: #{@message.subject}") render :action => "show", :layout => "base_courses"#by young - else + elsif @project @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page @replies = @topic.children. includes(:author, :attachments, {:board => :project}). @@ -86,6 +86,18 @@ class MessagesController < ApplicationController @reply = Message.new(:subject => "RE: #{@message.subject}") render :action => "show", :layout => "base_projects"#by young + else + @reply_pages = Paginator.new @reply_count, REPLIES_PER_PAGE, page + @replies = @topic.children. + includes(:author, :attachments, {:board => :project}). + reorder("#{Message.table_name}.created_on DESC"). + limit(@reply_pages.per_page). + offset(@reply_pages.offset). + all + + @reply = Message.new(:subject => "RE: #{@message.subject}") + @organization = @org_subfield.organization + render :action => "show", :layout => "base_org"#by young end end @@ -248,7 +260,14 @@ class MessagesController < ApplicationController else respond_to do |format| format.html { - layout_file = @project ? 'base_projects' : 'base_courses' + if @project + layout_file = 'base_projects' + elsif @course + layout_file = 'base_courses' + elsif @org_subfield + @organization = @org_subfield.organization + layout_file = 'base_org' + end render :layout => layout_file } end @@ -287,6 +306,16 @@ class MessagesController < ApplicationController redirect_to course_board_url(@course, @board) end end + elsif @org_subfield + if params[:is_board] + redirect_to organization_path(:id => @org_subfield.organization_id, :org_subfield_id => @org_subfield.id) + else + if @message.parent + redirect_to board_message_url(@board, @message.parent, :r => r) + else + redirect_to organization_path(:id => @org_subfield.organization_id, :org_subfield_id => @org_subfield.id) + end + end end end @@ -319,18 +348,19 @@ class MessagesController < ApplicationController org_subfield_ids = params[:org_subfields] @message = Message.find(params[:id]) # @message.update_attribute(:updated_on, Time.now) - type = @message.board.course_id.nil? ? "Project":"Course" + # type = @message.board.course_id.nil? ? "Project":"Course" org_subfield_ids.each do |field_id| @message.quotes = @message.quotes.nil? ? 1 : (@message.quotes + 1) @message.save - mes = Message.create(:board_id => @message.board_id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id, + board = OrgSubfield.find(field_id).boards.first + mes = Message.create(:board_id => board.id, :subject => @message.subject, :content => @message.content, :author_id => User.current.id, :created_on => Time.now, :updated_on => Time.now, :locked => @message.locked, :sticky => @message.sticky) @message.attachments.each do |attach| mes.attachments << Attachment.new(:filename => attach.filename, :disk_filename => attach.disk_filename, :filesize => attach.filesize, :content_type => attach.content_type, :digest => attach.digest, :downloads => 0, :author_id => User.current.id, :created_on => Time.now, :description => attach.description, :disk_directory => attach.disk_directory, :attachtype => attach.attachtype, :is_public => attach.is_public, :quotes => 0) end - OrgSubfieldMessage.create(:org_subfield_id => field_id.to_i, :message_id => mes.id, :message_type => type) + # OrgSubfieldMessage.create(:org_subfield_id => field_id.to_i, :message_id => mes.id, :message_type => type) # org_acts = OrgActivity.where("container_type='OrgSubfield' and container_id=? and org_act_type='Message' and org_act_id=?", field_id.to_i, @message.id) # if org_acts.all.size() > 0 # org_acts.first.update_attribute(:updated_at, Time.now) @@ -356,6 +386,9 @@ class MessagesController < ApplicationController @project = @board.project elsif @board.course_id @course = @board.course + else + @org_subfield = @board.org_subfield + @organization = @org_subfield end rescue ActiveRecord::RecordNotFound diff --git a/app/models/message.rb b/app/models/message.rb index 19531e270..dafdb767f 100644 --- a/app/models/message.rb +++ b/app/models/message.rb @@ -23,8 +23,8 @@ class Message < ActiveRecord::Base belongs_to :board,:touch => true belongs_to :author, :class_name => 'User', :foreign_key => 'author_id' has_many :praise_tread, as: :praise_tread_object, dependent: :destroy - has_many :org_subfield_messages, :dependent => :destroy - has_many :org_subfields, :through => :org_subfield_messages + # has_many :org_subfield_messages, :dependent => :destroy + # has_many :org_subfields, :through => :org_subfield_messages acts_as_tree :counter_cache => :replies_count, :order => "#{Message.table_name}.created_on ASC" acts_as_attachable @@ -150,6 +150,10 @@ class Message < ActiveRecord::Base usr && usr.logged? && (usr.allowed_to?(:edit_messages, course) || (self.author == usr && usr.allowed_to?(:edit_own_messages, course))) end + def org_subfield_editable_by?(usr) + usr && usr.logged? && usr.admin? && usr.admin_of_org?(self.board.org_subfield.organization) + end + def course_destroyable_by?(usr) usr && usr.logged? && (usr.allowed_to?(:delete_messages, course) || (self.author == usr && usr.allowed_to?(:delete_own_messages, course))) end @@ -192,7 +196,7 @@ class Message < ActiveRecord::Base # Description def act_as_forge_activity # 如果project为空,那么就是课程相关的消息 - if !self.board.project.nil? && self.parent_id.nil? + if self.board.project_id != -1 && self.parent_id.nil? self.forge_acts << ForgeActivity.new(:user_id => self.author_id, :project_id => self.board.project.id) end @@ -227,7 +231,7 @@ class Message < ActiveRecord::Base end end end - else # 项目相关 + elsif self.project # 项目相关 if self.parent_id.nil? # 主贴 self.project.members.each do |m| if m.user_id != self.author_id diff --git a/app/views/boards/_org_subfield_message_edit.html.erb b/app/views/boards/_org_subfield_message_edit.html.erb new file mode 100644 index 000000000..ae22b225b --- /dev/null +++ b/app/views/boards/_org_subfield_message_edit.html.erb @@ -0,0 +1,16 @@ + +
    +
    +
    + 编辑帖子 +
    +
    + <%= render :partial => 'boards/org_subfield_new', + :locals => {:f => f, :edit_mode => edit_mode, :topic => topic, :org_subfield => org_subfield} %> +
    \ No newline at end of file diff --git a/app/views/boards/_org_subfield_new.html.erb b/app/views/boards/_org_subfield_new.html.erb new file mode 100644 index 000000000..7664c5c32 --- /dev/null +++ b/app/views/boards/_org_subfield_new.html.erb @@ -0,0 +1,74 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: true, prettify: false) %> +<% end %> + +<%= error_messages_for 'message' %> +
    +
    +
    +
    + +

    +
    + +
    + <%#= render :partial => 'course_new_topic', :locals => {:f => f, :topic => @message} %> + +
    +
    \ No newline at end of file diff --git a/app/views/layouts/base_org.html.erb b/app/views/layouts/base_org.html.erb index 808e80239..83bcb4dc9 100644 --- a/app/views/layouts/base_org.html.erb +++ b/app/views/layouts/base_org.html.erb @@ -13,7 +13,7 @@ <%= javascript_heads %> <%= heads_for_theme %> <%= stylesheet_link_tag 'pleft','prettify','jquery/jquery-ui-1.9.2','header','new_user','repository','courses','org' %> - <%= javascript_include_tag 'cookie','project', 'header','prettify','select_list_move','org'%> + <%= javascript_include_tag 'cookie','project', 'organization','header','prettify','select_list_move','org'%> <%= javascript_include_tag 'attachments' %> <%= call_hook :view_layouts_base_html_head %> diff --git a/app/views/messages/_course_show.html.erb b/app/views/messages/_course_show.html.erb index cc93d99b9..294f9b7d4 100644 --- a/app/views/messages/_course_show.html.erb +++ b/app/views/messages/_course_show.html.erb @@ -57,7 +57,7 @@ :data => {:confirm => l(:text_are_you_sure)}, :class => 'postOptionLink' ) if @message.course_destroyable_by?(User.current) %> - <%#= link_to "发送",messages_join_org_subfield_path(:message_id => @topic.id) , :remote=> true,:class => 'postOptionLink' %> + <%= link_to "发送",messages_join_org_subfield_path(:message_id => @topic.id) , :remote=> true,:class => 'postOptionLink' %> diff --git a/app/views/messages/_org_subfield_show.html.erb b/app/views/messages/_org_subfield_show.html.erb new file mode 100644 index 000000000..9eb082d33 --- /dev/null +++ b/app/views/messages/_org_subfield_show.html.erb @@ -0,0 +1,199 @@ +<%= content_for(:header_tags) do %> + <%= import_ke(enable_at: false, prettify: false, init_activity: true) %> +<% end %> + + + + +
    +
    +
    + <%= link_to image_tag(url_to_avatar(@topic.author),:width=>50,:height => 50,:alt=>'图像' ),user_path(@topic.author) %> +
    +
    + <% if @topic.author.id == User.current.id%> + + <%end%> + +
    + +
    + <% if @topic.try(:author).try(:realname) == ' ' %> + <%= link_to @topic.try(:author), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> + <% else %> + <%= link_to @topic.try(:author).try(:realname), user_path(@topic.author,:host=>Setting.host_user), :class => "linkBlue2", :target=> "_blank" %> + <% end %> +
    +
    <%= format_time( @topic.created_on)%>
    +
    +
    + <%= @topic.content.html_safe%> +
    +
    +
    + <%= link_to_attachments_course @topic, :author => false %> +
    +
    +
    +
    +
    +
    + <% unless @replies.empty? %> +
    +
    回复(<%=@reply_count %>)
    +
    + +
    +
    + <% @replies.each_with_index do |reply,i| %> + +
    +
    + <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> +
    +
    +
    + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id,:host=>Setting.host_user), :class => "newsBlue mr10 f14" %> + <% end %> +
    +
    + <%= reply.content.html_safe%> +
    +
    + <%= format_time(reply.created_on) %> + +
    +

    +
    +
    +
    + <% end %> +
    + + <% end %> +
    + <% if !@topic.locked? && authorize_for_course('messages', 'reply') %> +
    + +
    +
    + <%= form_for @reply, :as => :reply, :url => {:action => 'reply', :id => @topic}, :html => {:multipart => true, :id => 'message_form'} do |f| %> + <%= render :partial => 'form_course', :locals => {:f => f, :replying => true} %> + <%= link_to l(:button_cancel), "javascript:void(0)", :onclick => 'course_board_canel_message_replay();', :class => "blue_btn grey_btn fr c_white mt10 mr5" %> + <%= link_to l(:button_submit), "javascript:void(0)", :onclick => 'course_board_submit_message_replay();', :class => "blue_btn fr c_white mt10", :style => "margin-left: 50px;" %> + <% end %> +
    +
    +
    + <% end %> +
    +
    \ No newline at end of file diff --git a/app/views/messages/_project_show.html.erb b/app/views/messages/_project_show.html.erb index a0a340a2a..1cbd606ab 100644 --- a/app/views/messages/_project_show.html.erb +++ b/app/views/messages/_project_show.html.erb @@ -112,8 +112,8 @@ :data => {:confirm => l(:text_are_you_sure)}, :class => 'postOptionLink' ) if @message.destroyable_by?(User.current) %> - <%#= link_to "发送",messages_join_org_subfield_path(:message_id => @topic.id) , :remote=> true,:class => 'postOptionLink' %> +
  • <%= link_to "发送",messages_join_org_subfield_path(:message_id => @topic.id) , :remote=> true,:class => 'postOptionLink' %>
  • diff --git a/app/views/messages/edit.html.erb b/app/views/messages/edit.html.erb index 7543e16e2..6e54a88e1 100644 --- a/app/views/messages/edit.html.erb +++ b/app/views/messages/edit.html.erb @@ -22,6 +22,18 @@ <%= render :partial => 'boards/course_message_edit', :locals => {:f => f, :edit_mode => true, :topic => @message, :course => @message.course} %> <% end %> + +<% elsif @message.board.org_subfield %> + <%= form_for @message, { + :as => :message, + :url => {:action => 'edit'}, + :html => {:multipart => true, + :id => 'message-form', + :method => :post} + } do |f| %> + <%= render :partial => 'boards/org_subfield_message_edit', + :locals => {:f => f, :edit_mode => true, :topic => @message, :org_subfield => @message.board.org_subfield} %> + <% end %> <% end %>
    diff --git a/app/views/messages/reply.js.erb b/app/views/messages/reply.js.erb index 518479344..c0da5ab9b 100644 --- a/app/views/messages/reply.js.erb +++ b/app/views/messages/reply.js.erb @@ -2,5 +2,7 @@ $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_message', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>"); <%elsif @course%> $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_message', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>"); +<% elsif @org_subfield %> + $("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'organizations/org_subfield_message', :locals => {:activity => @topic,:user_activity_id =>@user_activity_id}) %>"); <%end%> init_activity_KindEditor_data(<%= @user_activity_id%>,"","87%", "UserActivity"); \ No newline at end of file diff --git a/app/views/messages/show.html.erb b/app/views/messages/show.html.erb index 5996852ef..428c51f22 100644 --- a/app/views/messages/show.html.erb +++ b/app/views/messages/show.html.erb @@ -2,4 +2,6 @@ <%= render :partial => 'project_show', locals: {project: @project} %> <% elsif @course %> <%= render :partial => 'course_show', locals: {course: @course} %> +<% else %> + <%= render :partial => 'org_subfield_show', :locals => {:org_subfield => @org_subfield} %> <% end %> diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index e7a4f6afa..8bffb7c47 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -50,12 +50,14 @@ <% end %> <% end %> <% if act.container_type == 'OrgSubfield' %> - <% if act.org_act_type == 'Message' and act.org_act_id %> + <% if act.org_act_type == 'Message' and act.org_act_id and Message.where("id=#{act.org_act_id}").count > 0 %> <% message = Message.find(act.org_act_id) %> <% if !message.board.course_id.nil? %> <%= render :partial => 'org_course_message', :locals => {:activity => message,:user_activity_id =>act.id} %> - <% else %> + <% elsif message.board.project_id != -1 %> <%= render :partial => 'organizations/project_message', :locals => {:activity => message,:user_activity_id =>act.id} %> + <% elsif message.board.org_subfield_id %> + <%= render :partial => 'organizations/org_subfield_message', :locals => {:activity => message, :user_activity_id => act.id} %> <% end %> <% end %> <% end %> diff --git a/app/views/organizations/_org_subfield_message.html.erb b/app/views/organizations/_org_subfield_message.html.erb new file mode 100644 index 000000000..57c50486b --- /dev/null +++ b/app/views/organizations/_org_subfield_message.html.erb @@ -0,0 +1,118 @@ +
    +
    +
    + <%= 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.board.org_subfield.name.to_s+" | 资源栏目讨论区",org_subfield_boards_path(activity.board.org_subfield), :class => "newsBlue ml15 mr5"%> + +
    +
    + <% if activity.parent_id.nil? %> + <%= link_to activity.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey" + %> + <% else %> + <%= link_to activity.parent.subject.to_s.html_safe, board_message_path(activity.board,activity), :class=> "postGrey" + %> + <% end %> +
    +
    + 时间:<%= format_time(activity.created_on) %> +
    +
    +
    + <% if activity.parent_id.nil? %> + <%= activity.content.to_s.html_safe%> + <% else %> + <%= activity.parent.content.to_s.html_safe%> + <% end %> +
    +
    +
    + + +
    +
    +
    +
    + <% count = 0 %> + <% if activity.parent %> + <% count=activity.parent.children.count%> + <% else %> + <% count=activity.children.count%> + <% end %> +
    +
    +
    +
    回复( + <%=count %> + )
    +
    <%#=format_date(activity.updated_on)%>
    + <%if count>3 %> + + <% end %> +
    + + <% activity= activity.parent_id.nil? ? activity : activity.parent %> + <% replies_all_i = 0 %> + <% if count > 0 %> +
    +
      + <% activity.children.reorder("created_on desc").each do |reply| %> + + <% replies_all_i=replies_all_i+1 %> +
    • +
      + <%= link_to image_tag(url_to_avatar(reply.author), :width => "33", :height => "33"), user_path(reply.author_id), :alt => "用户头像" %> +
      +
      +
      + <% if reply.try(:author).try(:realname) == ' ' %> + <%= link_to reply.try(:author), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> + <% else %> + <%= link_to reply.try(:author).try(:realname), user_path(reply.author_id), :class => "newsBlue mr10 f14" %> + <% end %> + <%= format_time(reply.created_on) %> +
      +
      + <%= reply.content.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=>'messages',:action => 'reply', :id => activity.id, :board_id => activity.board_id, :is_board => 'true'},:method => "post", :remote => true) do |f|%> + + + +
    + +
    +

    + <% end%> +
    +
    +
    +
    +
    + +
    +
    \ No newline at end of file diff --git a/app/views/organizations/org_subfield_message_edit.html.erb b/app/views/organizations/org_subfield_message_edit.html.erb new file mode 100644 index 000000000..caa389945 --- /dev/null +++ b/app/views/organizations/org_subfield_message_edit.html.erb @@ -0,0 +1,16 @@ + +
    +
    +
    + 编辑帖子 +
    +
    + <%= render :partial => 'boards/course_new', + :locals => {:f => f, :edit_mode => edit_mode, :topic => topic, :course => course} %> +
    \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index be9843a80..36e6dff59 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -84,6 +84,7 @@ RedmineApp::Application.routes.draw do match "quote_resource_show_org_subfield", :via => [:get] end end + resource :boards end resources :org_document_comments do diff --git a/public/javascripts/organization.js b/public/javascripts/organization.js new file mode 100644 index 000000000..e04a8b282 --- /dev/null +++ b/public/javascripts/organization.js @@ -0,0 +1,39 @@ +/** + * Created by ouyangxuhua on 2015/12/30. + */ +function submit_topic() +{ + if(regexTopicSubject() && regexTopicDescription()) + { + message_content_editor.sync(); + $("#message-form").submit(); + } +} + +function regexTopicSubject() { + var name = $("#message_subject").val(); + if(name.length ==0) + { + $("#subjectmsg").text("标题不能为空"); + $("#subjectmsg").css('color','#ff0000'); + $("#message_subject").focus(); + return false; + } + else if(name.length <= 255) + { + $("#subjectmsg").text("填写正确"); + $("#subjectmsg").css('color','#008000'); + return true; + } + else + { + $("#subjectmsg").text("标题超过255个字符"); + $("#subjectmsg").css('color','#ff0000'); + $("#message_subject").focus(); + return false; + } +} + +function reset_topic(){ + +} From c16f99774b8102a90da4166590315bdf6a2fa727 Mon Sep 17 00:00:00 2001 From: ouyangxuhua Date: Wed, 30 Dec 2015 16:57:40 +0800 Subject: [PATCH 07/10] =?UTF-8?q?1.=E7=BB=84=E7=BB=87=E5=8F=B6=E5=BA=95?= =?UTF-8?q?=E6=A0=B7=E5=BC=8F=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98=E4=BF=AE?= =?UTF-8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/organizations/_org_activities.html.erb | 15 ++------------- app/views/organizations/show.html.erb | 8 ++++---- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/app/views/organizations/_org_activities.html.erb b/app/views/organizations/_org_activities.html.erb index 8bffb7c47..b82bbb642 100644 --- a/app/views/organizations/_org_activities.html.erb +++ b/app/views/organizations/_org_activities.html.erb @@ -50,7 +50,7 @@ <% end %> <% end %> <% if act.container_type == 'OrgSubfield' %> - <% if act.org_act_type == 'Message' and act.org_act_id and Message.where("id=#{act.org_act_id}").count > 0 %> + <% if act.org_act_type == 'Message' and act.org_act_id %> <% message = Message.find(act.org_act_id) %> <% if !message.board.course_id.nil? %> <%= render :partial => 'org_course_message', :locals => {:activity => message,:user_activity_id =>act.id} %> @@ -62,21 +62,10 @@ <% end %> <% end %> <% end %> - - <%#= pagination_links_full @obj_pages, @obj_count, :per_page_links => false, :remote => false, :flag => true%> - + <% end %> <% if org_act_count == 10 %> - <%= link_to "点击展开更多",organization_path(org,:page => page.to_i + 1, :show_homepage =>params[:show_homepage],:type => params[:type]),:id => "show_more_activities",:remote => "true",:class => "loadMore mt10 f_grey"%> <% end%> -