Skip to content

Commit

Permalink
new feature file management
Browse files Browse the repository at this point in the history
  • Loading branch information
guohongze committed Oct 9, 2018
1 parent b1a39c3 commit 154aab8
Show file tree
Hide file tree
Showing 146 changed files with 75,603 additions and 45 deletions.
13 changes: 8 additions & 5 deletions accounts/permission.py
Expand Up @@ -124,10 +124,13 @@ def permission_del(request, ids):
def get_user_permission(request):
ret = []
iUser = UserInfo.objects.get(username=request.user)
role_permission = RoleList.objects.get(name=iUser.role)
role_permission_list = role_permission.permission.all()
for p in role_permission_list:
d = p.name
ret.append(d.encode('ascii'))
try:
role_permission = RoleList.objects.get(name=iUser.role)
role_permission_list = role_permission.permission.all()
for p in role_permission_list:
d = p.name
ret.append(d.encode('ascii'))
except:
data = "Role list is empty"
data = ",".join(ret)
return HttpResponse(str(data))
8 changes: 8 additions & 0 deletions adminset/settings.py
Expand Up @@ -66,6 +66,9 @@
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'elfinder',
'storages',
'mfile'
]

MIDDLEWARE_CLASSES = [
Expand Down Expand Up @@ -295,3 +298,8 @@
)

AUTH_USER_MODEL = 'accounts.UserInfo'
# MEDIA_ROOT = os.path.join(BASE_DIR,'mfile/media')
MEDIA_ROOT = os.path.join('/var/opt/adminset/data')
MEDIA_URL = '/media/'

DEFAULT_FILE_STORAGE = 'storages.backends.sftpstorage.SFTPStorage'
2 changes: 2 additions & 0 deletions adminset/urls.py
Expand Up @@ -14,4 +14,6 @@
url(r'^accounts/', include('accounts.urls')),
url(r'^appconf/', include('appconf.urls')),
url(r'^delivery/', include('delivery.urls')),
url(r'^mfile/', include('mfile.urls')),
url(r'^elfinder/',include('elfinder.urls')),
]
1 change: 1 addition & 0 deletions elfinder/.gitignore
@@ -0,0 +1 @@
*.pyc
1 change: 1 addition & 0 deletions elfinder/__init__.py
@@ -0,0 +1 @@
__version__ = '0.0.1'
7 changes: 7 additions & 0 deletions elfinder/apps.py
@@ -0,0 +1,7 @@
from __future__ import unicode_literals

from django.apps import AppConfig


class ElfinderConfig(AppConfig):
name = 'elfinder'
Empty file added elfinder/conf/__init__.py
Empty file.
203 changes: 203 additions & 0 deletions elfinder/conf/settings.py
@@ -0,0 +1,203 @@
from os.path import join
from django.conf import settings
from elfinder.utils.accesscontrol import fs_standard_access
from elfinder.volumes.filesystem import ElfinderVolumeLocalFileSystem
from elfinder.volumes.storage import ElfinderVolumeStorage
ELFINDER_JS_URLS = {
'a_jquery' : 'http://apps.bdimg.com/libs/jquery/1.8.2/jquery.min.js',
'b_jqueryui' : 'http://apps.bdimg.com/libs/jqueryui/1.9.2/jquery-ui.min.js',
'c_elfinder' : '%selfinder/js/elfinder.full.js' % settings.STATIC_URL,
}
#allow to override any key in the project settings file
ELFINDER_JS_URLS.update(getattr(settings, 'ELFINDER_JS_URLS', {}))

ELFINDER_CSS_URLS = {
'a_jqueryui' : 'http://apps.bdimg.com/libs/jqueryui/1.9.2/themes/smoothness/jquery-ui.css',
'b_elfinder' : '%selfinder/css/elfinder.min.css' % settings.STATIC_URL
}
#allow to override any key in the project settings file
ELFINDER_CSS_URLS.update(getattr(settings, 'ELFINDER_CSS_URLS', {}))

ELFINDER_WIDGET_JS_URL = '%sjs/jquery.elfinder-widget.full.js' % settings.STATIC_URL
ELFINDER_WIDGET_CSS_URL = '%scss/jquery.elfinder-widget.full.css' % settings.STATIC_URL

ELFINDER_LANGUAGES_ROOT_URL = getattr(settings, 'ELFINDER_LANGUAGES_ROOT_URL', '%splugins/elfinder/js/i18n/' % settings.STATIC_URL)

#The available language codes. A corresponding ELFINDER_LANGUAGES_ROOT_URL/elfinder.{ext}.js url must be available
ELFINDER_LANGUAGES = getattr(settings, 'ELFINDER_LANGUAGES', ['ar', 'bg', 'ca', 'cs', 'de', 'el', 'es', 'fa', 'fr', 'hu', 'it', 'jp', 'ko', 'nl', 'no', 'pl', 'pt_BR', 'ru', 'tr', 'zh_CN'])

