download page: waiting...

pull/26/head
liuzheng712 2015-11-06 23:04:09 +08:00
parent f220ea367e
commit 44a330ac02
3 changed files with 35 additions and 7 deletions

View File

@ -18,5 +18,5 @@ urlpatterns = patterns('',
# (r'^jlog/', include('jlog.urls')),
(r'^jperm/', include('jperm.urls')),
(r'^node_auth/', 'jumpserver.views.node_auth'),
(r'download/(\d{4}/\d\d/\d\d/.*)', 'jumpserver.views.download_file')
)

View File

@ -356,17 +356,18 @@ def Logout(request):
#
# return HttpResponse(json.dumps(result, sort_keys=True, indent=2), content_type='application/json')
####################### liuzheng's test(start) ########################
from django.contrib.auth.decorators import login_required
from juser.models import Document
@login_required(login_url='/login')
def upload(request):
if request.method == 'GET':
machines = [{'name':'aaa'}]
return render_to_response('upload.html', locals(), context_instance=RequestContext(request))
elif request.method == 'POST':
from juser.models import Document
upload_files = request.FILES.getlist('file[]', None)
# form = DocumentForm(request.POST, request.FILES)
# if form.is_valid():
# for upload_file in upload_files:
print request.FILES
for file in upload_files:
print file
newdoc = Document(docfile=file, user_id=request.user.id)
@ -375,5 +376,26 @@ def upload(request):
else:
return HttpResponse("ERROR")
@login_required(login_url='/login')
def download(request):
return render_to_response('download.html', locals(), context_instance=RequestContext(request))
documents = []
for doc in Document.objects.filter(user_id=request.user.id).all():
documents.append('/'.join(str(doc.docfile).split('/')[2:]))
return render_to_response('download.html', locals(), context_instance=RequestContext(request))
def download_file(request, path):
# TODO: get downlode file and make sure it is exist!
# by liuzheng
filepath = 'upload/' + str(request.user.id)+'/'+path
return HttpResponse(filepath)
def node_auth(request):
return HttpResponse('nothing')
def httperror(request):
return HttpResponse('nothing')
def base(request):
return HttpResponse('nothing')
def install(request):
return HttpResponse('nothing')
####################### liuzheng's test(end) ########################

View File

@ -29,6 +29,12 @@
</div>
<div class="ibox-content">
<h2>下载文件可联系管理员在服务器安装lrzsz使用sz命令下载。 </h2>
<div>
{% for document in documents %}
<a href="/download/{{ document }}">{{ document }}</a>
{% endfor %}
</div>
</div>
</div>
</div>