Merge branch 'develop' of https://git.trustie.net/jacknudt/trustieforge into develop

This commit is contained in:
cxt 2016-10-14 20:31:53 +08:00
commit d5eea455e9
16 changed files with 126 additions and 19 deletions

View File

@ -336,11 +336,23 @@ class AttachmentsController < ApplicationController
AttachmentHistory.find(params[:history_id]).destroy
@attachment = Attachment.find(params[:id])
@is_history = true
@is_history_destroy = false
@attachment_histories = @attachment.attachment_histories
rescue Exception => e
puts e
end
elsif params[:type] == "history_delete"
begin
AttachmentHistory.find(params[:history_id]).destroy
@attachment = Attachment.find(params[:id])
@is_history_delete = true
@is_history_destroy = false
@attachment_histories = @attachment.attachment_histories
rescue Exception => e
puts e
end
else
@history = params[:history]
if @attachment.container.respond_to?(:init_journal)
@attachment.container.init_journal(User.current)
end
@ -644,6 +656,7 @@ class AttachmentsController < ApplicationController
#找到文件的所有的历史版本
def attachment_versions
@history = params[:history]
@attachment = Attachment.find(params[:id])
@attachment_histories = @attachment.attachment_histories
respond_to do |format|
@ -651,6 +664,14 @@ class AttachmentsController < ApplicationController
end
end
def attachment_versions_delete
@attachment = Attachment.find(params[:id])
@attachment_histories = @attachment.attachment_histories
respond_to do |format|
format.js
end
end
#找到文件的所有的历史版本及当前版本
def attachment_history_download
@attachment = Attachment.find(params[:id])

View File

@ -1391,7 +1391,7 @@ module ApplicationHelper
when "Course"
result = User.current.allowed_to?(:as_teacher, attachment.container) || User.current.id == history.author_id || User.current.admin?
when "OrgSubfield"
result = User.current.id == history.author_id || User.current.admin_of_org?(@organization) || User.current.admin?
result = User.current.id == history.author_id || User.current.admin_of_org?(attachment.container) || User.current.admin?
end
end

View File

@ -0,0 +1,11 @@
<div class="muban_popup_top">
<h3 class="fl">删除资源</h3>
<a href="javascript:void(0);" class="muban_icons_close fr" onclick="hideModal();"></a>
<div class="cl"></div>
</div>
<div class="muban_popup_con" >
<div class=" clear ml15 mr15 mt15" id="attachment_history_popub">
<%= render :partial => "files/attachment_history_popub_delete" %>
</div>
</div>

View File

@ -1,6 +1,7 @@
<div class="clear mb10">
<a class="sub_btn fl" name="button" onclick="_file.click()" onmouseover="" style="<%= ie8? ? 'display:none' : ''%>">文件浏览</a>
<p class="fl ml5 mt3 sy_cgrey">(未选择文件) 您可以上传小于<span class="c_red">50MB</span>的文件</p>
<p class="fl ml5 mt3 sy_cgrey" ><span id="upload_file_count" class="c_red">(未选择文件)</span> 您可以上传小于<span class="c_red">50MB</span>的文件</p>
</div>
<%= file_field_tag 'attachments[dummy][file]',

View File

@ -0,0 +1,2 @@
var htmlvalue = "<%= escape_javascript(render :partial => 'attachments/show_attachment_history_delete') %>";
pop_box_new(htmlvalue,820,360);

View File

