Migrate form old ui to new ui (categories, tags and authorizations)
This commit is contained in:
1 parent
11b880752d
commit
279ac774d4
9 files changed
+196
-131
No files matched your search
@@ -2,8 +2,8 @@ class AdBanner
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include Mongoid::MultiParameterAttributes
|
||||
include OrbitCoreLib::ObjectAuthable
|
||||
include OrbitTag::Taggable
|
||||
include OrbitModel::Authorizable
|
||||
|
||||
field :title
|
||||
field :transition_msec,type: Integer
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
class AuthManager < Authorization
|
||||
# belongs_to :manager_authorizable, polymorphic: true
|
||||
has_and_belongs_to_many :authorized_users, class_name: 'User', inverse_of: 'managing_apps'
|
||||
end
|
||||
@@ -7,6 +7,7 @@ class ModuleApp
|
||||
field :auth_approval_users, type: Array, default: nil
|
||||
field :auth_manager_users, type: Array, default: nil
|
||||
field :auth_sub_manager_users, type: Array, default: nil
|
||||
field :has_category, type: Boolean, default: false
|
||||
field :key
|
||||
field :title
|
||||
field :sidebar_order,type: Integer,default: 0
|
||||
@@ -189,7 +190,8 @@ class ModuleApp
|
||||
end
|
||||
|
||||
def update_auth_manager_users
|
||||
self.update_attribute(:auth_manager_users, self.auth_manager_authorized_users.map{|user| user.id})
|
||||
users = self.auth_manager_authorized_users
|
||||
self.update_attribute(:auth_manager_users, users.map{|user| user.id}) if users
|
||||
end
|
||||
|
||||
def update_auth_sub_manager_users
|
||||
@@ -207,21 +209,6 @@ class ModuleApp
|
||||
managers.include?(user)
|
||||
end
|
||||
|
||||
def add_managers(users)
|
||||
users = Array(users)
|
||||
if auth_manager = self.auth_manager
|
||||
auth_manager.update_attribute(:authorized_users, (auth_manager.authorized_users + users).uniq)
|
||||
else
|
||||
self.create_auth_manager(authorized_users: users)
|
||||
end
|
||||
end
|
||||
|
||||
def remove_managers(users)
|
||||
users = Array(users)
|
||||
users = users.delete_if{|user| user == current_user || is_admin?}
|
||||
self.auth_manager.update_attribute(:authorized_users, auth_manager.authorized_users - users)
|
||||
end
|
||||
|
||||
def is_manager?(user)
|
||||
if user && !auth_manager_users.blank?
|
||||
auth_manager_users.include?(user.id)
|
||||
|
||||
@@ -1,8 +1,3 @@
|
||||
# class Tag < ProtoTag
|
||||
# belongs_to :module_app
|
||||
|
||||
# end
|
||||
|
||||
class Tag
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
Reference in new issue
Block a user