camaleon_cms 2.5.3.1 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of camaleon_cms might be problematic. Click here for more details.

Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/app/apps/plugins/front_cache/front_cache_helper.rb +1 -1
  3. data/app/assets/images/camaleon_cms/language/md.png +0 -0
  4. data/app/models/camaleon_cms/ability.rb +94 -92
  5. data/app/models/camaleon_cms/category.rb +45 -44
  6. data/app/models/camaleon_cms/custom_field.rb +26 -25
  7. data/app/models/camaleon_cms/custom_field_group.rb +115 -114
  8. data/app/models/camaleon_cms/custom_fields_relationship.rb +21 -19
  9. data/app/models/camaleon_cms/media.rb +48 -44
  10. data/app/models/camaleon_cms/meta.rb +5 -3
  11. data/app/models/camaleon_cms/nav_menu.rb +27 -24
  12. data/app/models/camaleon_cms/nav_menu_item.rb +58 -54
  13. data/app/models/camaleon_cms/plugin.rb +62 -60
  14. data/app/models/camaleon_cms/post.rb +205 -227
  15. data/app/models/camaleon_cms/post_comment.rb +44 -42
  16. data/app/models/camaleon_cms/post_default.rb +65 -62
  17. data/app/models/camaleon_cms/post_relationship.rb +1 -2
  18. data/app/models/camaleon_cms/post_tag.rb +9 -6
  19. data/app/models/camaleon_cms/post_type.rb +170 -163
  20. data/app/models/camaleon_cms/site.rb +211 -203
  21. data/app/models/camaleon_cms/term_relationship.rb +16 -14
  22. data/app/models/camaleon_cms/term_taxonomy.rb +49 -54
  23. data/app/models/camaleon_cms/theme.rb +24 -23
  24. data/app/models/camaleon_cms/user.rb +18 -13
  25. data/app/models/camaleon_cms/user_role.rb +130 -128
  26. data/app/models/camaleon_cms/widget/assigned.rb +25 -21
  27. data/app/models/camaleon_cms/widget/main.rb +40 -36
  28. data/app/models/camaleon_cms/widget/sidebar.rb +20 -16
  29. data/app/validators/camaleon_cms/post_uniq_validator.rb +28 -0
  30. data/app/validators/camaleon_cms/uniq_validator.rb +9 -0
  31. data/config/locales/camaleon_cms/admin/ar.yml +1 -0
  32. data/config/locales/camaleon_cms/admin/de.yml +1 -0
  33. data/config/locales/camaleon_cms/admin/en.yml +82 -21
  34. data/config/locales/camaleon_cms/admin/fr.yml +1 -0
  35. data/config/locales/camaleon_cms/admin/it.yml +1 -0
  36. data/config/locales/camaleon_cms/admin/js/de.yml +51 -0
  37. data/config/locales/camaleon_cms/admin/js/en.yml +51 -0
  38. data/config/locales/camaleon_cms/admin/js/es.yml +53 -0
  39. data/config/locales/camaleon_cms/admin/js/it.yml +44 -0
  40. data/config/locales/camaleon_cms/admin/js/nl.yml +42 -0
  41. data/config/locales/camaleon_cms/admin/js/pt-BR.yml +44 -0
  42. data/config/locales/camaleon_cms/admin/js/ru.yml +51 -0
  43. data/config/locales/camaleon_cms/admin/js/uk.yml +51 -0
  44. data/config/locales/camaleon_cms/admin/js/zh-CN.yml +51 -0
  45. data/config/locales/camaleon_cms/admin/nl.yml +1 -0
  46. data/config/locales/camaleon_cms/admin/ru.yml +1 -0
  47. data/config/locales/camaleon_cms/admin/uk.yml +2 -1
  48. data/config/locales/camaleon_cms/admin/zh-CH.yml +1 -0
  49. data/config/locales/camaleon_cms/common.md +3 -0
  50. data/config/locales/camaleon_cms/common/ar.yml +66 -0
  51. data/config/locales/camaleon_cms/common/de.yml +66 -0
  52. data/config/locales/camaleon_cms/common/en.yml +63 -0
  53. data/config/locales/camaleon_cms/common/es.yml +66 -0
  54. data/config/locales/camaleon_cms/common/fr.yml +66 -0
  55. data/config/locales/camaleon_cms/common/it.yml +63 -0
  56. data/config/locales/camaleon_cms/common/md.yml +60 -0
  57. data/config/locales/camaleon_cms/common/nl.yml +64 -0
  58. data/config/locales/camaleon_cms/common/pt-BR.yml +65 -0
  59. data/config/locales/camaleon_cms/common/pt.yml +65 -0
  60. data/config/locales/camaleon_cms/common/ru.yml +66 -0
  61. data/config/locales/camaleon_cms/common/uk.yml +64 -0
  62. data/config/locales/camaleon_cms/common/zh-CN.yml +66 -0
  63. data/config/locales/camaleon_cms/languages/ar.yml +16 -0
  64. data/config/locales/camaleon_cms/languages/de.yml +16 -0
  65. data/config/locales/camaleon_cms/languages/en.yml +16 -0
  66. data/config/locales/camaleon_cms/languages/es.yml +16 -0
  67. data/config/locales/camaleon_cms/languages/it.yml +16 -0
  68. data/config/locales/camaleon_cms/languages/md.yml +15 -0
  69. data/config/locales/camaleon_cms/languages/nl.yml +16 -0
  70. data/config/locales/camaleon_cms/languages/pt-BR.yml +16 -0
  71. data/config/locales/camaleon_cms/languages/pt.yml +16 -0
  72. data/config/locales/camaleon_cms/languages/ru.yml +16 -0
  73. data/config/locales/camaleon_cms/languages/uk.yml +16 -0
  74. data/config/locales/camaleon_cms/languages/zh-CN.yml +16 -0
  75. data/config/locales/camaleon_cms/routes/de.yml +8 -0
  76. data/config/locales/camaleon_cms/routes/es.yml +8 -0
  77. data/config/locales/camaleon_cms/routes/fr.yml +8 -0
  78. data/config/locales/camaleon_cms/routes/it.yml +8 -0
  79. data/config/locales/camaleon_cms/routes/md.yml +8 -0
  80. data/config/locales/camaleon_cms/routes/pt-BR.yml +8 -0
  81. data/config/locales/camaleon_cms/routes/pt.yml +8 -0
  82. data/config/locales/camaleon_cms/routes/ru.yml +8 -0
  83. data/config/locales/camaleon_cms/routes/uk.yml +8 -0
  84. data/config/locales/camaleon_cms/routes/zh-CN.yml +8 -0
  85. data/config/locales/md.yml +207 -0
  86. data/lib/camaleon_cms/version.rb +1 -1
  87. data/spec/dummy/config/application.rb +14 -2
  88. metadata +102 -109
  89. data/config/locales/camaleon_cms/admin/js.yml +0 -435
  90. data/config/locales/camaleon_cms/common.yml +0 -786
  91. data/config/locales/camaleon_cms/languages.yml +0 -167
  92. data/config/locales/camaleon_cms/routes.yml +0 -71
  93. data/spec/dummy/db/development.sqlite3 +0 -0
  94. data/spec/dummy/db/test.sqlite3 +0 -0
  95. data/spec/dummy/log/development.log +0 -254
  96. data/spec/dummy/log/test.log +0 -46384
  97. data/spec/dummy/public/media/1/rails_tmp.png +0 -0
  98. data/spec/dummy/public/media/1/rails_tmp_1.png +0 -0
  99. data/spec/dummy/public/media/1/rails_tmp_2.png +0 -0
  100. data/spec/dummy/public/media/1/rails_tmp_3.png +0 -0
  101. data/spec/dummy/public/media/1/sample/rails_tmp.png +0 -0
  102. data/spec/dummy/public/media/1/sample/thumb/rails_tmp-png.png +0 -0
  103. data/spec/dummy/public/media/1/slide33.jpg +0 -0
  104. data/spec/dummy/public/media/1/thumb/rails_tmp-png.png +0 -0
  105. data/spec/dummy/public/media/1/thumb/rails_tmp-png_20x.png +0 -0
  106. data/spec/dummy/public/media/1/thumb/rails_tmp-png_300x300.png +0 -0
  107. data/spec/dummy/public/media/1/thumb/rails_tmp-png_505x350.png +0 -0
  108. data/spec/dummy/public/media/1/thumb/rails_tmp_1-png.png +0 -0
  109. data/spec/dummy/public/media/1/thumb/rails_tmp_2-png.png +0 -0
  110. data/spec/dummy/public/media/1/thumb/rails_tmp_3-png.png +0 -0
  111. data/spec/dummy/public/media/1/thumb/slide33-jpg.jpg +0 -0
  112. data/spec/dummy/tmp/capybara/screenshot_2019-09-04-09-19-13.472.html +0 -457
  113. data/spec/dummy/tmp/capybara/screenshot_2019-09-04-09-19-13.472.png +0 -0
  114. data/spec/dummy/tmp/capybara/screenshot_2019-09-04-09-19-28.693.html +0 -428
  115. data/spec/dummy/tmp/capybara/screenshot_2019-09-04-09-19-28.693.png +0 -0
  116. data/spec/dummy/tmp/capybara/screenshot_2019-09-04-09-22-45.502.html +0 -337
  117. data/spec/dummy/tmp/capybara/screenshot_2019-09-04-09-22-45.502.png +0 -0
  118. data/spec/support/fixtures/rails_tmp.png +0 -0
