Class: Adminpanel::GalleriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/adminpanel/galleries_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#get_menu_elements, #handle_unverified_request, #set_model, #signed_in_user

Methods included from RouterHelper

#adminpanel_resources, #default_controllers, #find_resources, #menu_items, #resources_path

Methods included from SessionsHelper

#current_user, #current_user=, #sign_in, #sign_out, #signed_in?

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
# File 'app/controllers/adminpanel/galleries_controller.rb', line 15

def create
  @gallery = Gallery.new(params[:gallery])

  if @gallery.save
    redirect_to gallery_path(@gallery), :notice => t("gallery.success")
  else
    render 'new'
  end
end

#destroyObject



61
62
63
64
65
66
# File 'app/controllers/adminpanel/galleries_controller.rb', line 61

def destroy
  @gallery = Gallery.find(params[:id])
  @gallery.destroy

  redirect_to galleries_path, :notice => t("gallery.deleted")
end

#editObject



11
12
13
# File 'app/controllers/adminpanel/galleries_controller.rb', line 11

def edit
  @gallery = Gallery.find(params[:id])
end

#indexObject



3
4
5
# File 'app/controllers/adminpanel/galleries_controller.rb', line 3

def index
  @galleries = Gallery.find(:all)
end

#move_betterObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/adminpanel/galleries_controller.rb', line 25

def move_better
  @gallery = Gallery.find(params[:id])
  if @gallery.move_to_better_position
    flash[:success] = t("gallery.moved")
  else
    flash[:warning] = t("gallery.not-moved")
  end
    respond_to do |format|
      format.html do 
        redirect_to galleries_path 
      end
      format.js do
        @galleries = Gallery.all
        render :locals => { :galleries => @galleries }
      end
    end
end

#move_worstObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'app/controllers/adminpanel/galleries_controller.rb', line 43

def move_worst
  @gallery = Gallery.find(params[:id])
  if @gallery.move_to_worst_position
    flash[:success] = t("gallery.moved")
  else
    flash[:warning] = t("gallery.not-moved")
  end
    respond_to do |format|
      format.html do 
        redirect_to galleries_path 
      end
      format.js do
        @galleries = Gallery.all
        render :locals => { :galleries => @galleries }
      end
    end
end

#newObject



77
78
79
# File 'app/controllers/adminpanel/galleries_controller.rb', line 77

def new
  @gallery = Gallery.new
end

#showObject



7
8
9
# File 'app/controllers/adminpanel/galleries_controller.rb', line 7

def show
  @gallery = Gallery.find(params[:id])
end

#updateObject



68
69
70
71
72
73
74
75
# File 'app/controllers/adminpanel/galleries_controller.rb', line 68

def update
  @gallery = Gallery.find(params[:id])
  if @gallery.update_attributes(params[:gallery])
    redirect_to gallery_path(@gallery)
  else
    render 'edit'
  end
end