forked from saurabh/orbit4-5
78 lines
1.6 KiB
Ruby
78 lines
1.6 KiB
Ruby
class Admin::PersonalPluginIntrosController < OrbitMemberController
|
|
def index
|
|
if has_access?
|
|
get_types
|
|
@plugin_intro = @types.where(member_profile_id: params[:member_profile_id]).first rescue nil
|
|
|
|
if @plugin_intro.blank?
|
|
@set_type = @types.new()
|
|
@url = eval("admin_#{@app_type}s_path(member_profile_id: params[:member_profile_id])")
|
|
@verb = :post
|
|
else
|
|
@set_type = @types.find(@plugin_intro.id)
|
|
@url = polymorphic_path(["admin", @plugin_intro])
|
|
@verb = :put
|
|
end
|
|
else
|
|
render_401
|
|
end
|
|
end
|
|
|
|
def new
|
|
if !has_access?
|
|
render_401
|
|
end
|
|
end
|
|
|
|
def show
|
|
end
|
|
|
|
def create
|
|
get_types
|
|
|
|
@plugin_intro = @types.new(personal_plugin_intro_params)
|
|
member = MemberProfile.find(personal_plugin_intro_params[:member_profile_id])
|
|
respond_to do |format|
|
|
if @plugin_intro.save
|
|
format.html { redirect_to(admin_member_url(id: member.to_param, show_plugin_profile: @reback_name)) }
|
|
end
|
|
end
|
|
|
|
end
|
|
|
|
def edit
|
|
if !has_access?
|
|
render_401
|
|
end
|
|
end
|
|
|
|
def update
|
|
get_types
|
|
|
|
@plugin_intro = @types.find(params[:id])
|
|
member = MemberProfile.find(personal_plugin_intro_params[:member_profile_id])
|
|
|
|
respond_to do |format|
|
|
if @plugin_intro.update_attributes(personal_plugin_intro_params)
|
|
format.html { redirect_to(admin_member_url(id: member.to_param,show_plugin_profile: @reback_name)) }
|
|
end
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
end
|
|
|
|
private
|
|
|
|
def personal_plugin_intro_params
|
|
params.require(:plugin_intro).permit!
|
|
end
|
|
|
|
protected
|
|
|
|
def get_types
|
|
@types = @app_type.classify.constantize
|
|
end
|
|
|
|
end
|