@@ -1,27 +1,29 @@
1
- class CamaleonCms::CustomFieldsRelationship < ActiveRecord::Base
2
- self.table_name = "#{PluginRoutes.static_system_info['db_prefix']}custom_fields_relationships"
1
+ module CamaleonCms
2
+ class CustomFieldsRelationship < ActiveRecord::Base
3
+ self.table_name = "#{PluginRoutes.static_system_info['db_prefix']}custom_fields_relationships"
3
4
 
4
- # attr_accessible :objectid, :custom_field_id, :term_order, :value, :object_class,
5
- # :custom_field_slug, :group_number
6
- default_scope { order("#{CamaleonCms::CustomFieldsRelationship.table_name}.term_order ASC") }
5
+ # attr_accessible :objectid, :custom_field_id, :term_order, :value, :object_class,
6
+ # :custom_field_slug, :group_number
7
+ default_scope { order("#{CamaleonCms::CustomFieldsRelationship.table_name}.term_order ASC") }
7
8
 
8
- # relations
9
- belongs_to :custom_fields, class_name: 'CamaleonCms::CustomField', foreign_key: :custom_field_id
9
+ # relations
10
+ belongs_to :custom_field
10
11
 
11
- # validates :objectid, :custom_field_id, presence: true
12
- validates :custom_field_id, presence: true # error on clone model
12
+ # validates :objectid, :custom_field_id, presence: true
13
+ validates :custom_field_id, presence: true # error on clone model
13
14
 
