diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 0230e562a..3b80bade0 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -21,19 +21,22 @@ class ProjectsController < ApplicationController layout 'base_projects' before_filter :authorize1, :only => [:show] - menu_item :overview, :only => :show - menu_item :roadmap, :only => :roadmap - menu_item :settings, :only => :settings - menu_item :homework, :only => [:homework, :new_homework] - menu_item :feedback, :only => :feedback - menu_item :share, :only => :share - + # menu_item :overview, :only => :show + # menu_item :roadmap, :only => :roadmap + # menu_item :settings, :only => :settings + # menu_item :homework, :only => [:homework, :new_homework] + # menu_item :feedback, :only => :feedback + # menu_item :share, :only => :share + skip_before_filter :verify_authenticity_token, :only => [:training_task_status] + skip_before_filter :check_if_login_required, :only => [:training_task_status] before_filter :find_project, :except => [ :index, :search,:list, :new, :create, :copy, :statistics, :new_join, :course, :enterprise_course, :course_enterprise, :view_homework_attaches,:join_project, :project_home, :training_execute, :training_task_status] before_filter :authorize, :only => [:show, :settings, :edit, :sort_project_members, :update, :modules, :close, :reopen,:view_homework_attaches,:course] before_filter :authorize_global, :only => [:new, :create,:view_homework_attaches] before_filter :require_admin, :only => [ :copy, :unarchive, :destroy, :calendar] before_filter :file + + # 除非项目内人员,不可查看成员, TODO: 完了写报表里去 # before_filter :memberAccess, only: :member @@ -827,6 +830,9 @@ class ProjectsController < ApplicationController # 已经实训过直接跳入 # def training_chiled_project_exec + if !User.current.logged? + return render_403 + end respond_to do |format| format.js end @@ -879,8 +885,14 @@ class ProjectsController < ApplicationController taskId = params[:training_task_id] jobName = @project.forked_from_project_id @training_task = TrainingTask.find(taskId) + step = @training_task.position + + rep_identify = Repository.where(:project_id => @project.id, :type => "Repository::Gitlab").first.try(:identifier) + gitlab_address = Redmine::Configuration['gitlab_address'] + gitUrl = gitlab_address.to_s+"/"+@project.owner.to_s+"/"+ rep_identify + "."+"git" + gitUrl = Base64.encode64(gitUrl) if @training_task.status == 0 - params = {:jobName => "#{jobName}", :taskId => "#{taskId}"} + params = {:jobName => "#{jobName}", :taskId => "#{taskId}", :step => "#{step}", :gitUrl => "#{gitUrl}"} uri = URI.parse("http://123.59.135.74:9999/jenkins-exec/api/buildJob") begin res = uri_exec uri, params @@ -932,7 +944,7 @@ class ProjectsController < ApplicationController def training_task_status status = params[:status].to_i task_id = params[:taskId] - message = params[:msg] + message = Base64.decode64(params[:msg]) begin @training_task = TrainingTask.find(task_id) # 如果已经执行成功过,则不重复执行 @@ -949,8 +961,7 @@ class ProjectsController < ApplicationController ActiveRecord::Base.transaction do if position < original_tasks_count # 继续发布下一个任务 - position = position + 1 - publish_training_tasks original_project_id, @training_task.project_id, position + publish_training_tasks original_project_id, @training_task.project_id, position + 1 end @training_task.update_attribute(:status, 1) # 创建一条回复提醒 diff --git a/app/controllers/training_tasks_controller.rb b/app/controllers/training_tasks_controller.rb index 5ec9ae841..7b49fd44f 100644 --- a/app/controllers/training_tasks_controller.rb +++ b/app/controllers/training_tasks_controller.rb @@ -149,7 +149,11 @@ class TrainingTasksController < ApplicationController def update return unless build_new_task_from_params @training_task.save_attachments(params[:attachments] || (params[:training_task] && params[:training_task][:uploads])) - if @training_task.update_attributes(params[:training_task]) + # params[:training_task][:position] = params[:training_task][:position].to_i + @training_task.position = params[:training_task][:position].to_i + @training_task.subject = params[:training_task][:subject] + @training_task.description = params[:training_task][:description] + if @training_task.save respond_to do |format| format.js format.html{redirect_to training_task_url(@training_task)} diff --git a/app/views/attachments/_project_file_links.html.erb b/app/views/attachments/_project_file_links.html.erb index a1a978a48..3e5457518 100644 --- a/app/views/attachments/_project_file_links.html.erb +++ b/app/views/attachments/_project_file_links.html.erb @@ -84,6 +84,16 @@ #:id => "attachments_" + attachment.id.to_s, :title => l(:button_delete) %> <% end %> + <% elsif attachment.container_type == 'TrainingTask' %> + <% if User.current == attachment.author %> + <%= link_to image_tag('delete.png'), attachment_path(attachment), + :data => {:confirm => l(:text_are_you_sure)}, + :method => :delete, + :class => 'delete', + #:remote => true, + #:id => "attachments_" + attachment.id.to_s, + :title => l(:button_delete) %> + <% end %> <% else %> <%= link_to image_tag('delete.png'), attachment_path(attachment), :data => {:confirm => l(:text_are_you_sure)}, diff --git a/app/views/layouts/_base_project_top.html.erb b/app/views/layouts/_base_project_top.html.erb index 18733a326..4e1433905 100644 --- a/app/views/layouts/_base_project_top.html.erb +++ b/app/views/layouts/_base_project_top.html.erb @@ -10,7 +10,11 @@
<% unless @project.is_public? %><% end %> - <%=link_to "#{@project.owner.try(:show_name)}/".html_safe, user_path(@project.owner), :class => "pro_new_username" %> + <% if @project.is_training_project? %> + <%=link_to "#{@project.owner.try(:show_name)}导师/".html_safe, user_path(@project.owner), :class => "pro_new_username" %> + <% else %> + <%=link_to "#{@project.owner.try(:show_name)}/".html_safe, user_path(@project.owner), :class => "pro_new_username" %> + <% end %> <%=link_to @project.name, project_path(@project), :class => "pro_new_username break_word" %>
diff --git a/app/views/layouts/base_contests.html.erb b/app/views/layouts/base_contests.html.erb index 4b826482b..9e91bbea4 100644 --- a/app/views/layouts/base_contests.html.erb +++ b/app/views/layouts/base_contests.html.erb @@ -77,8 +77,11 @@
+ <% update_visiti_count @contest %> +
访问计数 <%= @contest.visits.to_i %> (自2016年5月)
+ <%= render_flash_messages %>
<%= yield %> diff --git a/app/views/projects/_applied_status.html.erb b/app/views/projects/_applied_status.html.erb index 06bd2bf0b..cde6450a9 100644 --- a/app/views/projects/_applied_status.html.erb +++ b/app/views/projects/_applied_status.html.erb @@ -36,14 +36,15 @@
  • - <% if @project.is_training_project? && User.current.id != @project.user_id %> - <%= link_to "开始实训", training_chiled_project_exec_project_path(@project), :class => "sy_btn_green fr", :remote => true %> - <% else %> - <%= link_to "".html_safe+"Fork", forked_pop_project_path(@project), - :class=>"pro_new_topbtn_left fl", :remote => true %> - <%= project_fork_count %> + <% if User.current.logged? %> + <% if @project.is_training_project? && User.current.id != @project.user_id %> + <%= link_to "开始实训", training_chiled_project_exec_project_path(@project), :class => "sy_btn_green fr", :remote => true %> + <% else %> + <%= link_to "".html_safe+"Fork", forked_pop_project_path(@project), + :class=>"pro_new_topbtn_left fl", :remote => true %> + <%= project_fork_count %> + <% end %> <% end %> -