forked from saurabh/personal-diploma
fixed bug for diplomas without member_profile
This commit is contained in:
parent
774df67db0
commit
75e75ec5c7
|
@ -1,6 +1,7 @@
|
||||||
class Admin::DiplomasController < OrbitMemberController
|
class Admin::DiplomasController < OrbitMemberController
|
||||||
layout "member_plugin"
|
layout "member_plugin"
|
||||||
|
|
||||||
|
before_action :set_diploma, only: [:show, :edit , :update, :destroy]
|
||||||
before_action :set_plugin
|
before_action :set_plugin
|
||||||
before_action :get_settings,:only => [:new, :edit, :setting]
|
before_action :get_settings,:only => [:new, :edit, :setting]
|
||||||
|
|
||||||
|
@ -24,20 +25,17 @@ class Admin::DiplomasController < OrbitMemberController
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
@member = @diploma.member_profile rescue nil
|
||||||
@diploma = Diploma.find(params[:id])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@member = MemberProfile.find(diploma_params['member_profile_id']) rescue nil
|
@member = @diploma.member_profile rescue nil
|
||||||
@diploma = Diploma.find(params[:id])
|
|
||||||
@diploma.update_attributes(diploma_params)
|
@diploma.update_attributes(diploma_params)
|
||||||
@diploma.save
|
@diploma.save
|
||||||
redirect_to params['referer_url']
|
redirect_to params['referer_url']
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@diploma = Diploma.find(params[:id])
|
|
||||||
@diploma.destroy
|
@diploma.destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -84,6 +82,18 @@ class Admin::DiplomasController < OrbitMemberController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def set_diploma
|
||||||
|
path = request.path.split('/')
|
||||||
|
if path.last.include? '-'
|
||||||
|
uid = path[-1].split("-").last
|
||||||
|
uid = uid.split("?").first
|
||||||
|
else
|
||||||
|
uid = path[-2].split("-").last
|
||||||
|
uid = uid.split("?").first
|
||||||
|
end
|
||||||
|
@diploma = Diploma.find_by(:uid => uid) rescue Diploma.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
def diploma_params
|
def diploma_params
|
||||||
params.require(:diploma).permit! rescue nil
|
params.require(:diploma).permit! rescue nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
<%= link_to diploma.school_name, OrbitHelper.url_to_plugin_show(diploma.to_param,'personal_diploma'), target: "blank"%>
|
<%= link_to diploma.school_name, OrbitHelper.url_to_plugin_show(diploma.to_param,'personal_diploma'), target: "blank"%>
|
||||||
<div class="quick-edit">
|
<div class="quick-edit">
|
||||||
<ul class="nav nav-pills hide">
|
<ul class="nav nav-pills hide">
|
||||||
<li><%= link_to t('edit'), '/admin/members/'+diploma.member_profile.to_param+'/diplomas/'+diploma.id+'/edit' %></li>
|
<li><%= link_to t('edit'), edit_admin_diploma_path(diploma) %></li>
|
||||||
<li><%= link_to t(:delete_), admin_diploma_path(id: diploma.id, member_profile_id: diploma.member_profile.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
|
<li><%= link_to t(:delete_), admin_diploma_path(id: diploma.id), method: :delete, remote: true, data: { confirm: 'Are you sure?' } %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in New Issue