14
- after_save :set_parent_slug
15
- after_save :update_model_owner # TODO: convert this model into polymorphic
15
+ after_save :set_parent_slug
16
+ after_save :update_model_owner # TODO: convert this model into polymorphic
16
17
 
17
- private
18
+ private
18
19
 
19
- def set_parent_slug
20
- # self.update_column('custom_field_slug', self.custom_fields.slug)
21
- end
22
-
23
- # touch owner model
24
- def update_model_owner
25
- "CamaleonCms::#{object_class}".constantize.find(objectid).touch rescue nil # owner model
20
+ def set_parent_slug
21
+ # self.update_column('custom_field_slug', self.custom_fields.slug)
22
+ end
23
+
24
+ # touch owner model
25
+ def update_model_owner
26
+ "CamaleonCms::#{object_class}".constantize.find(objectid).touch rescue nil # owner model
27
+ end
26
28
  end
27
29
  end
@@ -1,54 +1,58 @@
1
- class CamaleonCms::Media < ActiveRecord::Base
2
- self.table_name = "#{PluginRoutes.static_system_info['db_prefix']}media"
3
- belongs_to :site, class_name: 'CamaleonCms::Site'
4
- validates :name, uniqueness: {
5
- scope: [:site_id, :is_folder, :folder_path, :is_public],
6
- message: 'Duplicates not allowed'
7
- }
8
- scope :only_folder, ->{ where(is_folder: true) }
9
- scope :only_file, ->{ where(is_folder: false) }
10
- default_scope { order(is_folder: :asc, name: :asc) }
11
- before_save :create_parent_folders
12
- before_destroy :delete_folder_items
1
+ module CamaleonCms
2
+ class Media < ActiveRecord::Base
3
+ self.table_name = "#{PluginRoutes.static_system_info['db_prefix']}media"
13
4
 
