Compare commits

...

1 Commits

Author SHA1 Message Date
huang 1fc8e54b1d 实训重置的问题 2017-09-28 11:03:18 +08:00
4 changed files with 25 additions and 1 deletions

View File

@ -108,6 +108,8 @@ class ShixunsController < ApplicationController
end
end
# 实训状态低于未发布则强制重置实训已发布则记录修改的文件路径便于TPI中重置代码
# repository_path数据没有就增加tpi重置完成将status置为0便于统计用户行为
def entry_update
g = Gitlab.client
@path = params[:path]
@ -116,6 +118,13 @@ class ShixunsController < ApplicationController
code_file = g.edit_file(@shixun.gpid, :content => params[:content], :file_path => @path, :branch_name => @rev, :commit_message => "shixun entry")
if @shixun.try(:status).to_i < 2
shixun_modify_status_without_publish(@shixun, 1)
else
@shixun.myshixuns.each do |myshixun|
# 不重复增加记录,但可能会有多条
if RepositoryPath.where(:myshixun_id => myshixun.id, :path => @path, :status => 1).first.blank?
RepositoryPath.create(:path => @path, :myshixun_id => myshixun.id, :user_id => User.current.id, :status => 1)
end
end
end
respond_to do |format|
format.js

View File

@ -0,0 +1,3 @@
class RepositoryPath < ActiveRecord::Base
attr_accessible :myshixun_id, :path, :status, :user_id
end

View File

@ -25,7 +25,7 @@
<%= "(#{number_to_human_size(@entry.size)})" if @entry.size %>
<% end %>
<% else %>
<% if @shixun.try(:status).to_i < 2 %>
<% if @shixun.try(:status).to_i < 2 || User.current.admin? %>
<% if params[:controller] == "shixuns" && params[:action] == "entry_edit" %>
<a href="javascript:void(0);" onclick="$('#shixun_entry_update_id').submit();" class = "fl mr5">保存</a>
<% elsif params[:action] == "shixun_entry" || params[:action] == "entry_update" %>

View File

@ -0,0 +1,12 @@
class CreateRepositoryPaths < ActiveRecord::Migration
def change
create_table :repository_paths do |t|
t.string :path
t.integer :myshixun_id
t.integer :user_id
t.integer :status
t.timestamps
end
end
end