app/controllers/article_threads_controller.rb
# for creating new article and its article_thread
for creating new article and its article_thread
for creating new article and its article_thread
def prepare_for_new
    @display_mode = @background_params[:display_mode]
    @forum        = @background_params[:forum] || []
    preparation_for_altering
    sender_name   = @current_user.real_name
    @thread = @entity = ArticleThread.new_run(:no_of_articles => 0)
    article_class = (prm = @background_params[:article_class]).blank? ? Article::General_Class : prm
    if article_class == Article::General_Class
      @article_form_items = @article_form_items - [:is_general] + [:is_general_hidden]  
    end
    init_article_attrs = { :article_class => article_class,
                           :is_general    => true,
                           :is_news       => true,
                           :sender_name   => sender_name}
    unless @forum.blank?
      forum_id, forum_type = @forum.to_id_and_model_name
      init_article_attrs.merge! :forum_run_id => forum_id,
                                :forum_type   => forum_type,
                                :is_general   => false
    end
    if ["schedules" ,"space_schedules"].include? @display_mode
      @article_form_items = @article_form_items - [:is_news, :is_general] + [:is_news_for_schedules, :is_general_hidden]
      date = params[:start_date].to_datetime(:local).to_date
      init_article_attrs.merge! :start_date => date,
                                :end_date   => date,
                                :start_datetime => date,
                                :end_datetime   => date,
                                :is_news => false,
                                :is_general => true,
                                :time_place_settings => 1    
    end
    if @display_mode == "space_schedules"
      space_span = @background_params[:space_span]
      init_article_attrs.merge! :place_run_id => Space.entity_by_name(space_span).run_id
    end
    @article = @thread.articles.build(init_article_attrs)
    @article.to_individuals.build :user_info_run_id => @current_user.run_id
    @article.organizations.build :affiliation_run_id => Affiliation.tree_root.run_id,
                                 :status_run_id      => Status.tree_root.run_id 
    if @background_params[:only_with_questionnaires]
      @article.questionnaires.build :question_no => 1
    end
  end
def prepare_for_new @display_mode = @background_params [ :display_mode ] @forum = @background_params [ :forum ] || [ ] preparation_for_altering sender_name = @current_user . real_name @thread = @entity = ArticleThread . new_run ( :no_of_articles => 0 ) article_class = ( prm = @background_params [ :article_class ] ) . blank? ? Article :: General_Class : prm if article_class == Article :: General_Class @article_form_items = @article_form_items - [ :is_general ] + [ :is_general_hidden ] end init_article_attrs = { :article_class => article_class , :is_general => true , :is_news => true , :sender_name => sender_name } unless @forum . blank? forum_id , forum_type = @forum . to_id_and_model_name init_article_attrs . merge! :forum_run_id => forum_id , :forum_type => forum_type , :is_general => false end if [ "schedules" , "space_schedules" ] . include? @display_mode @article_form_items = @article_form_items - [ :is_news , :is_general ] + [ :is_news_for_schedules , :is_general_hidden ] date = params [ :start_date ] . to_datetime ( :local ) . to_date init_article_attrs . merge! :start_date => date , :end_date => date , :start_datetime => date , :end_datetime => date , :is_news => false , :is_general => true , :time_place_settings => 1 end if @display_mode == "space_schedules" space_span = @background_params [ :space_span ] init_article_attrs . merge! :place_run_id => Space . entity_by_name ( space_span ) . run_id end @article = @thread . articles . build ( init_article_attrs ) @article . to_individuals . build :user_info_run_id => @current_user . run_id @article . organizations . build :affiliation_run_id => Affiliation . tree_root . run_id , :status_run_id => Status . tree_root . run_id if @background_params [ :only_with_questionnaires ] @article . questionnaires . build :question_no => 1 end end
for creating new article and its article_thread
for creating new article and its article_thread
# make this field hidden # set pre_selection of shared_place # as default organization destination.