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
ce83ea42
authored
Feb 04, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Labor GUI login initial commit.
parent
c0e5d189
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
105 additions
and
37 deletions
+105
-37
cloud/urls.py
+1
-0
store/static/store/gui.js
+39
-0
store/templates/store/gui.html
+23
-0
store/views.py
+42
-37
No files found.
cloud/urls.py
View file @
ce83ea42
...
...
@@ -25,6 +25,7 @@ urlpatterns = patterns('',
url
(
r'^reload/$'
,
'firewall.views.reload_firewall'
,
name
=
'reload_firewall'
),
url
(
r'^fwapi/$'
,
'firewall.views.firewall_api'
,
name
=
'firewall_api'
),
url
(
r'^store/$'
,
'store.views.index'
,
name
=
'store_index'
),
url
(
r'^store/gui/$'
,
'store.views.gui'
,
name
=
'store_gui'
),
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/static/store/gui.js
0 → 100644
View file @
ce83ea42
// using jQuery
function
getCookie
(
name
)
{
var
cookieValue
=
null
;
if
(
document
.
cookie
&&
document
.
cookie
!=
''
)
{
var
cookies
=
document
.
cookie
.
split
(
';'
);
for
(
var
i
=
0
;
i
<
cookies
.
length
;
i
++
)
{
var
cookie
=
jQuery
.
trim
(
cookies
[
i
]);
// Does this cookie string begin with the name we want?
if
(
cookie
.
substring
(
0
,
name
.
length
+
1
)
==
(
name
+
'='
))
{
cookieValue
=
decodeURIComponent
(
cookie
.
substring
(
name
.
length
+
1
));
break
;
}
}
}
return
cookieValue
;
}
var
csrftoken
=
getCookie
(
'csrftoken'
);
function
postKey
(
key
)
{
$
.
post
(
"/store/gui/"
,
{
"KEY"
:
key
},
function
(
respond
)
{
alert
(
respond
);
}
);
}
function
resetKey
()
{
$
.
post
(
"/store/gui/"
,
""
,
function
(
respond
)
{
alert
(
respond
);
}
);
}
$
.
ajaxSetup
({
crossDomain
:
false
,
// obviates need for sameOrigin test
beforeSend
:
function
(
xhr
,
settings
)
{
xhr
.
setRequestHeader
(
"X-CSRFToken"
,
csrftoken
);
}
});
store/templates/store/gui.html
0 → 100644
View file @
ce83ea42
<!DOCTYPE html>
<html>
<head>
<title>
Store Gui
</title>
<script
src=
"/static/jquery.min.js"
></script>
<script
type=
"text/javascript"
src=
"/static/store/gui.js"
></script>
</head>
<body>
EZ LESZ A GUI JOL!
<form
action=
"login:{{ username }}:{{ host }}"
>
<input
type=
submit
name=
"login_button"
id=
"login_button"
value=
"login"
/>
</form>
<form
action=
"mount:true"
>
<input
type=
submit
name=
"mount_button"
id=
"mount_button"
value=
"mount"
hidden=
"true"
/>
</form>
<form
action=
"umount:true"
>
<input
type=
submit
name=
"umount_button"
id=
"umount_button"
value=
"umount"
hidden=
"true"
/>
</form>
<form
action=
"logout:{{ username }}:{{ host }}"
>
<input
type=
submit
name=
"logout_button"
id=
"logout_button"
value=
"logout"
hidden=
"true"
/>
</form>
</body>
</html>
store/views.py
View file @
ce83ea42
...
...
@@ -8,10 +8,9 @@ from django.contrib.auth.models import User
from
django.views.decorators.csrf
import
csrf_exempt
import
os
import
json
import
base64
@login_required
def
index
(
request
):
user
=
request
.
user
.
username
def
estabilish_store_user
(
user
):
try
:
details
=
request
.
user
.
userclouddetails_set
.
all
()[
0
]
password
=
details
.
smb_password
...
...
@@ -20,13 +19,26 @@ def index(request):
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!'
)
@login_required
def
index
(
request
):
user
=
request
.
user
.
username
if
StoreApi
.
userexist
(
user
)
!=
True
:
estabilish_store_user
(
user
)
#UpdateAuthorizationInfo
try
:
auth
=
request
.
POST
[
'auth'
]
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
not
StoreApi
.
updateauthorizationinfo
(
user
,
password
,
key_list
):
return
HttpResponse
(
'Can not update authorization information!'
)
except
:
...
...
@@ -71,18 +83,8 @@ def index(request):
@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
)
estabilish_store_user
(
user
)
path
=
'/'
try
:
path
=
request
.
POST
[
'path'
]
...
...
@@ -97,17 +99,6 @@ def ajax_listfolder(request):
def
ajax_download
(
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
:
if
not
StoreApi
.
createuser
(
user
,
password
,
key_list
):
return
HttpResponse
(
'User does not exist on store! And could not create!'
,
status_code
=
404
)
try
:
dl
=
request
.
POST
[
'dl'
]
return
HttpResponse
(
json
.
dumps
({
'url'
:
StoreApi
.
requestdownload
(
user
,
dl
)}))
except
:
...
...
@@ -118,17 +109,6 @@ def ajax_download(request):
def
ajax_delete
(
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
:
if
not
StoreApi
.
createuser
(
user
,
password
,
key_list
):
return
HttpResponse
(
'User does not exist on store! And could not create!'
,
status_code
=
404
)
try
:
rm
=
request
.
POST
[
'rm'
]
return
HttpResponse
(
json
.
dumps
({
'success'
:
StoreApi
.
requestremove
(
user
,
rm
)}))
except
:
...
...
@@ -142,6 +122,31 @@ def toplist(request):
file_list
=
StoreApi
.
toplist
(
user
)
return
render_to_response
(
'store/list.html'
,
RequestContext
(
request
,
{
'file_list'
:
file_list
,
'path'
:
path
,
'backpath'
:
backpath
,
'username'
:
user
}))
def
gui
(
request
):
user
=
request
.
user
.
username
if
request
.
method
==
'GET'
:
return
render_to_response
(
'store/gui.html'
,
RequestContext
(
request
,
{
'username'
:
user
,
'host'
:
'10.9.1.86'
}))
elif
request
.
method
==
'POST'
:
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
)
try
:
lab_key_decoded
=
base64
.
b64decode
(
request
.
POST
[
'KEY'
])
key_list
.
append
(
lab_key_decoded
)
except
:
pass
if
not
StoreApi
.
updateauthorizationinfo
(
user
,
password
,
key_list
):
return
HttpResponse
(
'Can not update authorization information!'
)
else
:
return
HttpResponse
(
'Updated key information!'
)
else
:
return
HttpResponse
(
'Method not found!'
,
status_code
=
404
)
def
logout
(
request
):
auth
.
logout
(
request
)
return
redirect
(
'/'
)
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