ELFINDER_CONNECTOR_OPTION_SETS = {
#the default keywords demonstrates all possible configuration options
#it allowes all file types, except from hidden files
'default' : {
'debug' : True, #optionally set debug to True for additional debug messages
'roots' : [
#{
# 'driver' : ElfinderVolumeLocalFileSystem,
# 'path' : join(settings.MEDIA_ROOT, 'files'),
#},
{
'id' : 'lff',
'driver' : ElfinderVolumeLocalFileSystem,
'path' : settings.MEDIA_ROOT,
# 'alias' : 'Files',
#open this path on initial request instead of root path
#'startPath' : '',
'URL' : '%sfiles/' % settings.MEDIA_URL,
#the depth of sub-directory listings that should return per request
#'treeDeep' : 1,
#directory separator. required by client to show paths correctly
#'separator' : os.sep,
#directory for thumbnails
#'tmbPath' : '.tmb',
#Thumbnails dir URL. Set this if you're storing thumbnails outside the root directory
#'tmbURL' : '',
#Thumbnail size (in px)
#'tmbSize' : 48,
#Whether to crop (scale image to fit) thumbnails or not.
#'tmbCrop' : True,
#thumbnails background color (hex #rrggbb or 'transparent')
#'tmbBgColor' : '#ffffff',
#on paste file - if True - old file will be replaced with new one, if False new file get name - original_name-number.ext
'copyOverwrite' : False,
#if True - join new and old directories content on paste
#'copyJoin' : True,
#filter mime types to show
#'onlyMimes' : [],
#on upload - if True - old file will be replaced with new one, if False new file get name - original_name-number.ext
#'uploadOverwrite' : True,
#mimetypes allowed to upload
'uploadAllow' : ['all',],
'mimeDetect' : 'internal',
#mimetypes not allowed to upload
'uploadDeny' : ['all',],
#order to proccess uploadAllow and uploadDeny options
'uploadOrder' : ['deny', 'allow'],
#maximum upload file size. NOTE - this is size for every uploaded files
'uploadMaxSize' : '128m',
#if True - every folder will be check for children folders, otherwise all folders will be marked as having subfolders
#'checkSubfolders' : True,
#allow to copy from this volume to other ones?
#'copyFrom' : True,
#allow to copy from other volumes to this one?
#'copyTo' : True,
#Regular expression against which all new file names will be validated.
#'disabled' : [],
#regexp against which new file names will be validated
#enable this to allow creating hidden files
#'acceptedName' : r'.*',
#callable to control file permissions
#`fs_standard_access` hides all files starting with .
'accessControl' : fs_standard_access,
#default permissions. not set hidden/locked here - take no effect
#'defaults' : {
# 'read' : True,
# 'write' : True
#},
'attributes' : [
{
'pattern' : r'\.tmb$',
'read' : True,
'write': True,
'hidden' : True,
'locked' : True
},
#{
# 'pattern' : r'\/my-inaccessible-folder$',
# 'write' : False,
# 'read' : False,
# 'hidden' : True,
# 'locked' : True
#},
],
#quarantine folder name - required to check archive (must be hidden)
#'quarantine' : '.quarantine',
#Allowed archive's mimetypes to create. Leave empty for all available types.
#'archiveMimes' : [],
#Manual config for archivers. Leave empty for auto detect
'archivers' : {
#create archivers must be a dictionary containing a class implementing the open, add, close methods and the archiver's file extension
#they should operate like the python's built-in tarfile.TarFile classes
#http://docs.python.org/library/tarfile.html
#'create' : { 'ext' : 'rar', 'archiver' : MyRarArchiver },
#extract archiver class must implement the open, extractall and close methods
#they should operate like python's built-in tarfile.TarFile classes
#for more information see http://docs.python.org/library/tarfile.html
#'extract' : { 'ext' : 'rar', 'archiver' : MyRarExtractor },
},
#seconds to cache the file and dir data used by the driver
'cache' : 6
},
]
},
#option set to only allow image files
# 'image' : {
# 'debug' : True,
# 'roots' : [
# {
# 'id' : 'imageid',
# 'driver' : ElfinderVolumeLocalFileSystem,
# 'path' : join(settings.MEDIA_ROOT, u'images'),
# 'alias' : 'Elfinder images',
# 'URL' : '%simages/' % settings.MEDIA_URL,
# 'onlyMimes' : ['image',],
# 'uploadAllow' : ['image',],
# 'uploadDeny' : ['all',],
# 'uploadMaxSize' : '128m',
# 'disabled' : ['mkfile', 'archive'],
# 'accessControl' : fs_standard_access,
# 'attributes' : [
# {
# 'pattern' : r'\.tmb$',
# 'read' : True,
# 'write': True,
# 'hidden' : True,
# 'locked' : True
# },
# ],
# }
# ]
# },
# 'pdf':{
# 'debug':True,
# 'roots':[
# {
# 'id' : 'pdf',
# 'driver' : ElfinderVolumeLocalFileSystem,
# 'path' : join(settings.MEDIA_ROOT, u'pdf'),
# 'alias' : 'pdf',
# 'URL' : '%spdf/' % settings.MEDIA_URL,
# 'onlyMimes' : ['application/pdf',],
# 'uploadAllow' : ['application/pdf',],
# 'uploadDeny' : ['all',],
# 'uploadMaxSize' : '128m',
# 'disabled' : ['mkfile', 'archive'],
# 'accessControl' : fs_standard_access,
# 'attributes' : [
# {
# 'pattern' : r'\.tmb$',
# 'read' : True,
# 'write': True,
# 'hidden' : True,
# 'locked' : True
# },
# ],
# }
# ]
# },
'sftp' : {
'debug' : True,
'roots' : [
{
'id' : 'pdfid',
'alias' : '127.0.0.1',
'driver' : ElfinderVolumeStorage,
'storageClass': 'storages.backends.sftpstorage.SFTPStorage',
'keepAlive' : True,
'cache' : 300
}
]
},
}

ELFINDER_CONNECTOR_OPTION_SETS.update(getattr(settings, 'ELFINDER_CONNECTOR_OPTION_SETS', {}))

0 comments on commit 154aab8

Please sign in to comment.