diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 2564ae5e..b457b74d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -345,7 +345,6 @@ class ApplicationController < ActionController::Base if (!user_signed_in? && object_class == "bulletin") objects = get_bulletins_for_open_backend(objects) end - Kaminari.paginate_array(filter_authorized_objects(objects)).page(params[:page]).per(10) end diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index 275a1950..febe7de8 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -188,9 +188,11 @@ class PagesController < ApplicationController else if params[:action] && params[:action] == "show_from_link" default_widget = module_app.get_default_widget - model = eval(default_widget["query"]) - item = model.find(params[:id]) - @item = Item.where(:category => [item.category_id.to_s]).first + if !default_widget.blank? + model = eval(params[:app_action].classify.constantize) + item = model.find(params[:id]) + @item = Item.where(:category => [item.category_id.to_s]).first + end end end diff --git a/lib/tasks/migrate.rake b/lib/tasks/migrate.rake index 7cd8ddaa..f166b8bb 100644 --- a/lib/tasks/migrate.rake +++ b/lib/tasks/migrate.rake @@ -122,7 +122,7 @@ namespace :migrate do a.widgets = {} a.widgets[:widget1] = [] a.widget_options_fields_i18n = {"widget1"=>{"vertical"=>"gallery.widget_option.vertical", "horizontal"=>"gallery.widget_option.horizontal", "album_id"=>"gallery.album"}} - a.widget_options = {"widget1"=>{"vertical"=>[1, 2], "horizontal"=>[1, 2, 3, 4, 5, 6], "album_id"=>{"query"=>"GalleryAlbum.all", "value"=>:id, "label"=>:name}}} + a.widget_options = {"widget1"=>{"vertical"=>[1, 2], "horizontal"=>[1, 2, 3, 4, 5, 6], "album_id"=>{"query"=>"Album.all", "value"=>:id, "label"=>:name}}} a.save end diff --git a/lib/tasks/new_ui.rake b/lib/tasks/new_ui.rake index 131d3a9f..00d1e1e1 100644 --- a/lib/tasks/new_ui.rake +++ b/lib/tasks/new_ui.rake @@ -5,7 +5,7 @@ namespace :new_ui do %w(ask ask_question ask_category), %w(asset asset), %w(faq qa), - %w(gallery gallery_album gallery_category), + %w(gallery album gallery_category), %w(location location), %w(personal_book writing_book), %w(personal_conference writing_conference), diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/album_images_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/album_images_controller.rb index 2cd280c2..a5310f7d 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/album_images_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/album_images_controller.rb @@ -6,32 +6,32 @@ class Panel::Gallery::BackEnd::AlbumImagesController < OrbitBackendController def show @tags = get_tags - @image = GalleryImage.find(params[:id]) - @albumid = @image.gallery_album_id - @album = GalleryAlbum.find(@albumid) - @images = @album.gallery_images.all + @image = AlbumImage.find(params[:id]) + @albumid = @image.album_id + @album = Album.find(@albumid) + @images = @album.album_images.all end def destroy images = params['images'] images.each do |image| - img = GalleryImage.find(image) + img = AlbumImage.find(image) img.delete end if params['delete_cover'] == "true" - album = GalleryAlbum.find(params['id']) + album = Album.find(params['id']) album.update_attributes(:cover=>"default",:cover_path => nil) end render :json =>{"success"=>true}.to_json end def update_image - image = GalleryImage.find(params[:image_id]) - image.update_attributes(params[:gallery_image]) + image = AlbumImage.find(params[:image_id]) + image.update_attributes(params[:album_image]) image.save - @album = GalleryAlbum.find(image.gallery_album_id.to_s) - @images = @album.gallery_images + @album = Album.find(image.album_id.to_s) + @images = @album.album_images @image_content = [] @images.each do |image| @image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tagged_ids} @@ -42,11 +42,11 @@ class Panel::Gallery::BackEnd::AlbumImagesController < OrbitBackendController def delete_photos images = params['images'] images.each do |image| - img = GalleryImage.find(image) + img = AlbumImage.find(image) img.delete end if params['delete_cover'] == "true" - album = GalleryAlbum.find(params['album_id']) + album = Album.find(params['album_id']) album.update_attributes(:cover=>"default",:cover_path => nil) end render :json =>{"success"=>true}.to_json @@ -57,13 +57,13 @@ class Panel::Gallery::BackEnd::AlbumImagesController < OrbitBackendController tags = params[:tag_ids] i = nil images.each do |image| - img = GalleryImage.find(image) + img = AlbumImage.find(image) img.tagged_ids = tags img.save i = img end - @album = GalleryAlbum.find(i.gallery_album_id.to_s) - @images = @album.gallery_images + @album = Album.find(i.album_id.to_s) + @images = @album.album_images @image_content = [] @images.each do |image| @image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tagged_ids} diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb index 0240663d..ad5bc97c 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/back_end/albums_controller.rb @@ -13,12 +13,12 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController @categories = get_categories_for_index @tags = get_tags category_ids = @categories.collect{|t| t.id} - @albums = get_sorted_and_filtered("gallery_album", :category_id.in => category_ids) + @albums = get_sorted_and_filtered("album", :category_id.in => category_ids) end def show - @album = GalleryAlbum.find(params[:id]) - @images = @album.gallery_images + @album = Album.find(params[:id]) + @images = @album.album_images @image_content = [] @images.each do |image| @image_content << {"id" => image.id.to_s, "description" => image.description_translations,"tags" => image.tagged_ids} @@ -33,12 +33,12 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController def new @categories = get_categories_for_index @tags = get_tags - @album = GalleryAlbum.new + @album = Album.new end def create - album = GalleryAlbum.new(params[:gallery_album]) + album = Album.new(params[:album]) album.save! redirect_to panel_gallery_back_end_albums_path end @@ -46,31 +46,31 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController def destroy - album = GalleryAlbum.find(params[:id]) + album = Album.find(params[:id]) album.destroy redirect_to panel_gallery_back_end_albums_path end def edit - @album = GalleryAlbum.find(params[:id]) + @album = Album.find(params[:id]) @tags = get_tags end def set_cover if params[:set_cover] == "true" - album = GalleryAlbum.find(params[:album_id]) - image = GalleryImage.find(params[:image_id]) + album = Album.find(params[:album_id]) + image = AlbumImage.find(params[:image_id]) album.update_attributes({:cover_path => image.file.thumb.url, :cover=>params[:image_id]}) else - album = GalleryAlbum.find(params[:album_id]) + album = Album.find(params[:album_id]) album.update_attributes({:cover_path => nil, :cover=>"default"}) end render :json =>{"success"=>true}.to_json end def get_album_json - albums = GalleryAlbum.all + albums = Album.all output = Array.new albums.each do |album| @@ -96,8 +96,8 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController end def get_imgs_json - album = GalleryAlbum.find(params[:album_id]) - images = album.gallery_images.all + album = Album.find(params[:album_id]) + images = album.album_images.all output = Array.new images.each do |image| @@ -119,9 +119,9 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController end def imgs - @album = GalleryAlbum.find(params[:album_id]) + @album = Album.find(params[:album_id]) @tag_names = Array.new - @images = @album.gallery_images.all + @images = @album.album_images.all @output = Array.new @images.each do |values| tags = Array.new @@ -133,7 +133,7 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController description: values.description, title: values.title, file: values.file.as_json[:file], - gallery_album_id: values.gallery_album_id, + gallery_album_id: values.album_id, tag_ids: values.tag_ids, tag_names: tags} end @@ -143,11 +143,11 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController def upload_image - @album = GalleryAlbum.find(params[:album_id]) + @album = Album.find(params[:album_id]) @files = params['files'] a = Array.new @files.each do |file| - @image = @album.gallery_images.new + @image = @album.album_images.new @image.file = file @image.save! a << {"thumbnail_url"=>@image.file.thumb.url,"url"=>panel_gallery_back_end_album_image_path(@image)} @@ -157,21 +157,21 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController def new_images if params[:last_image_id] != "" - @lastimage = GalleryImage.find(params[:last_image_id]) - @album = GalleryAlbum.find(params[:album_id]) - @newimages = @album.gallery_images.where(:created_at.gt => @lastimage.created_at) + @lastimage = AlbumImage.find(params[:last_image_id]) + @album = Album.find(params[:album_id]) + @newimages = @album.album_images.where(:created_at.gt => @lastimage.created_at) else - @album = GalleryAlbum.find(params[:album_id]) - @newimages = @album.gallery_images + @album = Album.find(params[:album_id]) + @newimages = @album.album_images end render :layout=>false end def images_tags - album = GalleryAlbum.find(params[:album_id]) + album = Album.find(params[:album_id]) tags = Array.new - images = album.gallery_images.all + images = album.album_images.all images.each do |image| tags << {"id"=>image.id, "tags" => image.tag_ids} end @@ -179,10 +179,10 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController end def update - @album = GalleryAlbum.find(params[:id]) + @album = Album.find(params[:id]) tagsToDestroy = [] tagsToAdd = [] - new_tags = params[:gallery_album][:tag_ids] + new_tags = params[:album][:tag_ids] old_tags = @album.tagged_ids old_tags.each do |tag| if !new_tags.include?(tag) @@ -197,14 +197,14 @@ class Panel::Gallery::BackEnd::AlbumsController < OrbitBackendController end end update_children_image_tag(tagsToDestroy,tagsToAdd) - @album.update_attributes(params[:gallery_album]) + @album.update_attributes(params[:album]) redirect_to panel_gallery_back_end_album_path(@album) end def update_children_image_tag(tagsToDestroy,tagsToAdd) # tagsToDestroy will contain all tag ids which have to be deleted from the galley_images - # tagsToAdd will contain all tag ids which ve to be added in tall gallery_images - @images = GalleryImage.all + # tagsToAdd will contain all tag ids which ve to be added in tall album_images + @images = AlbumImage.all @images.each do |image| image.tagged_ids.concat(tagsToAdd) tagsToDestroy.each do |tag| diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb index ec8e8849..d8375af8 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/front_end/albums_controller.rb @@ -1,16 +1,16 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController def index - @albums = GalleryAlbum.where(:category_id.in => params[:category_id]) + @albums = Album.where(:category_id.in => params[:category_id]) end def show - @album = GalleryAlbum.find(params[:id]) - @images = @album.gallery_images + @album = Album.find(params[:id]) + @images = @album.album_images end def imgs - @album = GalleryAlbum.find(params[:id]) - @images = @album.gallery_images.all + @album = Album.find(params[:id]) + @images = @album.album_images.all @output = Array.new @images.each do |values| tags = Tag.find(values.tagged_ids).map{|t| t.name} @@ -19,7 +19,7 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController :description => values.description, :title => values.title, :file => values.file.as_json[:file], - :gallery_album_id => values.gallery_album_id, + :gallery_album_id => values.album_id, :tag_ids => values.tag_ids, :tag_names => tags} end @@ -27,9 +27,9 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController end def images_tags - album = GalleryAlbum.find(params[:album_id]) + album = Album.find(params[:album_id]) tags = Array.new - images = album.gallery_images.all + images = album.album_images.all images.each do |image| tags << {"id"=>image.id, "tags" => image.tag_ids} end @@ -37,10 +37,10 @@ class Panel::Gallery::FrontEnd::AlbumsController < OrbitWidgetController end def theater - @image = GalleryImage.find(params[:id]) - @albumid = @image.gallery_album_id - @album = GalleryAlbum.find(@albumid) - @images = @album.gallery_images.all + @image = AlbumImage.find(params[:id]) + @albumid = @image.album_id + @album = Album.find(@albumid) + @images = @album.album_images.all tags = @album.tagged_ids @tagnames = Tag.find(tags).map{|t| t.name} @back_link = panel_gallery_front_end_album_path(@albumid) diff --git a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/widget/albums_controller.rb b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/widget/albums_controller.rb index 6ff4f1c6..5c974815 100644 --- a/vendor/built_in_modules/gallery/app/controllers/panel/gallery/widget/albums_controller.rb +++ b/vendor/built_in_modules/gallery/app/controllers/panel/gallery/widget/albums_controller.rb @@ -6,8 +6,8 @@ class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController vertical = @part.widget_options['vertical'].to_i rescue 0 horizontal = @part.widget_options['horizontal'].to_i rescue 0 - @album = GalleryAlbum.find(@part.widget_options['album_id']) rescue nil - @album_images = @album.gallery_images if @album + @album = Album.find(@part.widget_options['album_id']) rescue nil + @album_images = @album.album_images if @album @settings = {"vertical"=>vertical,"horizontal"=>horizontal} #[note] horizontal has it's limitation from 2 to 6 @@ -16,27 +16,34 @@ class Panel::Gallery::Widget::AlbumsController < OrbitWidgetController @rnd = Random.new @images = [] - if @album_images.count > @total - @randoms = [] - until @randoms.count == @total do - r = @rnd.rand(0...@album_images.count) - if !@randoms.include?r - @randoms << r - image = @album_images[r] + if !@album_images.nil? + if @album_images.count > @total + @randoms = [] + until @randoms.count == @total do + r = @rnd.rand(0...@album_images.count) + if !@randoms.include?r + @randoms << r + image = @album_images[r] + values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} + @images << values + end + end + elsif @album_images.count == @total + @album_images.each do |image| values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} @images << values end - end - elsif @album_images.count == @total - @album_images.each do |image| - values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} - @images << values + else + @album_images.each do |image| + values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} + @images << values + end + until @images.count == @total do + values = {"show_link"=>"javascript:void(0);","thumb"=>"assets/gallery/nodata.jpg"} + @images << values + end end else - @album_images.each do |image| - values = {"show_link"=>theater_panel_gallery_front_end_album_path(image),"thumb"=>image.file.thumb.url} - @images << values - end until @images.count == @total do values = {"show_link"=>"javascript:void(0);","thumb"=>"assets/gallery/nodata.jpg"} @images << values diff --git a/vendor/built_in_modules/gallery/app/models/gallery_album.rb b/vendor/built_in_modules/gallery/app/models/album.rb similarity index 68% rename from vendor/built_in_modules/gallery/app/models/gallery_album.rb rename to vendor/built_in_modules/gallery/app/models/album.rb index 4cc0fbc7..c46e0062 100644 --- a/vendor/built_in_modules/gallery/app/models/gallery_album.rb +++ b/vendor/built_in_modules/gallery/app/models/album.rb @@ -1,4 +1,4 @@ -class GalleryAlbum +class Album include Mongoid::Document include Mongoid::Timestamps @@ -12,7 +12,7 @@ class GalleryAlbum field :tag_names # has_and_belongs_to_many :tags, :class_name => "GalleryTag" - has_many :gallery_images, :autosave => true, :dependent => :destroy - accepts_nested_attributes_for :gallery_images, :allow_destroy => true + has_many :album_images, :autosave => true, :dependent => :destroy + accepts_nested_attributes_for :album_images, :allow_destroy => true end \ No newline at end of file diff --git a/vendor/built_in_modules/gallery/app/models/gallery_image.rb b/vendor/built_in_modules/gallery/app/models/album_image.rb similarity index 83% rename from vendor/built_in_modules/gallery/app/models/gallery_image.rb rename to vendor/built_in_modules/gallery/app/models/album_image.rb index 1fda445f..fcaa0b38 100644 --- a/vendor/built_in_modules/gallery/app/models/gallery_image.rb +++ b/vendor/built_in_modules/gallery/app/models/album_image.rb @@ -1,4 +1,4 @@ -class GalleryImage +class AlbumImage include Mongoid::Document include Mongoid::Timestamps include OrbitTag::Taggable @@ -10,6 +10,6 @@ class GalleryImage # has_and_belongs_to_many :tags, :class_name => "GalleryTag" - belongs_to :gallery_album + belongs_to :album end \ No newline at end of file diff --git a/vendor/built_in_modules/gallery/app/models/gallery_category.rb b/vendor/built_in_modules/gallery/app/models/gallery_category.rb index 07c5df8c..547fa50a 100644 --- a/vendor/built_in_modules/gallery/app/models/gallery_category.rb +++ b/vendor/built_in_modules/gallery/app/models/gallery_category.rb @@ -9,7 +9,7 @@ class GalleryCategory field :name, localize: true - has_many :gallery_albums, :autosave => true, :dependent => :destroy + has_many :albums, :autosave => true, :dependent => :destroy def title name diff --git a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/album_images/show.html.erb b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/album_images/show.html.erb index c85d8f54..25553aa6 100644 --- a/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/album_images/show.html.erb +++ b/vendor/built_in_modules/gallery/app/views/panel/gallery/back_end/album_images/show.html.erb @@ -6,7 +6,7 @@