Class: Gluttonberg::Admin::Content::GalleriesController

Inherits:
BaseController show all
Includes:
ActionView::Helpers::TextHelper
Defined in:
app/controllers/gluttonberg/admin/content/galleries_controller.rb

Overview

Manage image/video gallery

Instance Method Summary collapse

Instance Method Details

#createObject



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/gluttonberg/admin/content/galleries_controller.rb', line 27

def create
  clean_empty_repeater
  @gallery = Gallery.new(params[:gluttonberg_gallery])
  @gallery.user_id = current_user.id if @gallery.user_id.blank?
  if @gallery.save
    @gallery.save_collection_images(params, current_user)
    flash[:notice] = "The gallery was successfully created."
    redirect_to edit_admin_gallery_path(@gallery)
  else
    prepare_repeaters
    render :new
  end
end

#deleteObject



58
59
60
61
62
63
64
65
# File 'app/controllers/gluttonberg/admin/content/galleries_controller.rb', line 58

def delete
  display_delete_confirmation(
    :title      => "Delete gallery '#{@gallery.name}'?",
    :url        => admin_gallery_path(@gallery),
    :return_url => admin_galleries_path,
    :warning    => ""
  )
end

#destroyObject



67
68
69
70
71
72
73
# File 'app/controllers/gluttonberg/admin/content/galleries_controller.rb', line 67

def destroy
  generic_destroy(@gallery, {
    :name => "gallery",
    :success_path => admin_galleries_path,
    :failure_path => admin_galleries_path
  })
end

#editObject



41
42
43
# File 'app/controllers/gluttonberg/admin/content/galleries_controller.rb', line 41

def edit
  prepare_repeaters
end

#indexObject



18
19
20
# File 'app/controllers/gluttonberg/admin/content/galleries_controller.rb', line 18

def index
  @galleries = Gallery.paginate(:per_page => Gluttonberg::Setting.get_setting("number_of_per_page_items"), :page => params[:page])
end

#newObject



22
23
24
25
# File 'app/controllers/gluttonberg/admin/content/galleries_controller.rb', line 22

def new
  @gallery = Gallery.new
  prepare_repeaters
end

#updateObject



45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/gluttonberg/admin/content/galleries_controller.rb', line 45

def update
  clean_empty_repeater
  if @gallery.update_attributes(params[:gluttonberg_gallery])
    @gallery.save_collection_images(params, current_user)
    flash[:notice] = "The gallery was successfully updated."
    redirect_to edit_admin_gallery_path(@gallery)
  else
    prepare_repeaters
    flash[:error] = "Sorry, The gallery could not be updated."
    render :edit
  end
end