forked from mirror/MrDoc
修复默认状态下附件上传失败的异常
This commit is contained in:
parent
8ad9fbf32d
commit
d606c842a9
@ -2471,15 +2471,15 @@ def manage_attachment(request):
|
||||
# 限制附件格式
|
||||
# 获取系统设置允许的附件格式,如果不存在,默认仅允许zip格式文件
|
||||
try:
|
||||
attacement_suffix_list = SysSetting.objects.get(types='doc',name='attachment_suffix')
|
||||
attacement_suffix_list = attacement_suffix_list.value.split(',')
|
||||
if attacement_suffix_list == ['']:
|
||||
attacement_suffix_list = ['zip']
|
||||
attachment_suffix_list = SysSetting.objects.get(types='doc',name='attachment_suffix')
|
||||
attachment_suffix_list = attachment_suffix_list.value.split(',')
|
||||
if attachment_suffix_list == ['']:
|
||||
attachment_suffix_list = ['zip']
|
||||
except ObjectDoesNotExist:
|
||||
attachment_suffix_list = ['zip']
|
||||
allow_attachment = False
|
||||
for suffix in attacement_suffix_list:
|
||||
if attachment_name.split('.')[-1] in attacement_suffix_list:
|
||||
for suffix in attachment_suffix_list:
|
||||
if attachment_name.split('.')[-1] in attachment_suffix_list:
|
||||
allow_attachment = True
|
||||
if allow_attachment:
|
||||
a = Attachment.objects.create(
|
||||
|
@ -1,82 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
|
||||
<title>Pear Admin Layui</title>
|
||||
<!-- 依 赖 样 式 -->
|
||||
<link rel="stylesheet" href="component/pear/css/pear.css" />
|
||||
<!-- 加 载 样 式-->
|
||||
<link rel="stylesheet" href="admin/css/load.css" />
|
||||
<!-- 布 局 样 式 -->
|
||||
<link rel="stylesheet" href="admin/css/admin.css" />
|
||||
<!-- 主 题 更 换 -->
|
||||
<style id="pearadmin-bg-color"></style>
|
||||
<!-- 头 部 结 束 -->
|
||||
</head>
|
||||
<!-- 结 构 代 码 -->
|
||||
<body class="layui-layout-body pear-admin">
|
||||
<!-- 布 局 框 架 -->
|
||||
<div class="layui-layout layui-layout-admin">
|
||||
<div class="layui-header">
|
||||
<!-- 顶 部 左 侧 功 能 -->
|
||||
<ul class="layui-nav layui-layout-left">
|
||||
<li class="collaspe layui-nav-item"><a href="#" class="layui-icon layui-icon-shrink-right"></a></li>
|
||||
<li class="refresh layui-nav-item"><a href="#" class="layui-icon layui-icon-refresh-1" loading=600></a></li>
|
||||
</ul>
|
||||
<!-- 顶 部 右 侧 菜 单 -->
|
||||
<div id="control" class="layui-layout-control"></div>
|
||||
<ul class="layui-nav layui-layout-right">
|
||||
<li class="layui-nav-item layui-hide-xs"><a href="#" class="fullScreen layui-icon layui-icon-screen-full"></a></li>
|
||||
<li class="layui-nav-item layui-hide-xs"><a href="http://www.pearadmin.com" class="layui-icon layui-icon-website"></a></li>
|
||||
<li class="layui-nav-item">
|
||||
<!-- 头 像 -->
|
||||
<a href="javascript:;">
|
||||
<img src="admin/images/avatar.jpg" class="layui-nav-img">
|
||||
就眠仪式
|
||||
</a>
|
||||
<!-- 功 能 菜 单 -->
|
||||
<dl class="layui-nav-child">
|
||||
<dd><a user-menu-url="view/system/person.html" user-menu-id="5555" user-menu-title="基本资料">基本资料</a></dd>
|
||||
<dd><a href="login.html">注销登录</a></dd>
|
||||
</dl>
|
||||
</li>
|
||||
<li class="layui-nav-item setting"><a href="#" class="layui-icon layui-icon-more-vertical"></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<!-- 侧 边 区 域 -->
|
||||
<div class="layui-side layui-bg-black">
|
||||
<!-- 顶 部 图 标 -->
|
||||
<div class="layui-logo">
|
||||
<img class="logo"></img>
|
||||
<span class="title"></span>
|
||||
</div>
|
||||
<!-- 侧 边 菜 单 -->
|
||||
<div class="layui-side-scroll">
|
||||
<div id="sideMenu"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 视 图 页 面 -->
|
||||
<div class="layui-body">
|
||||
<div id="content"></div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 遮 盖 层 -->
|
||||
<div class="pear-cover"></div>
|
||||
<!-- 加 载 动 画-->
|
||||
<div class="loader-main">
|
||||
<div class="loader"></div>
|
||||
</div>
|
||||
<!-- 依 赖 脚 本 -->
|
||||
<script src="component/layui/layui.js"></script>
|
||||
<script src="component/pear/pear.js"></script>
|
||||
<!-- 框 架 初 始 化 -->
|
||||
<script>
|
||||
layui.use(['admin'], function() {
|
||||
var admin = layui.admin;
|
||||
|
||||
admin.render();
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -10,31 +10,42 @@
|
||||
|
||||
<!-- 表格工具栏 -->
|
||||
<script type="text/html" id="project-toolbar">
|
||||
<button class="layui-btn layui-btn-normal pear-btn-sm" lay-event="add">
|
||||
<i class="layui-icon layui-icon-add-1"></i>新增
|
||||
</button>
|
||||
<button class="layui-btn layui-btn-warm pear-btn-sm" lay-event="batchRemove">
|
||||
<i class="layui-icon layui-icon-delete"></i>删除
|
||||
</button>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" name="project-search-kw" placeholder="" class="layui-input">
|
||||
</div>
|
||||
<button class="layui-btn layui-btn-primary pear-btn-sm" lay-event="search">
|
||||
<i class="layui-icon layui-icon-search"></i>搜索
|
||||
</button>
|
||||
<button class="layui-btn layui-btn-normal pear-btn-sm" lay-event="add">
|
||||
<i class="layui-icon layui-icon-add-1"></i>新增
|
||||
</button>
|
||||
<button class="layui-btn layui-btn-warm pear-btn-sm" lay-event="batchRemove">
|
||||
<i class="layui-icon layui-icon-delete"></i>删除
|
||||
</button>
|
||||
|
||||
</script>
|
||||
|
||||
<!-- 文集名称 -->
|
||||
<script type="text/html" id="project-name">
|
||||
{% verbatim %}
|
||||
<a href="/project-{{d.id}}/" target="_blank">{{d.name}}</a>
|
||||
<a href="/project-{{d.id}}/" target="_blank">
|
||||
{{d.name}}
|
||||
{{#if (d.role == 0) { }}
|
||||
{{# }else if(d.role == 1){ }}
|
||||
<span tooltip="私密" placement="right"><i class="layui-icon layui-icon-password"></i></span>
|
||||
{{# }else if(d.role == 2){ }}
|
||||
<span tooltip="指定用户" placement="right"><i class="layui-icon layui-icon-user"></i></span>
|
||||
{{# }else if(d.role == 3){ }}
|
||||
<span tooltip="访问码" placement="right"><i class="layui-icon layui-icon-key"></i></span>
|
||||
{{# } }}
|
||||
</a>
|
||||
{% endverbatim %}
|
||||
</script>
|
||||
|
||||
<!-- 单个文集操作 -->
|
||||
<script type="text/html" id="project-bar">
|
||||
{% verbatim %}
|
||||
<!-- <button class="pear-btn pear-btn-normal pear-btn-md" lay-event="sort" ><i class="layui-icon layui-icon-cols"></i></button> -->
|
||||
<a href="/manage_pro_doc_sort/{{d.id}}/" class="layui-btn layui-btn-primary pear-btn-sm" lay-event="sort"><i class="layui-icon layui-icon-cols"></i></a>
|
||||
<a href="/modify_pro/?pro_id={{d.id}}" title="修改文集配置" class="layui-btn layui-btn-primary pear-btn-sm"><i class="layui-icon layui-icon-set"></i></a>
|
||||
<button class="layui-btn layui-btn-warm pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i></button>
|
||||
{% endverbatim %}
|
||||
@ -82,11 +93,11 @@
|
||||
let cols = [
|
||||
[
|
||||
{type: 'checkbox',width:20},
|
||||
{title: '文集名称',field: 'name',align: 'left',templet:"#project-name"},
|
||||
{title: '简介',field: 'intro',align: 'left',templet:"#share-type"},
|
||||
{title: '权限',field: 'role',align: 'left',templet:"#project-role"},
|
||||
{title: '文档总数',field: 'doc_total',align: 'left',width: 100},
|
||||
{title: '协作人数',field: 'colla_total',align: 'left',width: 90,templet:"#colla-cnt"},
|
||||
{title: '文集名称',field: 'name',align: 'left',templet:"#project-name",minWidth:200},
|
||||
// {title: '简介',field: 'intro',align: 'left',templet:"#share-type"},
|
||||
// {title: '权限',field: 'role',align: 'left',templet:"#project-role"},
|
||||
{title: '文档数',field: 'doc_total',align: 'left',width:90},
|
||||
{title: '协作人数',field: 'colla_total',align: 'left',templet:"#colla-cnt",width:90},
|
||||
{title: '创建时间',field: 'create_time',align: 'left',templet:"#project-create-time"},
|
||||
{title: '操作',toolbar: '#project-bar',align: 'left',}
|
||||
]
|
||||
|
224
template/app_doc/manage_project_doc_sort.html
Normal file
224
template/app_doc/manage_project_doc_sort.html
Normal file
@ -0,0 +1,224 @@
|
||||
{% extends 'app_doc/user/user_base.html' %}
|
||||
{% load static %}
|
||||
{% block title %}文集文档排序{% endblock %}
|
||||
{% block custom_element %}
|
||||
<link href="{% static 'tagsInput/tagsinput.css' %}" rel="stylesheet" type="text/css"/>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-row" style="padding-left:15px;">
|
||||
<span class="layui-breadcrumb" lay-separator=">">
|
||||
<a href="{% url 'manage_project' %}">文集管理</a>
|
||||
<a><cite>文集文档排序</cite></a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<div class="layui-card-header" style="margin-bottom: 10px;">
|
||||
<div class="layui-row">
|
||||
<span style="font-size:18px;">文集:{{pro.name}}</span>
|
||||
<button class="layui-btn layui-btn-normal layui-btn-sm" style="float: right;" id="save-sort-btn">保存排序</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-row">
|
||||
<div id="nested" class="row">
|
||||
<ul id="nestedDemo" class="list-group col nested-sortable">
|
||||
{% for docs in doc_list %}
|
||||
<li data-sortable-id="{{docs.id}}" class="list-group-item">{{docs.title}}
|
||||
{% if docs.children %}
|
||||
<i class="layui-icon layui-icon-down switch-toc"></i>
|
||||
<ul class="list-group nested-sortable">
|
||||
{% for node in docs.children %}
|
||||
<li data-sortable-id="{{node.id}}" class="list-group-item">{{node.title}}
|
||||
{% if node.children %}
|
||||
<i class="layui-icon layui-icon-down switch-toc"></i>
|
||||
<ul class="list-group nested-sortable">
|
||||
{% for doc in node.children %}
|
||||
<li data-sortable-id="{{doc.id}}" class="list-group-item">{{doc.title}}
|
||||
<ul class="list-group nested-sortable"></ul>
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<ul class="list-group nested-sortable"></ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<ul class="list-group nested-sortable"></ul>
|
||||
{% endif %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block custom_script %}
|
||||
<!-- 文集文档排序样式 -->
|
||||
<style>
|
||||
.row {
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-ms-flex-wrap: wrap;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.list-group {
|
||||
display: -ms-flexbox;
|
||||
display: flex;
|
||||
-ms-flex-direction: column;
|
||||
flex-direction: column;
|
||||
padding-left: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.col {
|
||||
-ms-flex-preferred-size: 0;
|
||||
flex-basis: 0;
|
||||
-ms-flex-positive: 1;
|
||||
flex-grow: 1;
|
||||
max-width: 100%;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
padding-right: 15px;
|
||||
padding-left: 15px;
|
||||
}
|
||||
.list-group-item:first-child {
|
||||
border-top-left-radius: .25rem;
|
||||
border-top-right-radius: .25rem;
|
||||
}
|
||||
.list-group-item {
|
||||
position: relative;
|
||||
display: block;
|
||||
padding: .75rem 1.25rem;
|
||||
margin-bottom: -1px;
|
||||
background-color: #fff;
|
||||
border: 1px solid rgba(0,0,0,.125);
|
||||
}
|
||||
.list-group-item:first-child {
|
||||
border-top-left-radius: 0.25rem;
|
||||
border-top-right-radius: 0.25rem;
|
||||
}
|
||||
|
||||
.list-group-item:last-child {
|
||||
margin-bottom: 0;
|
||||
border-bottom-right-radius: 0.25rem;
|
||||
border-bottom-left-radius: 0.25rem;
|
||||
}
|
||||
|
||||
.list-group-item:hover, .list-group-item:focus {
|
||||
z-index: 1;
|
||||
text-decoration: none;
|
||||
}
|
||||
.list-group-item.disabled, .list-group-item:disabled {
|
||||
color: #6c757d;
|
||||
pointer-events: none;
|
||||
background-color: #fff;
|
||||
}
|
||||
|
||||
.list-group-item.active {
|
||||
z-index: 2;
|
||||
color: #fff;
|
||||
background-color: #007bff;
|
||||
border-color: #007bff;
|
||||
}
|
||||
.toc-close {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<script src="{% static 'jquery/3.1.1/jquery.min.js' %}"></script>
|
||||
<script src="{% static 'layui/layui.all.js' %}"></script>
|
||||
<!-- 文档拖拽排序 -->
|
||||
<script src="{% static 'sortablejs/Sortable.js' %}"></script>
|
||||
<script>
|
||||
$.ajaxSetup({
|
||||
data: {csrfmiddlewaretoken: '{{ csrf_token }}' },
|
||||
});
|
||||
// 文档动态排序
|
||||
function docSort(){
|
||||
// Nested demo
|
||||
var nestedSortables = [].slice.call(document.querySelectorAll('.nested-sortable'));
|
||||
// Loop through each nested sortable element
|
||||
for (var i = 0; i < nestedSortables.length; i++) {
|
||||
new Sortable(nestedSortables[i], {
|
||||
group: {
|
||||
name:'docsort',
|
||||
pull: function(event) {
|
||||
var deep = event.el.parentNode.parentNode.parentNode.parentNode.className
|
||||
if(deep == 'list-group nested-sortable') return false;
|
||||
return true;
|
||||
},
|
||||
},
|
||||
animation: 150,//定义排序动画的时间
|
||||
fallbackOnBody: true, // 将cloned DOM 元素挂到body元素上
|
||||
invertSwap:true,
|
||||
swapThreshold: 0.65,
|
||||
onAdd:function(evt){
|
||||
console.log(evt)
|
||||
// console.log(evt.to)
|
||||
let current_ele = $(evt.item)
|
||||
console.log(current_ele[0])
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
// 获取排序值
|
||||
const nestedQuery = '.nested-sortable';
|
||||
const identifier = 'sortableId';
|
||||
const root = document.getElementById('nestedDemo');
|
||||
function serialize(sortable) {
|
||||
var serialized = [];
|
||||
var children = [].slice.call(sortable.children);
|
||||
for (var i in children) {
|
||||
var nested = children[i].querySelector(nestedQuery);
|
||||
serialized.push({
|
||||
id: children[i].dataset[identifier],
|
||||
children: nested ? serialize(nested) : []
|
||||
});
|
||||
}
|
||||
return serialized
|
||||
}
|
||||
function getLevel(){
|
||||
console.log(serialize(root))
|
||||
};
|
||||
// 展开收起左边目录
|
||||
$(function(){
|
||||
$("body").on('click','.switch-toc',SwitchToc)
|
||||
});
|
||||
function SwitchToc(i){
|
||||
console.log("点击了")
|
||||
var $me = $(this);
|
||||
$(this).next("ul").toggleClass("toc-close"); //切换展开收起样式
|
||||
$(this).toggleClass("layui-icon-left layui-icon-down");//切换图标
|
||||
};
|
||||
// 保存排序
|
||||
$("#save-sort-btn").on('click',function(){
|
||||
layer.load(1)
|
||||
var sort_data = {
|
||||
'pid':'{{pro.id}}',
|
||||
'sort_data':JSON.stringify(serialize(root)),
|
||||
}
|
||||
// console.log(sort_data)
|
||||
$.post('{% url "manage_pro_doc_sort" pro.id %}',sort_data,function(r){
|
||||
if(r.status){
|
||||
layer.closeAll('loading')
|
||||
layer.msg("完成文集排序",function(){
|
||||
layer.close(index)
|
||||
})
|
||||
|
||||
}else{
|
||||
layer.closeAll('loading')
|
||||
layer.msg("修改导入文集出错")
|
||||
}
|
||||
});
|
||||
})
|
||||
docSort();
|
||||
</script>
|
||||
{% endblock %}
|
Loading…
Reference in New Issue
Block a user