You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

org_document_comments_controller.rb 6.8 kB

​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. class OrgDocumentCommentsController < ApplicationController
  2. before_filter :find_organization, :only => [:new, :create, :show, :index]
  3. before_filter :authorize_allowed, :only => [:create, :add_reply, :add_reply_in_doc]
  4. helper :attachments,:organizations
  5. layout 'base_org'
  6. def new
  7. @org_document_comment = OrgDocumentComment.new
  8. end
  9. def create
  10. @org_document_comment = OrgDocumentComment.new(:organization_id => @organization.id, :creator_id => User.current.id)
  11. @org_document_comment.title = params[:org_document_comment][:title]
  12. @org_document_comment.content = params[:org_document_comment][:content]
  13. @org_document_comment.status = params[:org_document_comment][:status] == "on" ? 1 : 0
  14. @org_document_comment.save_attachments(params[:attachments])
  15. if params[:field_id]
  16. @org_document_comment.org_subfield_id = params[:field_id].to_i
  17. end
  18. if @org_document_comment.save
  19. flash.keep[:notice] = l(:notice_successful_create)
  20. EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document_comment.id, :created_at => @org_document_comment.updated_at)
  21. if params[:field_id]
  22. @org_subfield = OrgSubfield.find(params[:field_id])
  23. if @org_subfield.subfield_subdomain_dir.nil?
  24. redirect_to organization_path(@organization, :org_subfield_id => params[:field_id])
  25. else
  26. redirect_to show_org_subfield_organization_path(:id => @organization.id, :sub_dir_name => @org_subfield.subfield_subdomain_dir.name)
  27. end
  28. else
  29. redirect_to organization_org_document_comments_path(@organization)
  30. end
  31. else
  32. redirect_to new_org_document_comment_path(:organization_id => @organization.id)
  33. end
  34. end
  35. def show
  36. @document = OrgDocumentComment.find(params[:id])
  37. @org_subfield = OrgSubfield.where(:id => @document.org_subfield_id).first
  38. @subfield_content = @organization.org_subfields.order("priority")
  39. respond_to do |format|
  40. format.html {render :layout => (@organization.switch_type && @document && !@document.org_subfield_id.blank?) ? 'base_org_custom' : 'base_org'}
  41. end
  42. end
  43. def index
  44. if @organization.is_public? || User.current.admin? || User.current.member_of_org?(@organization)
  45. @documents = @organization.org_document_comments.where("parent_id is null").order("created_at desc")
  46. else
  47. render_403
  48. end
  49. end
  50. def update
  51. @org_document = OrgDocumentComment.find(params[:id])
  52. @org_document.update_attributes(:title => params[:org_document_comment][:title], :content => params[:org_document_comment][:content])
  53. Attachment.attach_files(@org_document, params[:attachments])
  54. # @org_document.save_attachments(params[:attachments])
  55. if @org_document.parent.nil?
  56. act = OrgActivity.where("org_act_type='OrgDocumentComment' and org_act_id =?", @org_document.id).first
  57. act.update_attributes(:updated_at => @org_document.updated_at)
  58. EditorOfDocument.create(:editor_id => User.current.id, :org_document_comment_id => @org_document.id, :created_at => Time.now)
  59. end
  60. respond_to do |format|
  61. format.html {
  62. if params[:flag].to_i == 0
  63. redirect_to organization_org_document_comments_path(:organization_id => @org_document.organization.id)
  64. else
  65. if params[:flag].to_i == 1
  66. redirect_to org_document_comment_path(@org_document.root.id, :organization_id => @org_document.organization.id)
  67. else
  68. redirect_to organization_path(@org_document.organization.id, :org_subfield_id => params[:org_subfield_id])
  69. end
  70. end
  71. }
  72. end
  73. end
  74. def edit
  75. @org_document = OrgDocumentComment.find(params[:id])
  76. @flag = params[:flag]
  77. @organization = Organization.find(params[:organization_id])
  78. end
  79. def add_reply
  80. @document = OrgDocumentComment.find(params[:id]).root
  81. @act = OrgActivity.find(params[:act_id])
  82. @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id])
  83. @comment.content = params[:org_content]
  84. @document.children << @comment
  85. @document.save
  86. end
  87. def add_reply_in_doc
  88. @document = OrgDocumentComment.find(params[:id]).root
  89. @comment = OrgDocumentComment.new(:organization_id => @document.organization_id, :creator_id => User.current.id, :reply_id => params[:id])
  90. if params[:org_comment].blank?
  91. @comment.content = params[:org_content]
  92. else
  93. @comment.content = params[:org_comment][:org_content]
  94. end
  95. @document.children << @comment
  96. @document.save
  97. respond_to do |format|
  98. format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)}
  99. end
  100. end
  101. def find_organization
  102. @organization = Organization.find(params[:organization_id])
  103. end
  104. def authorize_allowed
  105. unless User.current.logged?
  106. redirect_to signin_url
  107. return
  108. end
  109. end
  110. def destroy
  111. @org_document_comment = OrgDocumentComment.find(params[:id])
  112. @org_sub_id = @org_document_comment.org_subfield_id
  113. org = @org_document_comment.root.organization
  114. if @org_document_comment.id == org.home_id
  115. org.update_attributes(:home_id => nil)
  116. end
  117. if params[:user_activity_id]
  118. @act = OrgActivity.find(params[:user_activity_id])
  119. @document = @org_document_comment.root
  120. end
  121. if @org_document_comment.destroy
  122. end
  123. respond_to do |format|
  124. format.js
  125. end
  126. end
  127. def delete_reply
  128. @org_document_comment = OrgDocumentComment.find(params[:id])
  129. @document = @org_document_comment.root
  130. org = @org_document_comment.organization
  131. @org_document_comment.destroy
  132. respond_to do |format|
  133. format.html {redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)}
  134. end
  135. end
  136. def quote
  137. @org_comment = OrgDocumentComment.find(params[:id])
  138. @temp = OrgDocumentComment.new
  139. respond_to do | format|
  140. format.js
  141. end
  142. end
  143. def reply
  144. @document = OrgDocumentComment.find(params[:id])
  145. @org_document = OrgDocumentComment.new(:creator_id => User.current.id, :reply_id => params[:id])
  146. @org_document.title = params[:org_document_comment][:title]
  147. @org_document.content = params[:org_document_comment][:content]
  148. @document.children << @org_document
  149. @document = @document.root
  150. @user_activity_id = params[:user_activity_id]
  151. @act = OrgActivity.find(@user_activity_id) if @user_activity_id
  152. respond_to do |format|
  153. format.html {
  154. redirect_to org_document_comment_path(:id => @document.id, :organization_id => @document.organization_id)
  155. }
  156. format.js
  157. end
  158. end
  159. end

软件技术创新是当今国家整体创新能力的重要基础和发展引擎。近年来,大众参与的软件创新与创业活动已经成为网络时代软件开发和应用的新形态,正在快速改变着全球软件创新模式和软件产业格局。 ...