put module app json into init,making orbit app work with module app.
This commit is contained in:
1 parent
36f6a6fdd6
commit
6995bb1622
15 files changed
+1317
-467
No files matched your search
+3
-2
@@ -4,7 +4,8 @@ class Item
|
||||
include Mongoid::Timestamps
|
||||
include Mongoid::Tree
|
||||
include Mongoid::Tree::Ordering
|
||||
|
||||
LIST = YAML.load(File.read('config/list.yml'))
|
||||
|
||||
field :name
|
||||
field :path
|
||||
field :is_published, :type => Boolean, :default => false
|
||||
@@ -15,7 +16,7 @@ class Item
|
||||
|
||||
|
||||
validates_format_of :name, :with => /^[0-9a-zA-Z\-_]+$/
|
||||
validates :name, :exclusion => { :in => LIST[:forbidden_item_names] }
|
||||
# validates :name, :exclusion => { :in => LIST[:forbidden_item_names] }
|
||||
validates_uniqueness_of :name, :scope => :parent_id
|
||||
validates_presence_of :name
|
||||
validates_associated :parent, :children
|
||||
|
||||
+35
-16
@@ -5,30 +5,45 @@ class ModuleApp
|
||||
|
||||
field :key
|
||||
field :title
|
||||
field :version
|
||||
field :organization
|
||||
field :author
|
||||
field :intro
|
||||
field :update_info
|
||||
field :create_date
|
||||
field :enable_frontend, type: Boolean, :default => true
|
||||
|
||||
field :app_pages ,type: Array
|
||||
# field :widgets ,type: Array
|
||||
field :widgets ,type: Hash
|
||||
field :widget_fields ,type: Array
|
||||
|
||||
|
||||
has_many :managers,as: :managing_app ,:class_name => "AppManager" ,:dependent => :destroy#,:foreign_key => "managing_app_id",:inverse_of => :managing_app
|
||||
has_many :sub_managers,as: :sub_managing_app ,:class_name => "AppManager", :dependent => :destroy#,:foreign_key => "sub_managing_app_id",:inverse_of => :sub_managing_app
|
||||
|
||||
has_many :tags
|
||||
# has_many :tags
|
||||
has_many :page_parts
|
||||
has_many :pages
|
||||
|
||||
has_one :app_auth,dependent: :delete
|
||||
|
||||
|
||||
before_save :set_key
|
||||
|
||||
|
||||
def get_registration
|
||||
OrbitApp::Module::Registration.find_by_key(key)
|
||||
end
|
||||
|
||||
# %w{label_i18n }.each do |field|
|
||||
# define_method(field){|var| get_registration.send("get_#{m}") }
|
||||
# end
|
||||
|
||||
def label_i18n
|
||||
reg = get_registration
|
||||
reg.nil? ? 'Init is not defined completely' : get_registration.get_label_i18n
|
||||
end
|
||||
|
||||
# def method_missing(m, *args, &block)
|
||||
# # get_registration.send("get_#{m}")
|
||||
# end
|
||||
|
||||
def using_default_widget?
|
||||
!get_registration.get_default_widget.blank?
|
||||
end
|
||||
|
||||
def get_widget_for_select
|
||||
widgets = get_registration.get_widgets
|
||||
ary = widgets.collect{|k,v| [I18n.t(v["label"]),k]}
|
||||
ary << [I18n.t('widget.default_widget'),'default_widget']if using_default_widget?
|
||||
end
|
||||
|
||||
def is_manager?(user)
|
||||
managing_users.include?(user)
|
||||
end
|
||||
@@ -79,6 +94,10 @@ class ModuleApp
|
||||
end
|
||||
end
|
||||
|
||||
def label
|
||||
I18n.t(label_i18n)
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def set_key
|
||||
|
||||
Reference in new issue
Block a user