14
- def self.search(search_expression = '', folder = nil)
15
- if search_expression.blank?
16
- where(folder_path: folder)
17
- else
18
- where('name like ?', "%#{search_expression}%")
5
+ belongs_to :site
6
+ validates :name, uniqueness: {
7
+ scope: [:site_id, :is_folder, :folder_path, :is_public],
8
+ message: 'Duplicates not allowed'
9
+ }
10
+ scope :only_folder, ->{ where(is_folder: true) }
11
+ scope :only_file, ->{ where(is_folder: false) }
12
+ default_scope { order(is_folder: :asc, name: :asc) }
13
+
14
+ before_save :create_parent_folders
15
+ before_destroy :delete_folder_items
16
+
17
+ def self.search(search_expression = '', folder = nil)
18
+ if search_expression.blank?
19
+ where(folder_path: folder)
20
+ else
21
+ where('name like ?', "%#{search_expression}%")
22
+ end
19
23
  end
20
- end
21
24
 
22
- # search file or folder by key
23
- def self.find_by_key(key)
24
- key = key.cama_fix_media_key
25
- if key == '/'
26
- where(folder_path: File.dirname(key))
27
- else
28
- where(folder_path: File.dirname(key), name: File.basename(key))
25
+ # search file or folder by key
26
+ def self.find_by_key(key)
27
+ key = key.cama_fix_media_key
28
+ if key == '/'
29
+ where(folder_path: File.dirname(key))
30
+ else
31
+ where(folder_path: File.dirname(key), name: File.basename(key))
32
+ end
29
33
  end
30
- end
31
34
 
32
- # return all items of current folder
33
- def items
34
- coll = is_public ? site.public_media : site.private_media
35
- coll.where(folder_path: "#{folder_path}/#{name}".cama_fix_media_key)
36
- end
35
+ # return all items of current folder
36
+ def items
37
+ coll = is_public ? site.public_media : site.private_media
38
+ coll.where(folder_path: "#{folder_path}/#{name}".cama_fix_media_key)
39
+ end
37
40
 
38
- private
39
- # recover folder or file format
40
- def create_parent_folders
41
- coll = is_public ? site.public_media : site.private_media
42
- _p = []
43
- folder_path.split('/').each do |f_name|
44
- _path = ('/'+_p.join('/')).cama_fix_media_key
45
- coll.only_folder.where(name: f_name, folder_path: _path).first_or_create() if "#{_path}/#{f_name}".cama_fix_media_key != '/'
46
- _p.push(f_name)
41
+ private
42
+ # recover folder or file format
43
+ def create_parent_folders
44
+ coll = is_public ? site.public_media : site.private_media
45
+ _p = []
46
+ folder_path.split('/').each do |f_name|
47
+ _path = ('/'+_p.join('/')).cama_fix_media_key
48
+ coll.only_folder.where(name: f_name, folder_path: _path).first_or_create if "#{_path}/#{f_name}".cama_fix_media_key != '/'
49
+ _p.push(f_name)
50
+ end
47
51
  end
48
- end
49
52
 
50
- # return all children items
51
- def delete_folder_items
52
- items.destroy_all if is_folder
53
+ # return all children items
54
+ def delete_folder_items
55
+ items.destroy_all if is_folder
56
+ end
53
57
  end
54
58
  end
@@ -1,4 +1,6 @@
1
- class CamaleonCms::Meta < ActiveRecord::Base
2
- self.table_name = "#{PluginRoutes.static_system_info["db_prefix"]}metas"
3
- # attr_accessible :objectid, :key, :value, :object_class
1
+ module CamaleonCms
2
+ class Meta < ActiveRecord::Base
3
+ self.table_name = "#{PluginRoutes.static_system_info["db_prefix"]}metas"
4
+ # attr_accessible :objectid, :key, :value, :object_class
5
+ end
4
6
  end
@@ -1,29 +1,32 @@
1
- class CamaleonCms::NavMenu < CamaleonCms::TermTaxonomy
2
- default_scope { where(taxonomy: :nav_menu).order(id: :asc) }
3
- alias_attribute :site_id, :parent_id
4
- cama_define_common_relationships('NavMenu')
5
- has_many :children, class_name: "CamaleonCms::NavMenuItem", foreign_key: :parent_id, dependent: :destroy, inverse_of: :parent
6
- belongs_to :site, :class_name => "CamaleonCms::Site", foreign_key: :parent_id, inverse_of: :nav_menus
1
+ module CamaleonCms
2
+ class NavMenu < CamaleonCms::TermTaxonomy
3
+ default_scope { where(taxonomy: :nav_menu).order(id: :asc) }
4
+ alias_attribute :site_id, :parent_id
7
5
 
8
- # add menu item for current menu
9
- # value: (Hash) is a hash object that contains label, type, link
10
- # options for type: post | category | post_type | post_tag | external
11
- # sample: {label: "my label", type: "external", link: "http://camaleon.tuzitio.com", target: '_blank'}
12
- # sample: {label: "my label", type: "post", link: 10}
13
- # sample: {label: "my label", type: "category", link: 12}
14
- # return item created
15
- def append_menu_item (value)
16
- item = children.create!({name: value[:label], url: value[:link], kind: value[:type], target: value[:target]})
17
- item
18
- end
6
+ cama_define_common_relationships('NavMenu')
7
+ has_many :children, class_name: "CamaleonCms::NavMenuItem", foreign_key: :parent_id, dependent: :destroy, inverse_of: :parent
8
+ belongs_to :site, foreign_key: :parent_id, inverse_of: :nav_menus
19
9
 
20
- # skip uniq slug validation
21
- def skip_slug_validation?
22
- true
23
- end
10
+ # add menu item for current menu
11
+ # value: (Hash) is a hash object that contains label, type, link
12
+ # options for type: post | category | post_type | post_tag | external
13
+ # sample: {label: "my label", type: "external", link: "http://camaleon.tuzitio.com", target: '_blank'}
14
+ # sample: {label: "my label", type: "post", link: 10}
15
+ # sample: {label: "my label", type: "category", link: 12}
16
+ # return item created
17
+ def append_menu_item (value)
18
+ item = children.create!({name: value[:label], url: value[:link], kind: value[:type], target: value[:target]})
19
+ item
20
+ end
21
+
22
+ # skip uniq slug validation
23
+ def skip_slug_validation?
24
+ true
25
+ end
24
26
 
25
- private
26
- # overwrite termtaxonomy method
27
- def destroy_dependencies
27
+ private
28
+ # overwrite termtaxonomy method
29
+ def destroy_dependencies
30
+ end
28
31
  end
29
32
  end
@@ -1,64 +1,68 @@
1
- class CamaleonCms::NavMenuItem < CamaleonCms::TermTaxonomy
2
- alias_attribute :site_id, :term_group
3
- alias_attribute :label, :name
4
- alias_attribute :url, :description
5
- alias_attribute :kind, :slug
6
- alias_attribute :target, :status
7
- # attr_accessible :label, :url, :kind
8
- default_scope { where(taxonomy: :nav_menu_item).order(id: :asc) }
9
- cama_define_common_relationships('NavMenuItem')
10
- belongs_to :parent, class_name: "CamaleonCms::NavMenu", inverse_of: :children
11
- belongs_to :parent_item, class_name: "CamaleonCms::NavMenuItem", foreign_key: :parent_id, inverse_of: :children
12
- has_many :children, class_name: "CamaleonCms::NavMenuItem", foreign_key: :parent_id, dependent: :destroy, inverse_of: :parent_item
1
+ module CamaleonCms
2
+ class NavMenuItem < CamaleonCms::TermTaxonomy
3
+ alias_attribute :site_id, :term_group
4
+ alias_attribute :label, :name
5
+ alias_attribute :url, :description
6
+ alias_attribute :kind, :slug
7
+ alias_attribute :target, :status
8
+ # attr_accessible :label, :url, :kind
9
+ #
10
+ default_scope { where(taxonomy: :nav_menu_item).order(id: :asc) }
13
11
 
14
- before_create :set_parent_site
15
- after_create :update_count
16
- #before_destroy :update_count
12
+ cama_define_common_relationships('NavMenuItem')
13
+ belongs_to :parent, class_name: "CamaleonCms::NavMenu", inverse_of: :children
14
+ belongs_to :parent_item, class_name: "CamaleonCms::NavMenuItem", foreign_key: :parent_id, inverse_of: :children
15
+ has_many :children, class_name: "CamaleonCms::NavMenuItem", foreign_key: :parent_id, dependent: :destroy, inverse_of: :parent_item
17
16
 
18
- # return the main menu
19
- def main_menu
20
- main_menu = self.parent
21
- return main_menu if main_menu.present?
22
- parent_menu = self.parent_item
23
- parent_menu.main_menu if parent_menu.present?
24
- end
17
+ before_create :set_parent_site
18
+ after_create :update_count
19
+ #before_destroy :update_count
25
20
 
26
- # check if this menu have children
27
- def have_children?
28
- self.children.count != 0
29
- end
21
+ # return the main menu
22
+ def main_menu
23
+ return parent if parent
30
24
 
31
- # add sub menu for a menu item
32
- # same values of NavMenu#append_menu_item
33
- # return item created
34
- def append_menu_item(value)
35
- children.create({name: value[:label], url: value[:link], kind: value[:type], target: value[:target]})
36
- end
25
+ parent_item.main_menu if parent_item
26
+ end
37
27
 
38
- # update current menu
39
- # value: same as append_menu_item (label, link, target)
40
- def update_menu_item(value)
41
- self.update({name: value[:label], url: value[:link], target: value[:target]})
42
- end
28
+ # check if this menu have children
29
+ def have_children?
30
+ self.children.count != 0
31
+ end
43
32
 
44
- # overwrite skip uniq slug validation
45
- def skip_slug_validation?; true end
46
- def before_validating; end
33
+ # add sub menu for a menu item
34
+ # same values of NavMenu#append_menu_item
35
+ # return item created
36
+ def append_menu_item(value)
37
+ children.create({name: value[:label], url: value[:link], kind: value[:type], target: value[:target]})
38
+ end
47
39
 
48
- private
49
- def update_count
50
- self.parent.update_column('count', self.parent.children.size) if self.parent.present?
51
- self.parent_item.update_column('count', self.parent_item.children.size) if self.parent_item.present?
52
- self.update_column(:term_group, main_menu.parent_id)
53
- self.update_column(:term_order, CamaleonCms::NavMenuItem.where(parent_id: self.parent_id).count) # update position
54
- end
40
+ # update current menu
41
+ # value: same as append_menu_item (label, link, target)
42
+ def update_menu_item(value)
43
+ self.update({name: value[:label], url: value[:link], target: value[:target]})
44
+ end
55
45
 
56
- # fast access from site to menu items
57
- def set_parent_site
58
- self.site_id = self.parent_item.site_id if self.parent_item.present?
59
- self.site_id = self.parent.site_id if self.parent.present?
60
- end
46
+ # overwrite skip uniq slug validation
47
+ def skip_slug_validation?; true end
48
+ def before_validating; end
49
+
50
+ private
51
+
52
+ def update_count
53
+ self.parent.update_column('count', parent.children.size) if parent
54
+ self.parent_item.update_column('count', parent_item.children.size) if parent_item
55
+ self.update_column(:term_group, main_menu.parent_id)
56
+ self.update_column(:term_order, CamaleonCms::NavMenuItem.where(parent_id: parent_id).count) # update position
57
+ end
61
58
 
62
- # overwrite inherit method
63
- def destroy_dependencies; end
59
+ # fast access from site to menu items
60
+ def set_parent_site
61
+ self.site_id = parent_item.site_id if parent_item
62
+ self.site_id = parent.site_id if parent
63
+ end
64
+
65
+ # overwrite inherit method
66
+ def destroy_dependencies; end
67
+ end
64
68
  end
@@ -1,76 +1,78 @@
1
- class CamaleonCms::Plugin < CamaleonCms::TermTaxonomy
2
- # attrs:
3
- # term_group => status active (1, nil)
4
- # slug => plugin key
5
- # name => plugin name
1
+ module CamaleonCms
2
+ class Plugin < CamaleonCms::TermTaxonomy
3
+ # attrs:
4
+ # term_group => status active (1, nil)
5
+ # slug => plugin key
6
+ # name => plugin name
6
7
 
7
- attr_accessor :error
8
- cama_define_common_relationships('Plugin')
9
- belongs_to :site, class_name: "CamaleonCms::Site", foreign_key: :parent_id
8
+ attr_accessor :error
9
+ cama_define_common_relationships('Plugin')
10
+ belongs_to :site, foreign_key: :parent_id
10
11
 
11
- default_scope { where(taxonomy: :plugin) }
12
- scope :active, -> { where(term_group: 1) }
12
+ default_scope { where(taxonomy: :plugin) }
13
+ scope :active, -> { where(term_group: 1) }
13
14
 
14
- before_validation :set_default
15
- before_destroy :destroy_custom_fields
15
+ before_validation :set_default
16
+ before_destroy :destroy_custom_fields
16
17
 
17
- # active the plugin
18
- def active
19
- self.term_group = 1
20
- self.save
21
- end
18
+ # active the plugin
19
+ def active
20
+ self.term_group = 1
21
+ self.save
22
+ end
22
23
 
23
- # inactive the plugin
24
- def inactive
25
- self.term_group = nil
26
- self.save
27
- end
24
+ # inactive the plugin
25
+ def inactive
26
+ self.term_group = nil
27
+ self.save
28
+ end
28
29
 
29
- # check if plugin is active
30
- def active?
31
- self.term_group.to_s == "1"
32
- end
30
+ # check if plugin is active
31
+ def active?
32
+ self.term_group.to_s == "1"
33
+ end
33
34
 
34
- # return theme settings configured in config.json
35
- def settings
36
- PluginRoutes.plugin_info(self.slug)
37
- end
35
+ # return theme settings configured in config.json
36
+ def settings
37
+ PluginRoutes.plugin_info(slug)
38
+ end
38
39
 
39
- # check if current installation version is older
40
- # return boolean
41
- def old_version?
42
- # self.installed_version.to_s != self.settings["version"].to_s
43
- false
44
- end
40
+ # check if current installation version is older
41
+ # return boolean
42
+ def old_version?
43
+ # self.installed_version.to_s != self.settings["version"].to_s
44
+ false
45
+ end
45
46
 
46
- # set a new installation version for this plugin
47
- def installed_version=(version)
48
- self.set_option("version_installed", version)
49
- end
47
+ # set a new installation version for this plugin
48
+ def installed_version=(version)
49
+ self.set_option("version_installed", version)
50
+ end
51
+
52
+ # return gem installed version
53
+ def installed_version
54
+ return ""
50
55
 
51
- # return gem installed version
52
- def installed_version
53
- return ""
54
- res = self.get_option("version_installed")
55
- unless res.present? # fix for old installations
56
- res = self.settings["version"]
57
- self.installed_version= res
56
+ res = get_option("version_installed")
57
+ unless res.present? # fix for old installations
58
+ res = self.settings["version"]
59
+ self.installed_version = res
60
+ end
61
+ res
58
62
  end
59
- res
60
- end
61
63
 
62
- # return the title of this plugin
63
- def title
64
- PluginRoutes.plugin_info(self.slug)["title"]
65
- end
64
+ # return the title of this plugin
65
+ def title
66
+ PluginRoutes.plugin_info(slug)["title"]
67
+ end
66
68
 
67
- private
68
- def set_default
69
- self.name = self.slug unless self.name.present?
70
- end
69
+ private
70
+ def set_default
71
+ self.name = slug unless name.present?
72
+ end
71
73
 
72
- def destroy_custom_fields
73
- self.get_field_groups.destroy_all
74
+ def destroy_custom_fields
75
+ self.get_field_groups.destroy_all
76
+ end
74
77
  end
75
-
76
78
  end