Class: Spina::Admin::PhotosController
Instance Method Summary
collapse
#captcha, #current_account, #error_explanation!, #image_tag_with_at2x, #link_to_add_fields, #markdown
Instance Method Details
#create ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 16
def create
@photo = Photo.create!(photo_params)
respond_to do |format|
format.js
format.json do
render json: { file_url: @photo.file_url }
end
end
end
|
#destroy ⇒ Object
26
27
28
29
30
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 26
def destroy
@photo = Photo.find(params[:id])
@photo.destroy
redirect_to spina.admin_photos_url
end
|
#enhance ⇒ Object
32
33
34
35
36
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 32
def enhance
@photo = Photo.find(params[:id])
@photo.remote_file_url = params[:new_image]
@photo.save
end
|
#index ⇒ Object
10
11
12
13
14
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 10
def index
add_breadcrumb I18n.t('spina.website.photos'), spina.admin_photos_path
@photos = Photo.sorted.page(params[:page])
@photo = Photo.new
end
|
#insert_photo ⇒ Object
68
69
70
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 68
def insert_photo
@photo = Photo.find(params[:photo_id]) if params[:photo_id].present?
end
|
#insert_photo_collection ⇒ Object
72
73
74
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 72
def insert_photo_collection
@photos = Photo.find(params[:photo_ids]) if params[:photo_ids].present?
end
|
#link ⇒ Object
38
39
40
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 38
def link
@photo = Photo.find(params[:id])
end
|
#photo_collection_select ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 55
def photo_collection_select
selected = params[:selected_photo_ids] || Array.new
@photos = Photo.order_by_ids(selected).sorted.page(params[:page])
@selected_photos = Photo.where(id: selected)
@photo = Photo.new
if params[:page].present?
render :multi_picker_infinite_scroll
else
render :photo_collection_select
end
end
|
#photo_select ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 42
def photo_select
selected = params[:selected_photo_id] || Array.new
@photos = Photo.order_by_ids(selected).sorted.page(params[:page])
@selected_photo = Photo.find(selected)
@photo = Photo.new
if params[:page].present?
render :single_picker_infinite_scroll
else
render :photo_select
end
end
|
#wysihtml5_insert ⇒ Object
76
77
78
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 76
def wysihtml5_insert
@photo = Photo.find(params[:photo_id])
end
|
#wysihtml5_select ⇒ Object
80
81
82
83
84
85
86
87
88
89
|
# File 'app/controllers/spina/admin/photos_controller.rb', line 80
def wysihtml5_select
@photos = Photo.sorted.page(params[:page])
@photo = Photo.new
if params[:page].present?
render :wysihtml5_infinite_scroll
else
render :wysihtml5_select
end
end
|