cmsable 0.0.3 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/app/helpers/cmsable/cmsable_helper.rb +13 -5
- data/lib/cmsable/version.rb +1 -1
- metadata +1 -1
@@ -11,10 +11,16 @@ module Cmsable
|
|
11
11
|
model = get_model name_or_model
|
12
12
|
|
13
13
|
options = {
|
14
|
-
|
14
|
+
readonly:false
|
15
15
|
}.merge options
|
16
16
|
|
17
|
-
|
17
|
+
# Skip checking permission of set to readonly or
|
18
|
+
# explicit authorisation is passed
|
19
|
+
unless options.include?(:authorised) or options[:readonly]
|
20
|
+
options[:authorised] = authorised?(model)
|
21
|
+
end
|
22
|
+
|
23
|
+
content_or_editable_content model, (options[:authorised] and !options[:readonly])
|
18
24
|
|
19
25
|
end
|
20
26
|
|
@@ -28,11 +34,13 @@ module Cmsable
|
|
28
34
|
end
|
29
35
|
end
|
30
36
|
|
31
|
-
def content_or_editable_content model,
|
32
|
-
control =
|
37
|
+
def content_or_editable_content model, editable
|
38
|
+
control = if(!@cmsable_control_rendered and editable)
|
39
|
+
render :template => 'cmsable/cmsable/control'
|
40
|
+
end
|
33
41
|
@cmsable_control_rendered = true
|
34
42
|
content = model.send(model.cmsable_body).html_safe
|
35
|
-
if
|
43
|
+
if editable
|
36
44
|
content_tag(:div, content, {
|
37
45
|
class: :cmsable_editor,
|
38
46
|
id: "cmsable_edit_#{model.class.to_s.parameterize}_#{model.id}",
|
data/lib/cmsable/version.rb
CHANGED