add rebuild the status of filefield in the mongo.
fix the problem about copying dir when lacking that dir.
This commit is contained in:
parent
fcfcd7d058
commit
ae85fe2859
|
@ -21,7 +21,13 @@ class Admin::PatchfilesController < OrbitAdminController
|
|||
end
|
||||
def edit
|
||||
params["filefield"]["file_show"].each do |name,status|
|
||||
@file_to_show.file_show[name][:status] = status.to_i
|
||||
@file_to_show.file_show[name][:status] = status.to_i rescue nil
|
||||
end
|
||||
if params["filefield"]["refresh_btn"] == "true"
|
||||
@default_field = Filefield.new()
|
||||
@file_to_show.file_show = @default_field.file_show
|
||||
@file_to_show.save
|
||||
redirect_to admin_patchfiles_path and return
|
||||
end
|
||||
params["filefield"]["sub_file_fields"].each do |name,files|
|
||||
files.each do |index,file_and_status|
|
||||
|
|
|
@ -74,6 +74,9 @@ class Filefield
|
|||
FileUtils.cd('..')
|
||||
@back_foler = file_name.dup #very important,don't just use '=',it will change original value when it change
|
||||
@back_foler[-1] = "_back/."
|
||||
if !Dir.exist?(file_name)
|
||||
FileUtils.mkdir_p file_name
|
||||
end
|
||||
FileUtils.cp_r(@back_foler, file_name)
|
||||
end
|
||||
end
|
||||
|
@ -82,6 +85,9 @@ class Filefield
|
|||
if (file_name.include? "/") == false
|
||||
FileUtils.cp(file_name , dest_file_path)
|
||||
else
|
||||
if !Dir.exist?(dest_file_path)
|
||||
FileUtils.mkdir_p dest_file_path
|
||||
end
|
||||
FileUtils.cp_r(file_name , dest_file_path+'..')
|
||||
end
|
||||
end
|
||||
|
|
|
@ -39,8 +39,10 @@
|
|||
<%end%>
|
||||
<%=file.submit "#{t(:updatefont)}",{:id=>"updatebtn",:onclick=>"return updatefcn()"}%>
|
||||
<%=file.text_field :recovery_btn, {:id=>"hidden-recovery",:type => "hidden",:value=>"false"} %>
|
||||
<%=file.text_field :refresh_btn, {:id=>"hidden-refresh",:type => "hidden",:value=>"false"} %>
|
||||
<button id="seemessage" onclick="return seelogfcn()"><%=(I18n.locale.to_s =="zh_tw") ? "查看上次更新的logs" : "see logs of prev update "%></button>
|
||||
<button id="recoverybtn" onclick="return recoveryfcn()"><%=(I18n.locale.to_s =="zh_tw") ? "復原到上次更新的檔案狀態" : "recovery to prev file status"%></button>
|
||||
<button id="destroy_mongofield" onclick="return destroy_mongofield_fcn()"><%=(I18n.locale.to_s =="zh_tw") ? "刷新可更新的檔案狀態" : "refresh the status of the update files"%></button>
|
||||
<%end%>
|
||||
<a>網站目錄根路徑:<%=Dir.pwd.to_s%></a>
|
||||
<li id ="ckeditorFont" class="show_li">
|
||||
|
@ -217,4 +219,7 @@
|
|||
});
|
||||
return false;
|
||||
};
|
||||
function destroy_mongofield_fcn(){
|
||||
$('#hidden-refresh').val('true');
|
||||
};
|
||||
</script>
|
Loading…
Reference in New Issue