Class: Pageflow::Editor::FilesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Pageflow::Editor::FilesController
- Defined in:
- app/controllers/pageflow/editor/files_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #publish ⇒ Object
- #retry ⇒ Object
- #reuse ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/controllers/pageflow/editor/files_controller.rb', line 17 def create entry = DraftEntry.find(params[:entry_id]) (:edit, entry.to_model) verify_edit_lock!(entry) @file = entry.create_file!(file_type, create_params) @file.publish! if params[:no_upload] respond_with(:editor, @file) rescue ActiveRecord::RecordInvalid, DraftEntry::InvalidForeignKeyCustomAttributeError => e debug_log_with_backtrace(e) head :unprocessable_entity end |
#destroy ⇒ Object
80 81 82 83 84 85 86 87 88 89 |
# File 'app/controllers/pageflow/editor/files_controller.rb', line 80 def destroy entry = DraftEntry.find(params[:entry_id]) file = entry.find_file(file_type.model, params[:id]) (:edit, entry.to_model) verify_edit_lock!(entry) entry.remove_file(file) head(:no_content) end |
#index ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'app/controllers/pageflow/editor/files_controller.rb', line 8 def index entry = DraftEntry.find(params[:entry_id]) (:use_files, entry.to_model) @files = entry.find_files(file_type.model) respond_with(:editor, @files) end |
#publish ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'app/controllers/pageflow/editor/files_controller.rb', line 60 def publish entry = DraftEntry.find(params[:entry_id]) file = entry.find_file(file_type.model, params[:id]) (:update, file.to_model) file.publish! head(:no_content) end |
#retry ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/pageflow/editor/files_controller.rb', line 46 def retry entry = DraftEntry.find(params[:entry_id]) file = entry.find_file(file_type.model, params[:id]) (:retry, file.to_model) file.retry! respond_with(:editor, file, location: editor_entry_file_url(file, entry, collection_name: params[:collection_name])) end |
#reuse ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controllers/pageflow/editor/files_controller.rb', line 31 def reuse entry = DraftEntry.find(params[:entry_id]) other_entry = DraftEntry.find(file_reuse_params[:other_entry_id]) file_reuse = FileReuse.new(entry, other_entry, file_type, file_reuse_params[:file_id]) (:edit, entry.to_model) (:use, file_reuse.file.to_model) verify_edit_lock!(entry) file_reuse.save! redirect_to(editor_entry_url(entry)) end |
#update ⇒ Object
70 71 72 73 74 75 76 77 78 |
# File 'app/controllers/pageflow/editor/files_controller.rb', line 70 def update entry = DraftEntry.find(params[:entry_id]) file = entry.find_file(file_type.model, params[:id]) (:update, file.to_model) file.update!(update_params) head(:no_content) end |