From bd0bd020840992e5c79c352a50c1584847509b84 Mon Sep 17 00:00:00 2001 From: huang Date: Fri, 24 Feb 2017 15:33:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9D=83=E9=99=90=E6=8E=A7=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/projects_controller.rb | 6 +++--- app/controllers/training_tasks_controller.rb | 15 +++++++++++++-- app/views/layouts/_base_project_top.html.erb | 2 +- app/views/projects/_project_activities.html.erb | 2 +- app/views/training_tasks/_content_list.html.erb | 9 +-------- app/views/training_tasks/index.html.erb | 3 --- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index cf1a71424..4eb7bddac 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -932,7 +932,7 @@ class ProjectsController < ApplicationController def training_task_status status = params[:status].to_i task_id = params[:taskId] - message = params[:msg].to_i + message = params[:msg] begin @training_task = TrainingTask.find(task_id) # 如果已经执行成功过,则不重复执行 @@ -953,11 +953,11 @@ class ProjectsController < ApplicationController @training_task.update_attribute(:status, 1) end # 创建一条回复提醒 - content = "恭喜您通过测评" + content = position == original_tasks_count ? "恭喜您,您已经完成了实训项目的所有任务" : "恭喜您,您已经完成了本任务" add_training_task_journal(content, original_project.user_id) end else - content = "很遗憾,您没有通过该步" + content = "很抱歉,您的任务未通过,请继续加油,错误信息如下:#{message}" add_training_task_journal(content, original_project.user_id) end end diff --git a/app/controllers/training_tasks_controller.rb b/app/controllers/training_tasks_controller.rb index 115754ff2..5ec9ae841 100644 --- a/app/controllers/training_tasks_controller.rb +++ b/app/controllers/training_tasks_controller.rb @@ -2,11 +2,12 @@ class TrainingTasksController < ApplicationController layout 'base_projects' + before_filter :find_training_task, :only => [:show, :edit, :update, :add_journal, :complete_training_task] before_filter :find_project, :only => [:index, :new, :create, :update_form, :issue_commits, :commit_for_issue, :issue_commit_delete, :destroy] before_filter :allow_manager, :only => [:index, :show] before_filter :allow_members, :only => [:new, :create] before_filter :build_new_task_from_params, :only => [:new, :create, :update_form] - before_filter :find_training_task, :only => [:show, :edit, :update, :add_journal, :complete_training_task] + # before_filter :find_issues, :only => [:bulk_edit, :bulk_update, :destroy] @@ -95,6 +96,9 @@ class TrainingTasksController < ApplicationController # Add a new issue # The new issue will be created from an existing one if copy_from parameter is given def new + if @project.is_child_training_project? + return render_404 + end # 顶部导航 @project_menu_type = 11 respond_to do |format| @@ -104,6 +108,9 @@ class TrainingTasksController < ApplicationController # 用户发布新任务 def create + if @project.is_child_training_project? + return render_404 + end @training_task.save_attachments(params[:attachments] || (params[:training_task] && params[:training_task][:uploads])) @training_task.subject = params[:training_task][:subject] @training_task.description = params[:training_task][:description] @@ -312,6 +319,10 @@ class TrainingTasksController < ApplicationController render_404 end + def find_training_task + + end + def allow_members if !(User.current.member_of?(@project) || User.current.admin?) render_403 @@ -319,7 +330,7 @@ class TrainingTasksController < ApplicationController end def allow_manager - if !(User.current.admin? || is_project_member?(User.current.id, @project.id)) + if !(User.current.admin? || is_project_manager?(User.current.id, @project.id) || is_project_manager?(User.current, @project.try(:forked_from_project_id)) ) return render_403 end end diff --git a/app/views/layouts/_base_project_top.html.erb b/app/views/layouts/_base_project_top.html.erb index 5fa7417ba..18733a326 100644 --- a/app/views/layouts/_base_project_top.html.erb +++ b/app/views/layouts/_base_project_top.html.erb @@ -43,7 +43,7 @@ <% end %> <% if !@project.enabled_modules.where("name = 'training_tasks'").empty? %> - <% if User.current.admin? || is_project_member?(User.current.id, @project.id) %> + <% if User.current.admin? || is_project_manager?(User.current.id, @project.id) || is_project_manager?(User.current, @project.try(:forked_from_project_id)) %>
  • <%= link_to training_tasks_count > 0 ? "#{l(:project_module_training_tasks)}#{switch_integer_into_k training_tasks_count}".html_safe : "#{l(:project_module_training_tasks)}", project_training_tasks_url(@project), :class => "pro_new_proname", :title => "#{training_tasks_count}" %>
  • diff --git a/app/views/projects/_project_activities.html.erb b/app/views/projects/_project_activities.html.erb index fe504145a..7a2689759 100644 --- a/app/views/projects/_project_activities.html.erb +++ b/app/views/projects/_project_activities.html.erb @@ -41,7 +41,7 @@ <% when "Issue" %> <%= render :partial => 'projects/act_issues', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :project_id => activity.project_id} %> <% when "TrainingTask" %> - <% if User.current.admin? || is_project_member?(User.current.id, @project.id) %> + <% if User.current.admin? || is_project_manager?(User.current.id, @project.id) || is_project_manager?(User.current, @project.try(:forked_from_project_id)) %> <%= render :partial => 'projects/act_training_tasks', :locals => {:activity => activity.forge_act, :user_activity_id => activity.id, :project_id => activity.project_id} %> <% end %> diff --git a/app/views/training_tasks/_content_list.html.erb b/app/views/training_tasks/_content_list.html.erb index b98e44afe..feecafb5a 100644 --- a/app/views/training_tasks/_content_list.html.erb +++ b/app/views/training_tasks/_content_list.html.erb @@ -8,7 +8,7 @@ <% end %>
    - + step<%= activity.position %> <%= activity.subject.to_s %> @@ -31,13 +31,6 @@ <%= activity.journals.count %> <% end %> - <% if @project.is_child_training_project? %> - -
    - <%= render :partial => 'action_status', :locals => {:activity => activity} %> -
    - - <% end %> <% end %> diff --git a/app/views/training_tasks/index.html.erb b/app/views/training_tasks/index.html.erb index 7cf63aea5..caec8ec9a 100644 --- a/app/views/training_tasks/index.html.erb +++ b/app/views/training_tasks/index.html.erb @@ -222,9 +222,6 @@

    所有<%= @training_tasks_count %>

      - <% if @project.is_child_training_project? %> -   - <% end %>