fix for patent without name

This commit is contained in:
Harry Bomrah 2014-10-02 19:58:33 +08:00
parent d4ce2c1b75
commit acb634b862
2 changed files with 19 additions and 8 deletions

View File

@ -1,6 +1,7 @@
class Admin::PatentsController < OrbitMemberController class Admin::PatentsController < OrbitMemberController
layout "member_plugin" layout "member_plugin"
before_action :set_patent, 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::PatentsController < OrbitMemberController
end end
def edit def edit
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil @member = @patent.member_profile rescue nil
@patent = Patent.find(params[:id])
end end
def update def update
@member = MemberProfile.find(patent_params['member_profile_id']) rescue nil @member = @patent.member_profile rescue nil
@patent = Patent.find(params[:id])
@patent.update_attributes(patent_params) @patent.update_attributes(patent_params)
@patent.save @patent.save
redirect_to params['referer_url'] redirect_to params['referer_url']
end end
def destroy def destroy
@patent = Patent.find(params[:id])
@patent.destroy @patent.destroy
end end
@ -82,6 +80,19 @@ class Admin::PatentsController < OrbitMemberController
private private
def set_patent
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
@patent = Patent.find_by(:uid => uid) rescue Patent.find(params[:id])
end
def patent_params def patent_params
params.require(:patent).permit! rescue nil params.require(:patent).permit! rescue nil
end end

View File

@ -5,13 +5,13 @@
<%= link_to patent.patent_title, OrbitHelper.url_to_plugin_show(patent.to_param,'personal_patent').to_s, target: "blank"%> <%= link_to patent.patent_title, OrbitHelper.url_to_plugin_show(patent.to_param,'personal_patent').to_s, 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/'+patent.member_profile.to_param+'/patents/'+patent.id+'/edit' %></li> <li><%= link_to t('edit'), edit_admin_patent_path(patent) %></li>
<li><%= link_to t(:delete_), admin_patent_path(id: patent.id, member_profile_id: patent.member_profile.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li> <li><%= link_to t(:delete_), admin_patent_path(id: patent.id), method: :delete, remote: true, data: { confirm: 'Are you sure?' } %></li>
</ul> </ul>
</div> </div>
</td> </td>
<td><%= patent.patent_no %></td> <td><%= patent.patent_no %></td>
<td><%= patent.patent_country %></td> <td><%= patent.patent_country %></td>
<td><%= patent.member_profile.name %></td> <td><%= patent.member_profile.name rescue "" %></td>
</tr> </tr>
<% end %> <% end %>