项目版本库历史版本删除功能及弹框样式

This commit is contained in:
huang 2016-10-14 14:28:51 +08:00
parent db63a5514d
commit 4646f20bba
5 changed files with 34 additions and 20 deletions

View File

@ -644,7 +644,6 @@ class AttachmentsController < ApplicationController
#找到文件的所有的历史版本
def attachment_versions
@project = Project.find(params[:project_id])
@attachment = Attachment.find(params[:id])
@attachment_histories = @attachment.attachment_histories
respond_to do |format|

View File

@ -1380,6 +1380,21 @@ module ApplicationHelper
end
end
# 判断课程、项目、组织是否有权限删除历史资源
# 项目管理员或者附件的作者可以删除
# (is_project_manager?(User.current.id, @project.id) || User.current.id == history.author_id)
def allow_to_delete_attachment history
attachment = history.attachment
case attachment.try(:container_type)
when "Project"
result = is_project_manager?(User.current.id, attachment.container_id) || User.current.id == history.author_id
when "Course"
result = User.current.allowed_to?(:as_teacher, attachment.container) || User.current.id == history.author_id
when "Organization"
# result = || User.current.id == history.author_id
end
end
# Wiki links
#
# Examples:

View File

@ -28,8 +28,9 @@
<%= link_to( '删除资源', attachment_path(history.attachment, :history_id => history, :type => "history"),
:remote => true,
:data => {:confirm => l(:text_are_you_sure)},
:method => :delete,:class => "postOptionLink",
:class => "btn") if (is_project_manager?(User.current.id, @project.id) || User.current.id == history.author_id) %>
:method => :delete,
:class => "postOptionLink",
:class => "btn") if allow_to_delete_attachment(history) %>
</th>
</tr>
<% end %>
@ -50,8 +51,8 @@
</div>
<div class="cl"></div>
<textarea style="resize:none" type="text" placeholder="请在此编辑资源描述" name="description" class="mr15 mb10 muban_textarea" ><%= @attachment.description %></textarea>
<div class="clear ">
<%= submit_tag '确定', :onclick => 'upload_attachment_version(event);', :onfocus => 'this.blur()', :id => 'upload_files_submit_btn', :class => 'btn btn-blue fr mr5' %>
<div class="clear mb15">
<a href="javascript:void(0);" id="upload_files_cancle_btn" class="btn fr" onclick="hideModal();">取消</a>
<%= submit_tag '确定', :onclick => 'upload_attachment_version(event);', :onfocus => 'this.blur()', :id => 'upload_files_submit_btn', :class => 'btn btn-blue fr mr5' %>
</div>
<% end %>

View File

@ -1,17 +1,16 @@
<% if @container_type == 0 %>
<div id="resource_list">
<%= render :partial => 'project_file', locals: {project: @project} %>
</div>
<% elsif @container_type == 1 %>
<div id="resource_list">
<%= render :partial => 'course_file', locals: {course: @course} %>
</div>
<% elsif @container_type == 2 %>
<div id="resource_list">
<%= render :partial => 'files/subfield_files', locals: {org_subfield: @org_subfield} %>
</div>
<% end %>
<% if @container_type == 0 %>
<div id="resource_list">
<%= render :partial => 'project_file', locals: {project: @project} %>
</div>
<% elsif @container_type == 1 %>
<div id="resource_list">
<%= render :partial => 'course_file', locals: {course: @course} %>
</div>
<% elsif @container_type == 2 %>
<div id="resource_list">
<%= render :partial => 'files/subfield_files', locals: {org_subfield: @org_subfield} %>
</div>
<% end %>
<script type='text/javascript'>
var slideHeight = 29;

View File

@ -19,7 +19,7 @@
<%= javascript_heads %>
<%= heads_for_theme %>
<%= call_hook :view_layouts_base_html_head %>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','sy_public','syllabus'%>
<%= stylesheet_link_tag 'jquery/jquery-ui-1.9.2','css/common','css/public', 'css/structure','prettify', 'css/courses','css/popup','sy_public','syllabus', 'css/moduel'%>
<%= javascript_include_tag "course","avatars","header","attachments",'prettify' %>
<!-- page specific tags -->
<%= yield :header_tags -%>