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