Add move operation for documents plugin

This commit is contained in:
Patrick Gansterer 2020-03-06 14:30:27 +01:00
parent 3fb3fa409b
commit 3a4519757e
10 changed files with 41 additions and 0 deletions

View file

@ -43,6 +43,14 @@ class DocumentsController < ApplicationController
redirect_to @document.parent || documents_path, alert: t('.error', error: error.message)
end
def update
@document = Document.find(params[:id])
@document.update_attribute(:parent_id, params[:parent_id])
redirect_to @document.parent || documents_path, notice: t('.notice')
rescue => error
redirect_to @document.parent || documents_path, alert: t('errors.general_msg', msg: error.message)
end
def destroy
@document = Document.find(params[:id])
if @document.created_by == current_user or current_user.role_admin?
@ -65,6 +73,10 @@ class DocumentsController < ApplicationController
end
end
def move
@document = Document.find(params[:document_id])
end
def allowed_mime?(mime)
whitelist = FoodsoftConfig[:documents_allowed_extension].split
MIME::Types.type_for(whitelist).each do |type|