修改了一些BUG

This commit is contained in:
baiyu 2013-09-30 17:27:58 +08:00
parent 19962f2695
commit 64f36f2c9d
6 changed files with 64 additions and 56 deletions

View File

@ -55,7 +55,7 @@ class MembersController < ApplicationController
user_ids.each do |user_id|
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => user_id)
## added by nie
if params[:membership][:role_ids][0] == "3"
if(params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
project_info << ProjectInfo.new(:user_id => user_id, :project_id => @project.id)
# ProjectInfo.create(:name => "test", :user_id => 123)
end
@ -64,8 +64,8 @@ class MembersController < ApplicationController
else
members << Member.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
## added by nie
if params[:membership][:role_ids][0] == "3"
project_info << Project_info.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
if(params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
project_info << ProjectInfo.new(:role_ids => params[:membership][:role_ids], :user_id => params[:membership][:user_id])
end
## end
end
@ -94,7 +94,7 @@ class MembersController < ApplicationController
@member.role_ids = params[:membership][:role_ids]
#added by nie
if params[:membership][:role_ids][0] == "3"
if(params[:membership][:role_ids] && params[:membership][:role_ids][0] == "3")
@projectInfo = ProjectInfo.new(:user_id => @member.user_id, :project_id => @project.id)
@projectInfo.save
else

View File

@ -484,6 +484,7 @@ class ProjectsController < ApplicationController
@course_tag = params[:project][:project_type]
if(@course_tag=="1")
if User.current.user_extensions.identity == 0
@course = Course.new
@course.extra='course' + DateTime.parse(Time.now.to_s).strftime('%Y-%m-%d_%H-%M-%S').to_s
@course.safe_attributes = params[:project][:course]
@ -491,6 +492,7 @@ class ProjectsController < ApplicationController
# added by bai
@course.term = params[:term]
@course.time = params[:time]
end
# end
# @course.save
# project = ProjectInfo.create(:user_id => User.current.id, :project_id => @project.id)
@ -504,55 +506,57 @@ class ProjectsController < ApplicationController
@project.identifier = @course.extra
end
if @course_tag == '1'
if@course.save
if validate_parent_id && @project.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
# Add current user as a project member if he is not admin
unless User.current.admin?
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new(:user => User.current, :roles => [r])
project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
if params[:project][:is_public] == '1' || @course_tag=="1"
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @course_tag)
end
@project.members << m
@project.project_infos << project
end
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_create)
if params[:continue]
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
redirect_to new_project_path(attrs, :course => '0')
#Added by young
elsif params[:course_continue]
redirect_to new_project_path(:course => '1')
#Ended by young
else
redirect_to settings_project_path(@project,:project_type => 1)
if User.current.user_extensions.identity == 0
if@course.save
if validate_parent_id && @project.save
@project.set_allowed_parent!(params[:project]['parent_id']) if params[:project].has_key?('parent_id')
# Add current user as a project member if he is not admin
unless User.current.admin?
r = Role.givable.find_by_id(Setting.new_project_user_role_id.to_i) || Role.givable.first
m = Member.new(:user => User.current, :roles => [r])
project = ProjectInfo.new(:user_id => User.current.id, :project_id => @project.id)
if params[:project][:is_public] == '1' || @course_tag=="1"
project_status = ProjectStatus.create(:project_id => @project.id, :watchers_count => 0, :changesets_count => 0, :project_type => @course_tag)
end
}
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
@project.members << m
@project.project_infos << project
end
respond_to do |format|
format.html {
flash[:notice] = l(:notice_successful_create)
if params[:continue]
attrs = {:parent_id => @project.parent_id}.reject {|k,v| v.nil?}
redirect_to new_project_path(attrs, :course => '0')
#Added by young
elsif params[:course_continue]
redirect_to new_project_path(:course => '1')
#Ended by young
else
redirect_to settings_project_path(@project,:project_type => 1)
end
}
format.api { render :action => 'show', :status => :created, :location => url_for(:controller => 'projects', :action => 'show', :id => @project.id) }
end
else
@course.destroy
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
end
end
else
@course.destroy
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
end
end
else
if validate_parent_id && @project.save
@project.delete
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
end
else
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
if validate_parent_id && @project.save
@project.delete
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
end
else
respond_to do |format|
format.html { render :action => 'new', :layout => 'base'}#Added by young
format.api { render_validation_errors(@project) }
end
end
end
end

