cmsable 0.0.3 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,10 +11,16 @@ module Cmsable
11
11
  model = get_model name_or_model
12
12
 
13
13
  options = {
14
- authorised:authorised?(model)
14
+ readonly:false
15
15
  }.merge options
16
16
 
17
- content_or_editable_content model, options[:authorised]
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, authorised
32
- control = render :template => 'cmsable/cmsable/control' unless @cmsable_control_rendered
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 authorised
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}",
@@ -1,3 +1,3 @@
1
1
  module Cmsable
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cmsable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: