forked from saurabh/orbit4-5
fixes for import, fixes for deletes
This commit is contained in:
parent
f9dcd32252
commit
cbf1114c4f
|
@ -494,7 +494,7 @@ class Admin::ImportController < OrbitAdminController
|
||||||
fields.each do |f|
|
fields.each do |f|
|
||||||
type = f["type"]
|
type = f["type"]
|
||||||
key = f["name"]["en"].gsub("/"," ").split(' ').join('_').underscore rescue nil
|
key = f["name"]["en"].gsub("/"," ").split(' ').join('_').underscore rescue nil
|
||||||
field = AttributeField.find_by(key: key) rescue nil
|
field = AttributeField.find_by(key: key, role_id: new_role.id) rescue nil
|
||||||
if (field.nil? && key != "category" && key != "academic_status")
|
if (field.nil? && key != "category" && key != "academic_status")
|
||||||
if type == "text"
|
if type == "text"
|
||||||
attribute = new_role.attribute_fields.build(key: key, title_translations: {"en"=>f["name"]["en"],"zh_tw"=>f["name"]["zh-tw"]})
|
attribute = new_role.attribute_fields.build(key: key, title_translations: {"en"=>f["name"]["en"],"zh_tw"=>f["name"]["zh-tw"]})
|
||||||
|
|
|
@ -181,7 +181,9 @@ class Admin::MembersController < OrbitMemberController
|
||||||
else
|
else
|
||||||
@member_profile = MemberProfile.find(params[:id])
|
@member_profile = MemberProfile.find(params[:id])
|
||||||
@member_profile.user.delete if @member_profile.user.present?
|
@member_profile.user.delete if @member_profile.user.present?
|
||||||
@member_profile.delete
|
@member_profile.destroy
|
||||||
|
@member_profile.roles.clear
|
||||||
|
@member_profile.role_statuses.clear
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
|
@ -69,10 +69,6 @@ class AttributeField
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def role
|
|
||||||
self.attribute.role
|
|
||||||
end
|
|
||||||
|
|
||||||
def panel
|
def panel
|
||||||
panel = LIST[:markups][self[:markup]]["panel"]
|
panel = LIST[:markups][self[:markup]]["panel"]
|
||||||
end
|
end
|
||||||
|
|
|
@ -40,6 +40,8 @@ class MemberProfile
|
||||||
scope :can_display, ->{where(is_hidden: false).order_by([:is_top,:desc],[:created_at,:desc])}
|
scope :can_display, ->{where(is_hidden: false).order_by([:is_top,:desc],[:created_at,:desc])}
|
||||||
before_save :assign_default_position, :if => :assign_default_position?
|
before_save :assign_default_position, :if => :assign_default_position?
|
||||||
|
|
||||||
|
before_destroy :delete_personal_plugin_data
|
||||||
|
|
||||||
mount_uploader :avatar, AvatarUploader
|
mount_uploader :avatar, AvatarUploader
|
||||||
paginates_per 10
|
paginates_per 10
|
||||||
|
|
||||||
|
@ -151,6 +153,14 @@ class MemberProfile
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def delete_personal_plugin_data
|
||||||
|
OrbitApp::Plugin::Registration.all.each do |plugin|
|
||||||
|
class_name = plugin.app_name.constantize
|
||||||
|
plugin_data = class_name.where(member_profile_id: self.id)
|
||||||
|
plugin_data.delete
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def assign_default_position?
|
def assign_default_position?
|
||||||
self.position.nil? || self.parent_id_changed?
|
self.position.nil? || self.parent_id_changed?
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Role
|
||||||
has_many :attribute_fields
|
has_many :attribute_fields
|
||||||
accepts_nested_attributes_for :attribute_fields
|
accepts_nested_attributes_for :attribute_fields
|
||||||
|
|
||||||
has_many :role_statuses
|
has_many :role_statuses, dependent: :destroy
|
||||||
|
|
||||||
def is_built_in?
|
def is_built_in?
|
||||||
self.built_in
|
self.built_in
|
||||||
|
|
Loading…
Reference in New Issue