View File

@ -170,7 +170,7 @@
<li><%= link_to l(:label_course_news), {:controller => 'news', :action => 'index', :project_id => @project}, :class => link_class(:news)%></li>
<!-- <li><%= link_to(l(:label_course_repository), {:controller => 'repositories', :action => 'show', :id => @project, :repository_id => nil, :path => nil, :rev => nil, :course => 1 })%></li> -->
<% if User.current.logged? && (User.current.admin? || (!Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.nil? && (Member.where('user_id = ? and project_id = ?', User.current.id, @project.id).first.roles&Role.where('id = ? or id = ?', 3, 7)).size >0))%>
<li><%= link_to l(:label_settings), {:controller => 'projects', :action => 'settings', :id => @project}, :class => link_class(:settings)%></li></ul>
<li><%= link_to l(:label_course_settings), {:controller => 'projects', :action => 'settings', :id => @project}, :class => link_class(:settings)%></li></ul>
<% end %>
</div>
<%= yield %>

View File

@ -7,7 +7,10 @@
<table width="100%" valign="center">
<tr>
<td width="16%"><span style="margin-left:0px"><%= l(:label_new_course)%></span></td>
<td valign="center"><%= link_to(l(:label_course_new), {:controller => 'projects', :action => 'new', :course => 1, :project_type => @project_type}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %></td>
<td valign="center">
<% if User.current.user_extensions.identity == 0 %>
<%= link_to(l(:label_course_new), {:controller => 'projects', :action => 'new', :course => 1, :project_type => @project_type}, :class => 'icon icon-add') if User.current.allowed_to?(:add_project, nil, :global => true) %></td>
<% end %>
<td align="right">
<div class="project-search">
<%= text_field_tag 'name', params[:name], :size => 30 %>

View File

@ -6,11 +6,11 @@
</p>
<% else %>
<p class="font_description">
<%= l(:label_project_course_unadd) %><%= link_to"#{l(:label_course_new)}",:controller=>'projects',:action=>'new', :course => 1 %>
<%= l(:label_project_course_unadd) %><%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1}, :class => 'icon icon-add' %>
</p>
<% end %>
<% else %>
<%= link_to"#{l(:label_course_new)}",:controller=>'projects',:action=>'new', :course => 1 %>
<%= link_to"#{l(:label_course_new)}",{:controller=>'projects',:action=>'new', :course => 1}, :class => 'icon icon-add' %>
<ul class="user_project_sort">
<% for membership in @memberships %>
<li>

View File

@ -709,7 +709,7 @@ zh:
label_latest_revision_plural: 最近的修订版本
label_view_revisions: 查看修订
label_view_all_revisions: 查看所有修订
label_max_size: 最大尺寸
label_max_size: 最大文件大小
label_sort_highest: 置顶
label_sort_higher: 上移
label_sort_lower: 下移
@ -959,7 +959,7 @@ zh:
text_project_destroy_confirmation: 您确信要删除这个项目以及所有相关的数据吗?
text_subprojects_destroy_warning: "以下子项目也将被同时删除:%{value}"
text_workflow_edit: 选择角色和跟踪标签来编辑工作流程
text_are_you_sure: 您确定
text_are_you_sure: 您确定要删除吗
text_journal_changed: "%{label} 从 %{old} 变更为 %{new}"
text_journal_set_to: "%{label} 被设置为 %{value}"
text_journal_deleted: "%{label} 已删除 (%{old})"
@ -1543,3 +1543,4 @@ zh:
label_third_reward: 三等奖
label_excellence_reward: 优秀奖
label_comfort_reward: 入围奖
label_course_settings: 课程设置