diff --git a/app/controllers/admin/writing_conferences_controller.rb b/app/controllers/admin/writing_conferences_controller.rb index 8ffc4a0..65f14d6 100644 --- a/app/controllers/admin/writing_conferences_controller.rb +++ b/app/controllers/admin/writing_conferences_controller.rb @@ -8,13 +8,51 @@ class Admin::WritingConferencesController < OrbitMemberController before_action :need_access_right before_action :allow_admin_only, :only => [:index, :setting] + def merge_process + params['writing_conference_id'].each do |writing_conference_id| + writing_conference_ids = writing_conference_id.split('/') + writing_conferences = WritingConference.find(writing_conference_ids) + member_ids = writing_conferences.collect(&:member_profile_id).uniq + writing_conferences.each_with_index do |writing_conference,index1| + if index1== 0 + writing_conference.member_profile_id = member_ids + writing_conference.save! + else + writing_conference.delete + end + end + end + redirect_to :action=> 'index' + end + def merge + @writing_conferences=WritingConference.order_by(:year=>'desc').map{|value| value}.group_by{|v| [v[:paper_title],v[:conference_title]]} + @writing_conferences.each do |key,value| + if value.length<=1 + @writing_conferences.delete key + end + end + if params['mode']!='simple' + @writing_conferences.each do |key,value| + @writing_conferences[key] = value.group_by{|v| [get_level_type(v),get_author_type(v),get_paper_type(v),get_publication_date(v)]} + @writing_conferences[key].each do |key1,value1| + if value1.length<=1 + @writing_conferences[key].delete key1 + end + end + if @writing_conferences[key].length==0 + @writing_conferences.delete key + end + end + + end + end def index @writing_conferences = WritingConference.order_by(:year=>'desc').page(params[:page]).per(10) end def new - @member = MemberProfile.find_by(:uid=>params['uid']) rescue nil + @member = Array(MemberProfile.find_by(:uid=>params['uid'])) rescue nil @writing_conference = WritingConference.new if params[:desktop] @@ -60,9 +98,9 @@ class Admin::WritingConferencesController < OrbitMemberController elsif !params[:author_members].blank? - params[:author_members].each do |author_member| + #params[:author_members].each do |author_member| - conference_params['member_profile_id'] = author_member + conference_params['member_profile_id'] = params[:author_members] @writing_conference = WritingConference.new(conference_params) @writing_conference.save @@ -70,7 +108,7 @@ class Admin::WritingConferencesController < OrbitMemberController render json: {"data" => get_paper_list}.to_json end - end + #end redirect_to params['referer_url'] @@ -92,14 +130,14 @@ class Admin::WritingConferencesController < OrbitMemberController end def edit - @member = @writing_conference.member_profile + @member = get_member(@writing_conference) if params[:desktop] render :layout => false end end def update - @member = @writing_conference.member_profile + @member = get_member(@writing_conference) @writing_conference.update_attributes(conference_params) @writing_conference.save if params[:desktop] == "true" diff --git a/app/controllers/personal_conferences_controller.rb b/app/controllers/personal_conferences_controller.rb index c320afc..63f4023 100644 --- a/app/controllers/personal_conferences_controller.rb +++ b/app/controllers/personal_conferences_controller.rb @@ -1,4 +1,5 @@ class PersonalConferencesController < ApplicationController + include Admin::PersonalConferencesHelper def index params = OrbitHelper.params page_data_count = OrbitHelper.page_data_count @@ -43,6 +44,8 @@ class PersonalConferencesController < ApplicationController writing_conferences_show = writing_conferences_temp.select { |value| search_all_words(value.conference_author_types.collect(&:title).join(', '), params[:keywords]) } when 'language' writing_conferences_show = writing_conferences_temp.select { |value| search_all_words((!value.language.nil? ? t(value.language.to_s) : ''), params[:keywords]) } + when 'authors' + writing_conferences_show = writing_conferences_temp.select { |value| search_all_words(get_authors_text(value), params[:keywords]) } else writing_conferences_show = writing_conferences_temp.select { |value| search_all_words(value.send(params[:selectbox]).to_s, params[:keywords]) } end @@ -75,6 +78,10 @@ class PersonalConferencesController < ApplicationController t << { 'value' => writing_conference.duration } when 'language' t << { 'value' => (!writing_conference.language.nil? ? t(writing_conference.language.to_s) : '') } + when 'url' + t << { 'value' => writing_conference.url.to_s.blank? ? "" : "#{writing_conference.url}"} + when 'authors' + t << { 'value' => get_authors_show(writing_conference) } else t << { 'value' => writing_conference.send(fs) } end diff --git a/app/helpers/admin/personal_conferences_helper.rb b/app/helpers/admin/personal_conferences_helper.rb index 487a73a..a0518e6 100644 --- a/app/helpers/admin/personal_conferences_helper.rb +++ b/app/helpers/admin/personal_conferences_helper.rb @@ -1,5 +1,25 @@ module Admin::PersonalConferencesHelper - + def get_authors_text(writing_conference) + (writing_conference.authors.to_s.blank? ? get_member(writing_conference).collect(&:name).join('/') : Nokogiri::HTML(writing_conference.authors.to_s).text rescue '') + end + def get_authors_show(writing_conference) + (writing_conference.authors.to_s.blank? ? get_member(writing_conference).collect{|member| "#{member.name}"}.join('/') : writing_conference.authors.to_s rescue '') + end + def get_member(writing_conference) + Array(MemberProfile.find(Array(writing_conference).collect(&:member_profile_id))) + end + def get_sponsor(writing_conference) + writing_conference.sponsor + end + def get_author_type(writing_conference) + writing_conference.conference_author_types.collect(&:title).join(', ') rescue '' + end + def get_paper_type(writing_conference) + !writing_conference.conference_paper_types.blank? ? writing_conference.conference_paper_types.collect(&:title).join(', ').to_s : nil + end + def get_publication_date(writing_conference) + writing_conference.publication_date.strftime('%Y/%m/%d') rescue '' + end def get_paper_list user = current_user.nil? ? OrbitHelper.current_user : current_user user_profile = user.member_profile diff --git a/app/models/writing_conference.rb b/app/models/writing_conference.rb index e700cff..38f0615 100644 --- a/app/models/writing_conference.rb +++ b/app/models/writing_conference.rb @@ -1,7 +1,7 @@ class WritingConference include Mongoid::Document include Mongoid::Timestamps - + include Admin::PersonalConferencesHelper include OrbitModel::Status include OrbitTag::Taggable include MemberHelper @@ -196,6 +196,10 @@ class WritingConference files << (url.nil? ? "" : "
  • #{title}
  • ") end value = files.join("") + when "url" + value = self.url.to_s.blank? ? "" : "#{self.url}" + when "authors" + value = get_authors_show(self) else value = self.send(field) rescue "" end diff --git a/app/views/admin/writing_conferences/_form.html.erb b/app/views/admin/writing_conferences/_form.html.erb index d0a7fe9..4bb6a0a 100644 --- a/app/views/admin/writing_conferences/_form.html.erb +++ b/app/views/admin/writing_conferences/_form.html.erb @@ -81,7 +81,7 @@
    <%= f.fields_for :authors_translations do |f| %> - <%= f.text_area locale, class: "input-block-level", placeholder: t("personal_conference.authors"), value: (@writing_conference.authors_translations[locale] rescue nil) %> + <%= f.text_area locale, class: "ckeditor input-block-level", placeholder: t("personal_conference.authors"), value: (@writing_conference.authors_translations[locale] rescue nil) %> <% end %>
    @@ -138,26 +138,17 @@
    - <% if !@member.nil? %> -
    - <%= @member.name rescue ''%> - <%= f.hidden_field :member_profile_id, :value => @member.id %> -
    -
    - - <% else %> - -
    - -
    - <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'author_members[]', email_members:[]} %> + <% if !@member.nil? %> + <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'author_members[]', email_members:@member} %> + <% else %> + <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'author_members[]', email_members:[]} %> + <% end %>
    - <% end %>
    diff --git a/app/views/admin/writing_conferences/_writing_conference.html.erb b/app/views/admin/writing_conferences/_writing_conference.html.erb index a1c507b..39059d5 100644 --- a/app/views/admin/writing_conferences/_writing_conference.html.erb +++ b/app/views/admin/writing_conferences/_writing_conference.html.erb @@ -2,7 +2,7 @@ "> <%= writing_conference.year %> - <%= link_to writing_conference.create_link, OrbitHelper.url_to_plugin_show(writing_conference.to_param,'personal_conference'), target: "blank"%> + <%= link_to Nokogiri::HTML(writing_journal.create_link).text, OrbitHelper.url_to_plugin_show(writing_conference.to_param,'personal_conference'), target: "blank"%>