Module: DcGalleryControl
- Defined in:
- app/controls/dc_gallery_control.rb
Overview
DRG CMS controls for DcGallery collection
Instance Method Summary collapse
-
#picture_remove ⇒ Object
Remove picture from gallery.
Instance Method Details
#picture_remove ⇒ Object
Remove picture from gallery.
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/controls/dc_gallery_control.rb', line 32 def picture_remove unless dc_user_can(DcPermission::CAN_DELETE, 'dc_gallery') return render json: { alert: t('drgcms.not_authorized') } end doc = DcGallery.find(params[:id]) pic = Rails.root.join('public', doc.picture.delete_prefix('/')) File.delete(pic) if File.exist?(pic) pic = Rails.root.join('public', doc.thumbnail.delete_prefix('/')) File.delete(pic) if File.exist?(pic) doc.delete render json: { reload: true } end |