Merge branch 'ntu' of github.com:Rulingcom/orbit into ntu
Conflicts: lib/tasks/migrate.rake
This commit is contained in:
commit
39f715319b
|
@ -46,12 +46,16 @@ class Admin::TagsController < OrbitBackendController
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def set_module_app
|
|
||||||
@module_app ||= ModuleApp.first(:conditions => {:key => @app_title.underscore}) rescue nil
|
|
||||||
end
|
|
||||||
|
|
||||||
def get_tags
|
def get_tags
|
||||||
@tags = (@module_app ? @module_app.tags : Tag.all)
|
@tags = (@module_app ? @module_app.tags : Tag.all)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def setup_vars
|
||||||
|
@app_key = request.env['HTTP_REFERER'].split('/')[4]
|
||||||
|
if @app_key
|
||||||
|
@app_key.gsub!(/[?].*/, '')
|
||||||
|
@module_app = ModuleApp.first(conditions: {:key => @app_key})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -47,10 +47,10 @@ class Item
|
||||||
new_parent = Item.find(new_parent)
|
new_parent = Item.find(new_parent)
|
||||||
current_position_sibling = find_by_parent_and_position(new_parent, position.to_i)
|
current_position_sibling = find_by_parent_and_position(new_parent, position.to_i)
|
||||||
if current_position_sibling
|
if current_position_sibling
|
||||||
current_position_sibling.at_bottom? ? move_below(current_position_sibling) : move_above(current_position_sibling)
|
move_above(current_position_sibling)
|
||||||
elsif self.parent != new_parent
|
elsif self.parent != new_parent
|
||||||
self.parent = new_parent
|
self.parent = new_parent
|
||||||
save!
|
save
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -24,14 +24,12 @@ class Page < Item
|
||||||
has_many :page_metas, :autosave => true, :dependent => :destroy
|
has_many :page_metas, :autosave => true, :dependent => :destroy
|
||||||
accepts_nested_attributes_for :page_parts, :allow_destroy => true
|
accepts_nested_attributes_for :page_parts, :allow_destroy => true
|
||||||
|
|
||||||
before_save :delete_empty_frontend_field
|
|
||||||
before_save :create_parts, if: Proc.new { |page| page.new_record? || page.design_id_changed? }
|
before_save :create_parts, if: Proc.new { |page| page.new_record? || page.design_id_changed? }
|
||||||
after_save :generate_html
|
before_save :delete_empty_frontend_field, :generate_html
|
||||||
|
|
||||||
# protected
|
protected
|
||||||
|
|
||||||
def create_parts
|
def create_parts
|
||||||
|
|
||||||
page_design = self.design
|
page_design = self.design
|
||||||
parent = self.parent
|
parent = self.parent
|
||||||
menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent
|
menu_part = parent.page_parts.detect{|page_part| page_part.kind.eql?('public_r_tag') && page_part.public_r_tag.eql?('sub_menu') && page_part.public_r_tag_object_id.eql?(parent.id.to_s)} if parent
|
||||||
|
@ -73,10 +71,7 @@ class Page < Item
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_html
|
def generate_html
|
||||||
Page.without_callback(:save, :after, :generate_html) do
|
self.content_translations = parse_page_noko(self, Site.first)
|
||||||
self.content_translations = parse_page_noko(self, Site.first)
|
|
||||||
self.save
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -350,10 +350,26 @@ namespace :migrate do
|
||||||
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/gallery/gallery.json").read).save
|
ModuleApp.new.from_json(File.open("#{Rails.root}/vendor/built_in_modules/gallery/gallery.json").read).save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
task :make_default_widget_work_config => :environment do
|
task :make_default_widget_work_config => :environment do
|
||||||
a = ModuleApp.where(:key=>'announcement').first
|
a = ModuleApp.where(:key=>'announcement').first
|
||||||
a.widgets[:default_widget] = ['typeA','typeC','typeB_style2','typeB_style3','typeB_style4']
|
a.widgets[:default_widget] = ['typeA','typeC','typeB_style2','typeB_style3','typeB_style4']
|
||||||
a.widget_fields = ["title","bulletin_category","postdate"]
|
a.widget_fields = ["title","bulletin_category","postdate"]
|
||||||
a.save
|
a.save
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
task :reorder_items => :environment do
|
||||||
|
reorder_children(Item.root)
|
||||||
|
end
|
||||||
|
|
||||||
|
def reorder_children(parent)
|
||||||
|
parent.children.each_with_index do |child, i|
|
||||||
|
child.position = i
|
||||||
|
child.save
|
||||||
|
reorder_children(child) if child.children
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -177,7 +177,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController
|
||||||
theater_link: panel_gallery_back_end_album_image_path(values),
|
theater_link: panel_gallery_back_end_album_image_path(values),
|
||||||
description: values.description,
|
description: values.description,
|
||||||
title: values.title,
|
title: values.title,
|
||||||
file: values.file,
|
file: values.file.as_json[:file],
|
||||||
gallery_album_id: values.gallery_album_id,
|
gallery_album_id: values.gallery_album_id,
|
||||||
tag_ids: values.tag_ids,
|
tag_ids: values.tag_ids,
|
||||||
tag_names: tags}
|
tag_names: tags}
|
||||||
|
|
|
@ -1,110 +1,104 @@
|
||||||
class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
|
class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController
|
||||||
|
def index
|
||||||
|
end
|
||||||
|
|
||||||
def index
|
def show
|
||||||
|
@album = GalleryAlbum.find(params[:id])
|
||||||
|
@tags = Array.new
|
||||||
|
@album.tag_ids.each do |tag|
|
||||||
|
@tags << GalleryTag.find(tag)[I18n.locale]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
def get_albums
|
||||||
|
@categoryids = params["cid"]
|
||||||
|
@tags = params["tid"]
|
||||||
|
@albums = Array.new
|
||||||
|
if @categoryids == "all"
|
||||||
|
if @tags
|
||||||
|
if @tags.kind_of?(Array)
|
||||||
|
@tags.each do |tag|
|
||||||
|
@albums << GalleryAlbum.where(tag_ids: tag)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@albums << GalleryAlbum.where(tag_ids: @tags)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@albums << GalleryAlbum.all
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@categoryids.each do |id|
|
||||||
|
category = GalleryCategory.find(id)
|
||||||
|
if @tags
|
||||||
|
if @tags.kind_of?(Array)
|
||||||
|
@tags.each do |tag|
|
||||||
|
@albums << category.gallery_albums.where(tag_ids: tag)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@albums << category.gallery_albums.where(tag_ids: @tags)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
@albums << category.gallery_albums.all
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@output = Array.new
|
||||||
|
@albums.each do |album|
|
||||||
|
@albs = Array.new
|
||||||
|
album.each do |values|
|
||||||
|
tags = Array.new
|
||||||
|
values.tag_ids.each do |tag|
|
||||||
|
tags << GalleryTag.find(tag)[I18n.locale]
|
||||||
|
end
|
||||||
|
category = GalleryCategory.find(values.gallery_category_id).name
|
||||||
|
@albs << {"_id"=>values.id,"show_path"=>panel_gallery_front_end_album_path(values),"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags}
|
||||||
|
end
|
||||||
|
@output << @albs
|
||||||
|
end
|
||||||
|
render :json=>@output.to_json
|
||||||
|
end
|
||||||
|
|
||||||
def show
|
def imgs
|
||||||
@album = GalleryAlbum.find(params[:id])
|
@album = GalleryAlbum.find(params[:id])
|
||||||
@tags = Array.new
|
@images = @album.gallery_images.all
|
||||||
@album.tag_ids.each do |tag|
|
@output = Array.new
|
||||||
@tags << GalleryTag.find(tag)[I18n.locale]
|
@images.each do |values|
|
||||||
end
|
tags = Array.new
|
||||||
|
values.tag_ids.each do |tag|
|
||||||
end
|
tags << GalleryTag.find(tag)[I18n.locale]
|
||||||
|
end
|
||||||
def get_albums
|
@output << {:_id => values.id,
|
||||||
@categoryids = params["cid"]
|
:theater_link => theater_panel_gallery_front_end_album_path(values),
|
||||||
@tags = params["tid"]
|
:description => values.description,
|
||||||
@albums = Array.new
|
:title => values.title,
|
||||||
if @categoryids == "all"
|
:file => values.file.as_json[:file],
|
||||||
if @tags
|
:gallery_album_id => values.gallery_album_id,
|
||||||
if @tags.kind_of?(Array)
|
:tag_ids => values.tag_ids,
|
||||||
@tags.each do |tag|
|
:tag_names => tags}
|
||||||
@albums << GalleryAlbum.where(tag_ids: tag)
|
end
|
||||||
end
|
render :json=>{:images => @output}.to_json
|
||||||
else
|
end
|
||||||
@albums << GalleryAlbum.where(tag_ids: @tags)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
@albums << GalleryAlbum.all
|
|
||||||
end
|
|
||||||
else
|
|
||||||
@categoryids.each do |id|
|
|
||||||
category = GalleryCategory.find(id)
|
|
||||||
if @tags
|
|
||||||
if @tags.kind_of?(Array)
|
|
||||||
@tags.each do |tag|
|
|
||||||
@albums << category.gallery_albums.where(tag_ids: tag)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
@albums << category.gallery_albums.where(tag_ids: @tags)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
@albums << category.gallery_albums.all
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@output = Array.new
|
|
||||||
@albums.each do |album|
|
|
||||||
@albs = Array.new
|
|
||||||
album.each do |values|
|
|
||||||
tags = Array.new
|
|
||||||
values.tag_ids.each do |tag|
|
|
||||||
tags << GalleryTag.find(tag)[I18n.locale]
|
|
||||||
end
|
|
||||||
category = GalleryCategory.find(values.gallery_category_id).name
|
|
||||||
@albs << {"_id"=>values.id,"show_path"=>panel_gallery_front_end_album_path(values),"cover"=>values.cover,"cover_path"=>values.cover_path,"description"=>values.description,"category_name"=>category,"gallery_category_id" => values.gallery_category_id,"name"=>values.name,"tag_ids"=>values.tag_ids,"tag_names"=>tags}
|
|
||||||
end
|
|
||||||
@output << @albs
|
|
||||||
end
|
|
||||||
render :json=>@output.to_json
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def imgs
|
|
||||||
@album = GalleryAlbum.find(params[:id])
|
|
||||||
@images = @album.gallery_images.all
|
|
||||||
@output = Array.new
|
|
||||||
@images.each do |values|
|
|
||||||
tags = Array.new
|
|
||||||
values.tag_ids.each do |tag|
|
|
||||||
tags << GalleryTag.find(tag)[I18n.locale]
|
|
||||||
end
|
|
||||||
@output << {"_id"=>values.id,"theater_link"=>theater_panel_gallery_front_end_album_path(values),"description"=>values.description,"title"=>values.title,"file"=>values.file,"gallery_album_id"=>values.gallery_album_id,"tag_ids"=>values.tag_ids,"tag_names"=>tags}
|
|
||||||
end
|
|
||||||
render :json=>{"images" => @output}.to_json
|
|
||||||
end
|
|
||||||
|
|
||||||
def images_tags
|
|
||||||
album = GalleryAlbum.find(params[:album_id])
|
|
||||||
tags = Array.new
|
|
||||||
images = album.gallery_images.all
|
|
||||||
images.each do |image|
|
|
||||||
tags << {"id"=>image.id, "tags" => image.tag_ids}
|
|
||||||
end
|
|
||||||
render :json=>tags.to_json
|
|
||||||
end
|
|
||||||
|
|
||||||
def theater
|
|
||||||
@image = GalleryImage.find(params[:id])
|
|
||||||
@albumid = @image.gallery_album_id
|
|
||||||
@album = GalleryAlbum.find(@albumid)
|
|
||||||
@images = @album.gallery_images.all
|
|
||||||
tags = @album.tag_ids
|
|
||||||
@tagnames = Array.new
|
|
||||||
tags.each do |tag|
|
|
||||||
@tagnames << GalleryTag.find(tag)[I18n.locale]
|
|
||||||
end
|
|
||||||
@back_link = panel_gallery_front_end_album_path(@albumid)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
def images_tags
|
||||||
|
album = GalleryAlbum.find(params[:album_id])
|
||||||
|
tags = Array.new
|
||||||
|
images = album.gallery_images.all
|
||||||
|
images.each do |image|
|
||||||
|
tags << {"id"=>image.id, "tags" => image.tag_ids}
|
||||||
|
end
|
||||||
|
render :json=>tags.to_json
|
||||||
|
end
|
||||||
|
|
||||||
|
def theater
|
||||||
|
@image = GalleryImage.find(params[:id])
|
||||||
|
@albumid = @image.gallery_album_id
|
||||||
|
@album = GalleryAlbum.find(@albumid)
|
||||||
|
@images = @album.gallery_images.all
|
||||||
|
tags = @album.tag_ids
|
||||||
|
@tagnames = Array.new
|
||||||
|
tags.each do |tag|
|
||||||
|
@tagnames << GalleryTag.find(tag)[I18n.locale]
|
||||||
|
end
|
||||||
|
@back_link = panel_gallery_front_end_album_path(@albumid)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue