app/models/camaleon_cms/plugin.rb in camaleon_cms-2.6.4 vs app/models/camaleon_cms/plugin.rb in camaleon_cms-2.7.0

- old
+ new

@@ -4,11 +4,11 @@ # term_group => status active (1, nil) # slug => plugin key # name => plugin name attr_accessor :error - cama_define_common_relationships('Plugin') + belongs_to :site, foreign_key: :parent_id, required: false default_scope { where(taxonomy: :plugin) } scope :active, -> { where(term_group: 1) } @@ -16,22 +16,22 @@ before_destroy :destroy_custom_fields # active the plugin def active self.term_group = 1 - self.save + save end # inactive the plugin def inactive self.term_group = nil - self.save + save end # check if plugin is active def active? - self.term_group.to_s == "1" + term_group.to_s == '1' end # return theme settings configured in config.json def settings PluginRoutes.plugin_info(slug) @@ -44,35 +44,36 @@ false end # set a new installation version for this plugin def installed_version=(version) - self.set_option("version_installed", version) + set_option('version_installed', version) end # return gem installed version def installed_version - return "" + '' - res = get_option("version_installed") - unless res.present? # fix for old installations - res = self.settings["version"] - self.installed_version = res - end - res + # res = get_option('version_installed') + # unless res.present? # fix for old installations + # res = settings['version'] + # self.installed_version = res + # end + # res end # return the title of this plugin def title - PluginRoutes.plugin_info(slug)["title"] + PluginRoutes.plugin_info(slug)['title'] end private + def set_default self.name = slug unless name.present? end def destroy_custom_fields - self.get_field_groups.destroy_all + get_field_groups.destroy_all end end end