New gem readyness and strong parameter fixes

This commit is contained in:
2014-07-14 18:58:23 +02:00
parent 9d25f38bbf
commit 372231b1b7
9 changed files with 82 additions and 49 deletions
@@ -1,10 +1,10 @@
<% cmtool = Cmtool::Engine.routes.url_helpers %>
$( ->
$('textarea.mceEditor, .editor_full').tinymce(
theme: 'advanced',
plugins: 'advimage',
theme: 'modern',
plugins: 'image',
language: tinymce_language,
external_image_list_url: '<%= cmtool.images_path(format: :js) %>',
image_list: '<%= cmtool.images_path(format: :js) %>',
relative_urls: false
)
$('.editor_basic').tinymce({theme: 'simple', language: tinymce_language})
@@ -41,7 +41,7 @@ module Cmtool
# POST /directories
# POST /directories.xml
def create
@directory = Cmtool::Directory.new(params[:directory])
@directory = Cmtool::Directory.new(directory_params)
respond_to do |format|
if @directory.save
@@ -60,7 +60,7 @@ module Cmtool
@directory = Cmtool::Directory.find(params[:id])
respond_to do |format|
if @directory.update_attributes(params[:directory])
if @directory.update_attributes(directory_params)
format.html { redirect_to([cmtool, @directory], :notice => I18n.t('cmtool.action.update.successful', :model => Cmtool::Directory.model_name.human)) }
format.xml { head :ok }
else
@@ -86,5 +86,9 @@ module Cmtool
@directory.image = nil
@directory.save
end
def directory_params
params.require(:directory).permit(:name, :parent_id)
end
end
end
+6 -2
View File
@@ -42,7 +42,7 @@ module Cmtool
# POST /images
# POST /images.xml
def create
@image = Cmtool::Image.new(params[:image])
@image = Cmtool::Image.new(image_params)
respond_to do |format|
if @image.save
@@ -61,7 +61,7 @@ module Cmtool
@image = Cmtool::Image.find(params[:id])
respond_to do |format|
if @image.update_attributes(params[:image])
if @image.update_attributes(image_params)
format.html { redirect_to([cmtool, @image], :notice => I18n.t('cmtool.action.update.successful', :model => Cmtool::Image.model_name.human)) }
format.xml { head :ok }
else
@@ -82,5 +82,9 @@ module Cmtool
format.xml { head :ok }
end
end
def image_params
params.require(:image).permit(:file, :directory_id)
end
end
end
@@ -41,7 +41,7 @@ module Cmtool
# POST /keywords
# POST /keywords.xml
def create
@keyword = Cmtool::Keyword.new(params[:keyword])
@keyword = Cmtool::Keyword.new(keyword_params)
respond_to do |format|
if @keyword.save
@@ -60,7 +60,7 @@ module Cmtool
@keyword = Cmtool::Keyword.find(params[:id])
respond_to do |format|
if @keyword.update_attributes(params[:keyword])
if @keyword.update_attributes(keyword_params)
format.html { redirect_to(cmtool.keywords_path, :notice => I18n.t('cmtool.action.update.successful', :model => Cmtool::Keyword.model_name.human)) }
format.xml { head :ok }
else
@@ -81,5 +81,11 @@ module Cmtool
format.xml { head :ok }
end
end
private
def keyword_params
params.require(:keyword).permit(:name)
end
end
end
+4 -4
View File
@@ -1,13 +1,13 @@
module Cmtool
class Directory
include SimplyStored::Couch
property :name
has_ancestry
view :all_documents, key: :name
has_many :images
end
end
+5 -4
View File
@@ -2,7 +2,7 @@ module Cmtool
class Image
include SimplyStored::Couch
include Paperclip::Glue
property :file_file_name
property :file_content_type
property :file_file_size, type: Fixnum
@@ -10,13 +10,14 @@ module Cmtool
has_attached_file :file, styles: { page: '675x10000>', medium: "354x1000>", thumb: "150x1250>" },
path: ":rails_root/public/system/:attachment/:id/:style.:extension",
url: "/system/:attachment/:id/:style.:extension"
do_not_validate_attachment_file_type :file
belongs_to :directory
def self.active(*args)
all(*args)
end
# Return cleaned name, without extension
def clean_name
return file_file_name
+2 -2
View File
@@ -1,9 +1,9 @@
module Cmtool
class Keyword
include SimplyStored::Couch
property :name
has_and_belongs_to_many :pages, storing_keys: false, class_name: 'Page'
has_and_belongs_to_many :news, :storing_keys => false
end
+8 -3
View File
@@ -1,3 +1,8 @@
var tinyMCEImageList = new Array(
<%=raw Cmtool::Image.active.map{|i| %{['#{i.clean_name} (Origineel)', '#{i.file.url(:original)}'], ['#{i.clean_name} (Pagina)', '#{i.file.url(:page)}'], ['#{i.clean_name} (Medium)', '#{i.file.url(:medium)}'], ['#{i.clean_name} (Thumb)', '#{i.file.url(:thumb)}']}}.join(",\n") %>
);
<%=raw Cmtool::Image.active.map{|i|
[
{title: "#{i.clean_name} (Origineel)", value: i.file.url(:original)},
{title: "#{i.clean_name} (Pagina)", value: i.file.url(:page)},
{title: "#{i.clean_name} (Medium)", value: i.file.url(:medium)},
{title: "#{i.clean_name} (Thumb)", value: i.file.url(:thumb)}
]
}.flatten.to_json %>
+40 -27
View File
File diff suppressed because one or more lines are too long