Merge branch 'master' into 'master'
Updated! See merge request spen/seminar!21
This commit is contained in:
commit
1043304d20
Binary file not shown.
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
|
@ -37,28 +37,45 @@ class SeminarsController < ApplicationController
|
|||
template_path = content_style_info["template"]
|
||||
template_info = content_style_info["info"]
|
||||
custom_footer = seminar_template_setting.footer_info
|
||||
if seminar_template_setting.seminar_banner_images.count != 0
|
||||
if seminar_template_setting.seminar_banner_images.count != 0 || background_style_info["default_logo"]
|
||||
banner_title = seminar.title
|
||||
external_link = prefix_url + "/home"
|
||||
images = seminar_template_setting.seminar_banner_images.map.with_index do |image,i|
|
||||
caption = (i == 0 ? '<div class="cycle-overlay"></div><div class="cycle-pager"></div>' : "")
|
||||
klass = (i == 0 ? "active" : "")
|
||||
alt_title = image.description
|
||||
context = ""
|
||||
image_link = image.file.url
|
||||
{
|
||||
"image_link" => image_link,
|
||||
"image_alt" => alt_title,
|
||||
"title" => "",
|
||||
"alt_title" => alt_title,
|
||||
"class" => klass,
|
||||
"height" => 0,
|
||||
"width" => 0,
|
||||
"caption" => caption,
|
||||
"context" => context,
|
||||
"link" => external_link,
|
||||
"target" => ""
|
||||
}
|
||||
images = []
|
||||
if seminar_template_setting.seminar_banner_images.count == 0
|
||||
images = [{
|
||||
"image_link" => background_style_info["default_logo"],
|
||||
"image_alt" => banner_title,
|
||||
"title" => "",
|
||||
"alt_title" => banner_title,
|
||||
"class" => "active",
|
||||
"height" => 0,
|
||||
"width" => 0,
|
||||
"caption" => '<div class="cycle-overlay"></div><div class="cycle-pager"></div>',
|
||||
"context" => "",
|
||||
"link" => external_link,
|
||||
"target" => ""
|
||||
}]
|
||||
else
|
||||
images = seminar_template_setting.seminar_banner_images.map.with_index do |image,i|
|
||||
caption = (i == 0 ? '<div class="cycle-overlay"></div><div class="cycle-pager"></div>' : "")
|
||||
klass = (i == 0 ? "active" : "")
|
||||
alt_title = image.description
|
||||
context = ""
|
||||
image_link = image.file.url
|
||||
{
|
||||
"image_link" => image_link,
|
||||
"image_alt" => alt_title,
|
||||
"title" => "",
|
||||
"alt_title" => alt_title,
|
||||
"class" => klass,
|
||||
"height" => 0,
|
||||
"width" => 0,
|
||||
"caption" => caption,
|
||||
"context" => context,
|
||||
"link" => external_link,
|
||||
"target" => ""
|
||||
}
|
||||
end
|
||||
end
|
||||
custom_banner = {
|
||||
"extras" => {
|
||||
|
|
|
@ -473,6 +473,22 @@ class SeminarMain
|
|||
no_dup_flag = new_object.send(f).present?
|
||||
elsif clone_target.relations[f].macro == :has_many
|
||||
no_dup_flag = new_object.send(f).to_a.count != 0
|
||||
elsif clone_target.relations[f].macro == :embeds_many #Fix localize fields
|
||||
if new_object.send(f).to_a.count != 0
|
||||
need_fix_fields = new_object.send(f).to_a[0].fields.select{|k,v| (v.options[:localize] rescue false)}.keys
|
||||
locale = I18n.locale.to_s
|
||||
embeded_records = new_object.send(f).map do |embeded_record|
|
||||
need_fix_fields.each do |f|
|
||||
if (embeded_record[f][locale].class != String rescue false)
|
||||
embeded_record.send("#{f}_translations=",embeded_record[f][locale])
|
||||
else
|
||||
embeded_record.send("#{f}_translations=",embeded_record[f])
|
||||
end
|
||||
end
|
||||
embeded_record
|
||||
end
|
||||
new_object.send("#{f}=",embeded_records)
|
||||
end
|
||||
end
|
||||
if clone_target.relations[f].macro == :belongs_to || clone_target.relations[f].class_name == "MemberProfile"
|
||||
if @records_all["#{f}_ids"].nil?
|
||||
|
|
|
@ -10,10 +10,46 @@ class SeminarTemplateSetting
|
|||
field :website_title, type: String , default: "", localize: true
|
||||
field :footer_info, type: String , default: "", localize: true
|
||||
field :introduction, type: String , default: "", localize: true
|
||||
field :background_style, type: String , default: ""
|
||||
field :content_style, type: String , default: ""
|
||||
field :background_style, type: String , default: "1"
|
||||
field :content_style, type: String , default: "1"
|
||||
has_many :seminar_banner_images, :autosave => true, :dependent => :destroy
|
||||
accepts_nested_attributes_for :seminar_banner_images, :allow_destroy => true
|
||||
after_create do
|
||||
if self.seminar_main
|
||||
@seminar_page_root = Page.where(:parent_page_id=>self.seminar_main_id).first
|
||||
available_locales = Site.first.in_use_locales rescue I18n.available_locales
|
||||
available_locales = available_locales.map{|l| l.to_s}
|
||||
if @seminar_page_root.nil?
|
||||
@seminar_page_root = Page.create(:parent_page_id=>self.seminar_main_id,:module=>"seminars_home",:name_translations=>@seminar.title_translations,:url=>"/home",:page_id=>"home",:enabled_for=>available_locales,:bind_uid=>@seminar.uid,:bind_module_app=>"seminar",:bind_model=>"SeminarMain",:menu_enabled_for=>available_locales)
|
||||
else
|
||||
@seminar_page_root.update(:name_translations=>@seminar.title_translations,:module=>"seminars_home",:url=>"/home",:page_id=>"home",:enabled_for=>available_locales,:bind_uid=>@seminar.uid,:bind_module_app=>"seminar",:bind_model=>"SeminarMain",:menu_enabled_for=>available_locales)
|
||||
end
|
||||
pages_info = {"introduction" => "seminars_page",
|
||||
"news" => "custom_announcement",
|
||||
"registration" => "seminar_registration",
|
||||
"submission" => "seminar_submission",
|
||||
"album" => "custom_gallery"}
|
||||
relation_model = {"news" => "CustomBulletin","album"=>"CustomAlbum"}
|
||||
pages_info.each do |page_id , page_module|
|
||||
seminar_page = @seminar_page_root.child_page.where(:page_id=>page_id).first
|
||||
page_trans = available_locales.map{|l| [l,I18n.with_locale(l){I18n.t("seminar.menu.#{page_id}")}]}.to_h
|
||||
available_locales_tmp = available_locales.clone
|
||||
if relation_model[page_id]
|
||||
relation = relation_model[page_id].constantize rescue nil
|
||||
if relation
|
||||
if relation.where(:bind_uid=>@seminar.uid).count == 0
|
||||
available_locales_tmp = []
|
||||
end
|
||||
end
|
||||
end
|
||||
if seminar_page.nil?
|
||||
seminar_page = @seminar_page_root.child_page.create(:name_translations=>page_trans,:page_id=>page_id,:url=>"/home/#{page_id}",:enabled_for=>available_locales_tmp,:module=>page_module,:menu_enabled_for=>available_locales_tmp)
|
||||
else
|
||||
seminar_page.update(:name_translations=>page_trans,:page_id=>page_id,:url=>"/home/#{page_id}",:module=>page_module)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
after_save do
|
||||
if self.display_menu_changed?
|
||||
@seminar_page_root = Page.where(:parent_page_id=>self.seminar_main_id).first
|
||||
|
@ -45,10 +81,15 @@ class SeminarTemplateSetting
|
|||
image_file = image_file.select{|f| File.basename(f).include?(folder_name)}.first
|
||||
key = File.basename(folder)
|
||||
image_path = "/assets/seminar/background_style/#{key}/#{File.basename(image_file) rescue ''}"
|
||||
@@background_style_infos[key] = {
|
||||
default_logo = nil
|
||||
if File.exist?("#{folder}logo.jpg")
|
||||
default_logo = "#{folder}logo.jpg".split("app")[1..-1].join("app").sub("/stylesheets/","/")
|
||||
end
|
||||
@@background_style_infos[key] = {
|
||||
"image"=>image_path,
|
||||
"css"=> get_folder_content(folder,"css"),
|
||||
"js"=> get_folder_content(folder,"js")
|
||||
"css"=> get_folder_content(folder,"css"),
|
||||
"js"=> get_folder_content(folder,"js"),
|
||||
"default_logo"=> default_logo
|
||||
}
|
||||
end
|
||||
@@background_style_infos = @@background_style_infos.sort_by {|k, v| (k.match(/\d+/)[0].to_i rescue 0)}.to_h
|
||||
|
|
|
@ -8,7 +8,8 @@
|
|||
<% begin %>
|
||||
<table class="table table-hover table-striped seminar-index">
|
||||
<caption>
|
||||
<h3><%= t('seminar.seminar') %></h3>
|
||||
<% page = OrbitHelper.page rescue Page.where(:page_id => params[:page_id]).first %>
|
||||
<h3><%= page.name rescue t('seminar.seminar') %></h3>
|
||||
</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
|
|
Loading…
Reference in New Issue