fix for projects without name
This commit is contained in:
parent
26418ef119
commit
afbacfb9f9
|
@ -1,6 +1,7 @@
|
||||||
class Admin::ProjectsController < OrbitMemberController
|
class Admin::ProjectsController < OrbitMemberController
|
||||||
layout "member_plugin"
|
layout "member_plugin"
|
||||||
|
|
||||||
|
before_action :set_project, 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::ProjectsController < OrbitMemberController
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@member = MemberProfile.find_by(:uid=>params['uid']) rescue nil
|
@member = @project.member_profile rescue nil
|
||||||
@project = Project.find(params[:id])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@member = MemberProfile.find(project_params['member_profile_id']) rescue nil
|
@member = @project.member_profile rescue nil
|
||||||
@project = Project.find(params[:id])
|
|
||||||
@project.update_attributes(project_params)
|
@project.update_attributes(project_params)
|
||||||
@project.save
|
@project.save
|
||||||
redirect_to params['referer_url']
|
redirect_to params['referer_url']
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
@project = Project.find(params[:id])
|
|
||||||
@project.destroy
|
@project.destroy
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -82,6 +80,18 @@ class Admin::ProjectsController < OrbitMemberController
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
|
def set_project
|
||||||
|
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
|
||||||
|
@project = Project.find_by(:uid => uid) rescue Project.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
def project_params
|
def project_params
|
||||||
params.require(:project).permit! rescue nil
|
params.require(:project).permit! rescue nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,14 +5,14 @@
|
||||||
<%= link_to project.project_title, OrbitHelper.url_to_plugin_show(project.to_param,'personal_project').to_s, target: "blank"%>
|
<%= link_to project.project_title, OrbitHelper.url_to_plugin_show(project.to_param,'personal_project').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/'+project.member_profile.to_param+'/projects/'+project.id+'/edit' %></li>
|
<li><%= link_to t('edit'), edit_admin_project_path(project) %></li>
|
||||||
<li><%= link_to t(:delete_), admin_project_path(id: project.id, member_profile_id: project.member_profile.id), method: :delete, remote: true, data: { confirm: t('sure?') } %></li>
|
<li><%= link_to t(:delete_), admin_project_path(id: project.id), method: :delete, remote: true, data: { confirm: 'Are you sure?' } %></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td><%= project.job_title %></td>
|
<td><%= project.job_title %></td>
|
||||||
<td><%= project.participator %></td>
|
<td><%= project.participator %></td>
|
||||||
<td><%= project.unit %></td>
|
<td><%= project.unit %></td>
|
||||||
<td><%= project.member_profile.name %></td>
|
<td><%= project.member_profile.name rescue "" %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% end %>
|
<% end %>
|
Loading…
Reference in New Issue