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

View File

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

View File

@ -7,7 +7,10 @@
<table width="100%" valign="center"> <table width="100%" valign="center">
<tr> <tr>
<td width="16%"><span style="margin-left:0px"><%= l(:label_new_course)%></span></td> <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"> <td align="right">
<div class="project-search"> <div class="project-search">
<%= text_field_tag 'name', params[:name], :size => 30 %> <%= text_field_tag 'name', params[:name], :size => 30 %>

View File

@ -6,11 +6,11 @@
</p> </p>
<% else %> <% else %>
<p class="font_description"> <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> </p>
<% end %> <% end %>
<% else %> <% 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"> <ul class="user_project_sort">
<% for membership in @memberships %> <% for membership in @memberships %>
<li> <li>

View File

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