Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
CIRCLE
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
94
Merge Requests
10
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
4dbb9645
authored
Jan 31, 2013
by
Dányi Bence
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
store: ajax listfolder view added
parent
e2dbef65
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
cloud/urls.py
+1
-0
store/views.py
+27
-0
No files found.
cloud/urls.py
View file @
4dbb9645
...
...
@@ -27,4 +27,5 @@ urlpatterns = patterns('',
url
(
r'^store/$'
,
'store.views.index'
,
name
=
'store_index'
),
url
(
r'^store/top/$'
,
'store.views.toplist'
,
name
=
'store_top'
),
url
(
r'^ajax/templateWizard$'
,
'one.views.ajax_template_wizard'
,
name
=
'ajax_template_wizard'
),
url
(
r'^ajax/store/list$'
,
'store.views.ajax_listfolder'
,
name
=
'store_ajax_listfolder'
),
)
store/views.py
View file @
4dbb9645
...
...
@@ -5,6 +5,7 @@ from django.template import RequestContext
from
store.api
import
StoreApi
from
django.contrib.auth.decorators
import
login_required
from
django.contrib.auth.models
import
User
from
django.views.decorators.csrf
import
csrf_exempt
import
os
import
json
...
...
@@ -67,6 +68,32 @@ def index(request):
file_list
=
StoreApi
.
listfolder
(
user
,
path
)
return
render_to_response
(
'store/list.html'
,
RequestContext
(
request
,
{
'file_list'
:
file_list
,
'path'
:
path
,
'backpath'
:
backpath
,
'username'
:
user
}))
@csrf_exempt
@login_required
def
ajax_listfolder
(
request
):
user
=
request
.
user
.
username
try
:
details
=
request
.
user
.
userclouddetails_set
.
all
()[
0
]
password
=
details
.
smb_password
key_list
=
[]
for
key
in
request
.
user
.
sshkey_set
.
all
():
key_list
.
append
(
key
.
key
)
except
:
return
HttpResponse
(
'Can not acces to django database!'
,
status_code
=
404
)
if
StoreApi
.
userexist
(
user
)
!=
True
:
#Create user
if
not
StoreApi
.
createuser
(
user
,
password
,
key_list
):
return
HttpResponse
(
'User does not exist on store! And could not create!'
,
status_code
=
404
)
path
=
'/'
try
:
path
=
request
.
POST
[
'path'
]
except
:
pass
#Normalize path (Need double dirname /folder/ -> /folder -> /
backpath
=
os
.
path
.
normpath
(
os
.
path
.
dirname
(
os
.
path
.
dirname
(
path
)))
file_list
=
StoreApi
.
listfolder
(
user
,
path
)
return
HttpResponse
(
json
.
dumps
(
file_list
))
@login_required
def
toplist
(
request
):
user
=
request
.
user
.
username
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment