diff --git a/app/controllers/sub_document_comments_controller.rb b/app/controllers/sub_document_comments_controller.rb index ed12ac8f7..502e815d2 100644 --- a/app/controllers/sub_document_comments_controller.rb +++ b/app/controllers/sub_document_comments_controller.rb @@ -65,25 +65,30 @@ class SubDocumentCommentsController < ApplicationController end def update - @org_document = OrgDocumentComment.find(params[:id]) - @org_document.update_attributes(:title => params[:org_document_comment][:title], :content => params[:org_document_comment][:content]) - Attachment.attach_files(@org_document, params[:attachments]) + @sub_document = SubDocumentComment.find(params[:id]) + @sub_document.update_attributes(:title => params[:sub_document_comment][:title], :content => params[:sub_document_comment][:content]) + @organization = OrgSubfield.find(params[:org_subfield_id]).organization + # Attachment.attach_files(@org_document, params[:attachments]) # @org_document.save_attachments(params[:attachments]) - 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) + if @sub_document.parent.nil? + act = OrgActivity.where("org_act_type='SubDocumentComment' and org_act_id =?", @sub_document.id).first + act.update_attributes(:updated_at => @sub_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) + + # render :action => 'index', :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org' + redirect_to org_subfield_sub_domain_sub_document_comments_path(:org_subfield_id => params[:org_subfield_id], :sub_domain_id => params[:sub_domain_id]) + # render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org' + # redirect_to organization_path(@organization) else - 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, :org_subfield_id => params[:org_subfield_id]) - end + # 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, :org_subfield_id => params[:org_subfield_id]) + # end end } end @@ -92,6 +97,7 @@ class SubDocumentCommentsController < ApplicationController def edit @sub_document = SubDocumentComment.find(params[:id]) @flag = params[:flag] + render :layout => @organization.switch_type ? 'base_sub_domain' : 'base_org' end def add_reply diff --git a/app/models/sub_domain.rb b/app/models/sub_domain.rb index 831edf17d..0ae325e1a 100644 --- a/app/models/sub_domain.rb +++ b/app/models/sub_domain.rb @@ -1,5 +1,5 @@ class SubDomain < ActiveRecord::Base attr_accessible :field_type, :hide, :name, :org_subfield_id, :priority, :status belongs_to :org_subfield, :foreign_key => :org_subfield_id - has_many :sub_document_comments + has_many :sub_document_comments, :dependent => :destroy end diff --git a/app/views/sub_document_comments/_show_sub_document.html.erb b/app/views/sub_document_comments/_show_sub_document.html.erb index 0027417ab..cc09042e3 100644 --- a/app/views/sub_document_comments/_show_sub_document.html.erb +++ b/app/views/sub_document_comments/_show_sub_document.html.erb @@ -46,7 +46,7 @@