实训项目权限控制
This commit is contained in:
parent
54eb9b0bca
commit
336c28ccdb
|
@ -379,7 +379,9 @@ class ProjectsController < ApplicationController
|
|||
def settings
|
||||
# 顶部导航
|
||||
@project_menu_type = 10
|
||||
|
||||
if @project.is_child_training_project?
|
||||
return render_404
|
||||
end
|
||||
# 修改查看消息状态
|
||||
applied_messages = ForgeMessage.where("user_id =? and project_id =? and forge_message_type =? and viewed =?", User.current.id, @project, "AppliedProject", 0)
|
||||
applied_messages.update_all(:viewed => true)
|
||||
|
|
|
@ -544,7 +544,7 @@ module ProjectsHelper
|
|||
result = "manage_versions"
|
||||
elsif user.allowed_to?(:manage_repository, @project)
|
||||
result = "manage_repository"
|
||||
elsif user.admin?
|
||||
elsif is_project_manager?(user.id, @project.id)
|
||||
result = "training_task"
|
||||
end
|
||||
result
|
||||
|
|
|
@ -160,6 +160,7 @@ class Project < ActiveRecord::Base
|
|||
after_create :create_board_sync,:acts_as_forge_activities, :create_project_ealasticsearch_index
|
||||
before_destroy :delete_all_members,:delete_project_ealasticsearch_index
|
||||
after_update :update_project_ealasticsearch_index
|
||||
|
||||
def remove_references_before_destroy
|
||||
return if self.id.nil?
|
||||
Watcher.delete_all ['watchable_id = ?', id]
|
||||
|
@ -194,6 +195,7 @@ class Project < ActiveRecord::Base
|
|||
scope :project_entities, -> { where(project_type: ProjectType_project) }
|
||||
scope :course_entities, -> { where(project_type: ProjectType_course) }
|
||||
scope :indexable,lambda { where('is_public = 1')} #用于elastic建索引的scope
|
||||
|
||||
def self.search(query)
|
||||
__elasticsearch__.search(
|
||||
{
|
||||
|
@ -220,6 +222,17 @@ class Project < ActiveRecord::Base
|
|||
}
|
||||
)
|
||||
end
|
||||
|
||||
# 判断项目是否为实训项目
|
||||
def is_training_project?
|
||||
(self.enabled_modules.where("name = 'training_tasks'").empty? && self.training_status == 0) ? false : true
|
||||
end
|
||||
|
||||
# 判断项目是否为开启实训的项目(eg:学生开启实训)
|
||||
def is_child_training_project?
|
||||
self.training_status == 1 ? true :false
|
||||
end
|
||||
|
||||
def new_course
|
||||
self.where('project_type = ?', 1)
|
||||
end
|
||||
|
|
|
@ -15,9 +15,12 @@
|
|||
</div>
|
||||
|
||||
<!--加入、退出、关注项目-->
|
||||
<div class="fr clear mr15">
|
||||
<ul><span id="join_in_project_applied"><%= render :partial => "projects/applied_status" %></span></ul>
|
||||
</div>
|
||||
<% if !@project.is_child_training_project? %>
|
||||
<div class="fr clear mr15">
|
||||
<ul><span id="join_in_project_applied"><%= render :partial => "projects/applied_status" %></span></ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="cl"></div>
|
||||
<% unless @project.forked_from_project_id.nil? %>
|
||||
<div class="fl pro_new_name ml15 clear mt5">
|
||||
|
@ -87,7 +90,7 @@
|
|||
</li>
|
||||
<% end %>
|
||||
|
||||
<% if User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project) %>
|
||||
<% if (User.current.admin? || User.current.allowed_to?({:controller => 'projects', :action => 'settings'}, @project)) && !@project.is_child_training_project? %>
|
||||
<li id="project_menu_010">
|
||||
<%= link_to "#{l(:button_configure)}", settings_project_path(@project), :class => "pro_new_proname" %>
|
||||
</li>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<h2 style="background: #fff; font-size: 14px; color: #333; height: 40px; line-height: 40px; padding-left: 15px; border-bottom:1px solid #e5e5e5;">项目简介
|
||||
<% if User.current.member_of?(@project) %>
|
||||
<% if User.current.member_of?(@project) && !@project.is_child_training_project? %>
|
||||
<span class="fr mr15" id="project_invite_code">邀请码:<span style="color: #333;"><%= @project.invite_code %></span></span>
|
||||
<% end %>
|
||||
</h2>
|
|
@ -55,7 +55,7 @@
|
|||
</div><!--tbc_06 end-->
|
||||
|
||||
<div class="<%= show_memu == 'training_task' ? 'pro_st_dis' : 'pro_st_undis'%>" id="pro_st_tbc_07">
|
||||
<%= render :partial=>"projects/settings/new_trainig_task" if User.current.admin? %>
|
||||
<%= render :partial=>"projects/settings/new_trainig_task" if is_project_manager?(User.current.id, @project.id) %>
|
||||
</div><!--tbc_06 end-->
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -7,11 +7,8 @@
|
|||
<a href="javascript:void(0)" class="fr btn btn-grey">取消</a>
|
||||
<a href="javascript:void(0)" class="fr btn btn-blue mr5">确定</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<h3>请输入脚本</h3>
|
||||
<p><%= link_to "开启实训", training_project_execute_project_path(@project) %></p>
|
||||
<textarea id="pull_request_comment" name="pull_request_comment" class="pullreques_reply_textarea" style="padding-left: 0px;"></textarea>
|
||||
|
||||
|
||||
<textarea>
|
||||
node()
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<!--新版项目头部结束-->
|
||||
<div class="ke-block pro_description_new_info mb10 " style="padding-bottom: 5px;word-break: normal;word-wrap: break-word" >
|
||||
<div id="project_invite_code"><%= render :partial => 'projects/invite_code' %></div>
|
||||
<div id="project_invite_code"><%= render :partial => 'projects/invite_code' %></div>
|
||||
<div id="project_description_code" style="padding: 0 15px 10px 15px;font-size: 14px;">
|
||||
<% if @project.description.blank? %>
|
||||
<p style="padding-top:5px"><%= @project.name %></p>
|
||||
|
|
Loading…
Reference in New Issue