2021-02-27 04:19:24 +00:00
|
|
|
class PersonalPluginField
|
|
|
|
include Mongoid::Document
|
|
|
|
include Mongoid::Timestamps
|
|
|
|
include OrbitModel::Status
|
|
|
|
include MemberHelper
|
2021-03-01 15:44:52 +00:00
|
|
|
field :author_name, :type => String, :default => "",:localize => true
|
2021-02-27 04:19:24 +00:00
|
|
|
field :title, :type => String, :default => "",:localize => true
|
|
|
|
field :module_name, :type => String, :default => ""
|
|
|
|
field :primary_modal_name, :type => String, :default => ""
|
|
|
|
field :related_modal_name, :type => Array, :default => []
|
|
|
|
field :primary_modal_fields, :type => Array, :default => []
|
|
|
|
field :related_modal_fields, :type => Array, :default => [] #ex: [[],[]]
|
|
|
|
field :backend_fields, :type => Hash, :default => {}
|
|
|
|
field :frontend_fields, :type => Hash, :default => {}
|
2021-03-03 12:24:10 +00:00
|
|
|
field :log_text, :type => String, :default => ""
|
2021-03-04 02:21:22 +00:00
|
|
|
field :fields_order, :type => Hash, :default => {}
|
2021-03-03 12:24:10 +00:00
|
|
|
before_save :check_plugin_exist
|
|
|
|
def get_all_gem_plugins
|
|
|
|
extention_files = ["downloaded_extensions.rb","built_in_extensions.rb"]
|
|
|
|
gem_plugins = extention_files.map{|f| (File.read(f).scan(/\n\s*gem\s*["'](.*)["']\s*,/).flatten rescue [])}.flatten
|
|
|
|
end
|
|
|
|
def check_plugin_exist
|
|
|
|
gem_plugins = get_all_gem_plugins
|
|
|
|
can_install = !gem_plugins.include?(self.module_name)
|
|
|
|
can_install = (self.class.where(:module_name=>self.module_name,:id.ne=>self.id).count == 0 rescue false) if !can_install
|
|
|
|
return can_install
|
|
|
|
end
|
2021-02-27 04:19:24 +00:00
|
|
|
end
|