@ -3,6 +3,15 @@
$("#attachment_history_popub").html('<%= escape_javascript( render :partial => 'files/attachment_history_popub') %>');
<% end %>
<% if @is_history_delete %>
$("#attachment_history_popub").html('<%= escape_javascript( render :partial => 'files/attachment_history_popub_delete') %>');
<% end %>
//历史版本删除局部刷新
<% if @is_history_destroy %>
$("#attachment_history_popub").html('<%= escape_javascript( render :partial => 'files/attachment_history_popub') %>');
<% end %>
<% if @is_destroy%>
$("#attachment_<%= @attachment.id%>").remove();
if(document.getElementById("revise_attachment_div_<%= @attachment.id%>")) {

View File

@ -1,7 +1,7 @@
<% if @flag %>
hideModal();
alert('更新成功')
$(".re_search").submit();
// $(".re_search").submit();
<%else%>
$("#upload_file_count").html('(更新失败)')
<%end %>

View File

@ -55,4 +55,4 @@
<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 %>
<% end %>

View File

@ -0,0 +1,54 @@
<table class="muban_table mb10" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th>资源名称</th>
<th >下载数</th>
<th>引用数</th>
<th>版本号</th>
<th></th>
</tr>
</thead>
<tbody>
<tr>
<th ><p class="popup_ziyuan_title"><%= @attachment.filename %><span class="muban_icons_blue ml5">当前版本</span></p></th>
<th><%= @attachment.downloads %></th>
<th><%= @attachment.try(:quotes).to_i %></th>
<th><%= format_time(@attachment.created_on) %></th>
<th></th>
</tr>
<% @attachment_histories.each do |history| %>
<tr>
<th ><p class="popup_ziyuan_title">
<%= link_to history.filename, download_history_attachment_path(history.id, history.filename), :title => history.filename+"\n"+history.description.to_s %></p>
</th>
<th><%= history.downloads %></th>
<th><%= history.try(:quotes).to_i %></th>
<th><%= format_time(history.created_on) %></th>
<th>
<%= link_to( '删除资源', attachment_path(history.attachment, :history_id => history, :type => "history_delete"),
:remote => true,
:data => {:confirm => l(:text_are_you_sure)},
:method => :delete,
:class => "postOptionLink",
:class => "btn") if allow_to_delete_attachment(history) %>
</th>
</tr>
<% end %>
</tbody>
</table>
<div>
<% if @attachment.container_type == "Project" %>
<%= link_to( '删除所有资源', attachment_path(@attachment, :history_delete => true), :data => {:confirm => l(:text_history_are_you_sure)}, :method => :delete,:class => "fr fontGrey2 mb5", :onclick =>"hideModal();") if (is_project_manager?(User.current.id, @attachment.container_id) || User.current.id == @attachment.author_id || User.current.admin?) %>
<% elsif @attachment.container_type == "Course" %>
<%= link_to( '删除所有资源', attachment_path(@attachment, :history_delete => true), :data => {:confirm => l(:text_history_are_you_sure)}, :method => :delete,:class => "fr fontGrey2 mb5", :onclick =>"hideModal();") if (User.current.allowed_to?(:as_teacher, @attachment.container) || User.current.id == @attachment.author_id || User.current.admin?) %>
<% elsif @attachment.container_type == "OrgSubfield" %>
<%= link_to( '删除所有资源', attachment_path(@attachment, :history => true), :data => {:confirm => l(:text_history_are_you_sure)}, :method => :delete,:class => "fr fontGrey2 mb5", :onclick =>"hideModal();") if (User.current.id == @attachment.author_id || User.current.admin_of_org?(@attachment) || User.current.admin?) %>
<% end %>
</div>

View File

@ -81,9 +81,11 @@
</li>
<%end%>
<li>
<%= link_to( '删除资源', attachment_path(file),
:data => {:confirm => file.destroyable ? l(:text_are_you_sure) : l(:text_history_are_you_sure)},
:method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %>
<% if file.destroyable %>
<%= link_to( '删除资源', attachment_path(file),:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == @course.id && file.container_type == "Course" %>
<% else %>
<%= link_to '删除资源',attachment_versions_delete_path(file), :class => "postOptionLink", :remote => true %>
<% end %>
</li>
</ul>
<% end %>

View File

@ -27,7 +27,11 @@
</li>
<% end %>
<li>
<%= link_to( '删除资源', attachment_path(file),:data => {:confirm => file.destroyable ? l(:text_are_you_sure) : l(:text_history_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == project.id && file.container_type == "Project" %>
<% if file.destroyable %>
<%= link_to( '删除资源', attachment_path(file),:data => {:confirm => l(:text_are_you_sure)}, :method => :delete,:class => "postOptionLink") if (delete_allowed || User.current.id == file.author_id) && file.container_id == project.id && file.container_type == "Project" %>
<% else %>
<%= link_to '删除资源',attachment_versions_delete_path(file), :class => "postOptionLink", :remote => true %>
<% end %>
</li>
</ul>
<% end %>

View File

@ -441,12 +441,10 @@
if($("#upload_form").find('.upload_filename').length > 1){
$("#upload_file_count").html('(只能上传一个更新文件)')
event.preventDefault();
return false;
}else if($("#upload_form").find('.upload_filename').length == 0){
$("#upload_file_count").html('(请上传一个更新文件)')
event.preventDefault();
return false;
}else{
$("#upload_form").submit();

View File

@ -1,7 +1,7 @@
<div class="testStatus" onmouseover="$('#poll_head_edit_pen').show();" onmouseout="$('#poll_head_edit_pen').hide();"><!--头部显示 start-->
<a href="javascript:" class="testEdit undis" id="poll_head_edit_pen" title="编辑" onclick="pollsEdit();" style="top:0;"></a>
<!-- <a class='ur_icon_add' title='导入' id="import_btn" onclick="importPoll();"></a> -->
<h1 class="ur_page_title" id="polls_name_h"><%= poll.polls_name%></h1>
<h1 class="ur_page_title" id="polls_name_h" style="width:668px; margin:0 auto;"><%= poll.polls_name%></h1>
<div class="testDesEdit mt5"><%= @poll.polls_description.nil? ? "" : @poll.polls_description.html_safe%></div>
<div class="cl"></div>
</div><!--头部显示 end-->

View File

@ -1,7 +1,11 @@
<h3><%=l(:label_version)%></h3>
<%= labelled_form_for @version,:html=>{:id=>"new_project_version_form"} do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<a href="#" onclick="$('#new_project_version_form').submit();" class="blue_btn ml110"><%=l(:button_save)%></a>
<% end %>
<h3><%=l(:label_version)%></h3>
<%= labelled_form_for @version,:html=>{:id=>"new_project_version_form"} do |f| %>
<%= render :partial => 'form', :locals => { :f => f } %>
<a href="#" onclick="$('#new_project_version_form').submit();" class="blue_btn ml110"><%=l(:button_save)%></a>
<% end %>
<script>
$("#new_project_version_form").parent().css({"width":"730px","background-color":"#fff","padding":"10px","margin-left":"10px","margin-bottom":"10px"});
</script>

View File

@ -1015,6 +1015,7 @@ RedmineApp::Application.routes.draw do
# additional routes for having the file name at the end of url
get 'attachments/:id/:filename', :to => 'attachments#show', :id => /\d+/, :filename => /.*/, :as => 'named_attachment'
get 'attachments/attachment_versions/:id',:to=>'attachments#attachment_versions',:as=>'attachments_versions'
get 'attachments/attachment_versions_delete/:id',:to=>'attachments#attachment_versions_delete',:as=>'attachment_versions_delete'
get 'attachments/attachment_history_download/:id',:to=>'attachments#attachment_history_download',:as=>'attachment_history_download'
post 'attachments/upload_attachment_version',:to=>'attachments#upload_attachment_version',:as=>'upload_attachment_version'
get 'attachments/download/:id/:filename', :to => 'attachments#download', :id => /\d+/, :filename => /.*/, :as => 'download_named_attachment'

View File

@ -231,7 +231,7 @@ a.exit { height:24px; display:block; width:80px; color:#000000; background:#c3c3
.lh22{ line-height: 22px;}
/*上传资源弹出框样式*/
.popbox_polls{width:300px;height:100px;position:fixed !important;z-index:100;left:50%;top:50%;/*margin:-100px 0 0 -150px;*/ background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
.popbox_polls{width:300px;height:100px;position:fixed !important;z-index:100;left:40%;top:40%;/*margin:-100px 0 0 -150px;*/ background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; overflow:auto;}
.upload_con h2{ display:block; background:#eaeaea; font-size:14px; color:#343333; height:31px; width: auto; margin-top:25px; padding-left:20px; padding-top:5px;}
.upload_box{ width:430px; margin:15px auto;}