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
28fc85f7
authored
Jul 23, 2014
by
Kálmán Viktor
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: allow no store
Closes
#219
parent
79703087
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
48 additions
and
26 deletions
+48
-26
circle/circle/settings/base.py
+4
-4
circle/dashboard/store_api.py
+6
-0
circle/dashboard/templates/dashboard/index.html
+2
-0
circle/dashboard/views.py
+36
-22
No files found.
circle/circle/settings/base.py
View file @
28fc85f7
...
@@ -446,14 +446,14 @@ if graphite_host and graphite_port:
...
@@ -446,14 +446,14 @@ if graphite_host and graphite_port:
else
:
else
:
GRAPHITE_URL
=
None
GRAPHITE_URL
=
None
STORE_BASIC_AUTH
=
get_env_variable
(
"STORE_BASIC_AUTH"
)
==
"True"
STORE_BASIC_AUTH
=
get_env_variable
(
"STORE_BASIC_AUTH"
,
""
)
==
"True"
STORE_VERIFY_SSL
=
get_env_variable
(
"STORE_VERIFY_SSL"
)
==
"True"
STORE_VERIFY_SSL
=
get_env_variable
(
"STORE_VERIFY_SSL"
,
""
)
==
"True"
STORE_SSL_AUTH
=
get_env_variable
(
"STORE_SSL_AUTH"
)
==
"True"
STORE_SSL_AUTH
=
get_env_variable
(
"STORE_SSL_AUTH"
,
""
)
==
"True"
STORE_CLIENT_USER
=
get_env_variable
(
"STORE_CLIENT_USER"
,
""
)
STORE_CLIENT_USER
=
get_env_variable
(
"STORE_CLIENT_USER"
,
""
)
STORE_CLIENT_PASSWORD
=
get_env_variable
(
"STORE_CLIENT_PASSWORD"
,
""
)
STORE_CLIENT_PASSWORD
=
get_env_variable
(
"STORE_CLIENT_PASSWORD"
,
""
)
STORE_CLIENT_KEY
=
get_env_variable
(
"STORE_CLIENT_KEY"
,
""
)
STORE_CLIENT_KEY
=
get_env_variable
(
"STORE_CLIENT_KEY"
,
""
)
STORE_CLIENT_CERT
=
get_env_variable
(
"STORE_CLIENT_CERT"
,
""
)
STORE_CLIENT_CERT
=
get_env_variable
(
"STORE_CLIENT_CERT"
,
""
)
STORE_URL
=
get_env_variable
(
"STORE_URL"
)
STORE_URL
=
get_env_variable
(
"STORE_URL"
,
""
)
SESSION_COOKIE_NAME
=
"csessid
%
x"
%
(((
getnode
()
//
139
)
^
SESSION_COOKIE_NAME
=
"csessid
%
x"
%
(((
getnode
()
//
139
)
^
(
getnode
()
%
983
))
&
0xffff
)
(
getnode
()
%
983
))
&
0xffff
)
circle/dashboard/store_api.py
View file @
28fc85f7
...
@@ -22,6 +22,10 @@ class NotOkException(StoreApiException):
...
@@ -22,6 +22,10 @@ class NotOkException(StoreApiException):
super
(
NotOkException
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
NotOkException
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
class
NoStoreException
(
StoreApiException
):
pass
class
Store
(
object
):
class
Store
(
object
):
def
__init__
(
self
,
user
,
default_timeout
=
0.5
):
def
__init__
(
self
,
user
,
default_timeout
=
0.5
):
...
@@ -35,6 +39,8 @@ class Store(object):
...
@@ -35,6 +39,8 @@ class Store(object):
self
.
username
=
"u-
%
d"
%
user
.
pk
self
.
username
=
"u-
%
d"
%
user
.
pk
self
.
default_timeout
=
default_timeout
self
.
default_timeout
=
default_timeout
self
.
store_url
=
settings
.
STORE_URL
self
.
store_url
=
settings
.
STORE_URL
if
not
self
.
store_url
:
raise
NoStoreException
def
_request
(
self
,
url
,
method
=
get
,
timeout
=
None
,
def
_request
(
self
,
url
,
method
=
get
,
timeout
=
None
,
raise_status_code
=
True
,
**
kwargs
):
raise_status_code
=
True
,
**
kwargs
):
...
...
circle/dashboard/templates/dashboard/index.html
View file @
28fc85f7
...
@@ -23,9 +23,11 @@
...
@@ -23,9 +23,11 @@
</div>
</div>
{% endif %}
{% endif %}
{% if not no_store %}
<div
class=
"col-lg-4 col-sm-6"
>
<div
class=
"col-lg-4 col-sm-6"
>
{% include "dashboard/store/index-files.html" %}
{% include "dashboard/store/index-files.html" %}
</div>
</div>
{% endif %}
{% if perms.vm.create_template %}
{% if perms.vm.create_template %}
<div
class=
"col-lg-4 col-sm-6"
>
<div
class=
"col-lg-4 col-sm-6"
>
...
...
circle/dashboard/views.py
View file @
28fc85f7
...
@@ -84,7 +84,7 @@ from storage.models import Disk
...
@@ -84,7 +84,7 @@ from storage.models import Disk
from
firewall.models
import
Vlan
,
Host
,
Rule
from
firewall.models
import
Vlan
,
Host
,
Rule
from
.models
import
Favourite
,
Profile
,
GroupProfile
,
FutureMember
from
.models
import
Favourite
,
Profile
,
GroupProfile
,
FutureMember
from
.store_api
import
Store
,
No
tOk
Exception
from
.store_api
import
Store
,
No
Store
Exception
logger
=
logging
.
getLogger
(
__name__
)
logger
=
logging
.
getLogger
(
__name__
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
...
@@ -226,19 +226,22 @@ class IndexView(LoginRequiredMixin, TemplateView):
...
@@ -226,19 +226,22 @@ class IndexView(LoginRequiredMixin, TemplateView):
'operator'
,
user
)
.
all
()[:
5
]
'operator'
,
user
)
.
all
()[:
5
]
# toplist
# toplist
cache_key
=
"toplist-
%
d"
%
self
.
request
.
user
.
pk
if
settings
.
STORE_URL
:
cache
=
get_cache
(
"default"
)
cache_key
=
"toplist-
%
d"
%
self
.
request
.
user
.
pk
toplist
=
cache
.
get
(
cache_key
)
cache
=
get_cache
(
"default"
)
if
not
toplist
:
toplist
=
cache
.
get
(
cache_key
)
try
:
if
not
toplist
:
toplist
=
Store
(
self
.
request
.
user
)
.
toplist
()
try
:
except
Exception
:
toplist
=
Store
(
self
.
request
.
user
)
.
toplist
()
logger
.
exception
(
"Unable to get tolist for
%
s"
,
except
Exception
:
unicode
(
self
.
request
.
user
))
logger
.
exception
(
"Unable to get tolist for
%
s"
,
toplist
=
[]
unicode
(
self
.
request
.
user
))
cache
.
set
(
cache_key
,
toplist
,
300
)
toplist
=
[]
cache
.
set
(
cache_key
,
toplist
,
300
)
context
[
'toplist'
]
=
toplist
context
[
'toplist'
]
=
toplist
else
:
context
[
'no_store'
]
=
True
return
context
return
context
...
@@ -3103,14 +3106,18 @@ class StoreList(LoginRequiredMixin, TemplateView):
...
@@ -3103,14 +3106,18 @@ class StoreList(LoginRequiredMixin, TemplateView):
return
context
return
context
def
get
(
self
,
*
args
,
**
kwargs
):
def
get
(
self
,
*
args
,
**
kwargs
):
if
self
.
request
.
is_ajax
():
try
:
context
=
self
.
get_context_data
(
**
kwargs
)
if
self
.
request
.
is_ajax
():
return
render_to_response
(
context
=
self
.
get_context_data
(
**
kwargs
)
"dashboard/store/_list-box.html"
,
return
render_to_response
(
RequestContext
(
self
.
request
,
context
),
"dashboard/store/_list-box.html"
,
)
RequestContext
(
self
.
request
,
context
),
else
:
)
return
super
(
StoreList
,
self
)
.
get
(
*
args
,
**
kwargs
)
else
:
return
super
(
StoreList
,
self
)
.
get
(
*
args
,
**
kwargs
)
except
NoStoreException
:
messages
.
warning
(
self
.
request
,
_
(
"No store."
))
return
redirect
(
"/"
)
def
create_up_directory
(
self
,
directory
):
def
create_up_directory
(
self
,
directory
):
return
normpath
(
join
(
'/'
,
directory
,
'..'
))
return
normpath
(
join
(
'/'
,
directory
,
'..'
))
...
@@ -3122,7 +3129,7 @@ def store_download(request):
...
@@ -3122,7 +3129,7 @@ def store_download(request):
path
=
request
.
GET
.
get
(
"path"
)
path
=
request
.
GET
.
get
(
"path"
)
try
:
try
:
url
=
Store
(
request
.
user
)
.
request_download
(
path
)
url
=
Store
(
request
.
user
)
.
request_download
(
path
)
except
NotOk
Exception
:
except
Exception
:
messages
.
error
(
request
,
_
(
"Something went wrong during download."
))
messages
.
error
(
request
,
_
(
"Something went wrong during download."
))
logger
.
exception
(
"Unable to download, "
logger
.
exception
(
"Unable to download, "
"maybe it is already deleted"
)
"maybe it is already deleted"
)
...
@@ -3183,6 +3190,12 @@ class StoreRemove(LoginRequiredMixin, TemplateView):
...
@@ -3183,6 +3190,12 @@ class StoreRemove(LoginRequiredMixin, TemplateView):
return
context
return
context
def
get
(
self
,
*
args
,
**
kwargs
):
try
:
return
super
(
StoreRemove
,
self
)
.
get
(
*
args
,
**
kwargs
)
except
NoStoreException
:
return
redirect
(
"/"
)
def
post
(
self
,
*
args
,
**
kwargs
):
def
post
(
self
,
*
args
,
**
kwargs
):
path
=
self
.
request
.
POST
.
get
(
"path"
)
path
=
self
.
request
.
POST
.
get
(
"path"
)
try
:
try
:
...
@@ -3209,6 +3222,7 @@ def store_new_directory(request):
...
@@ -3209,6 +3222,7 @@ def store_new_directory(request):
logger
.
exception
(
"Unable to create folder
%
s in
%
s for
%
s"
,
logger
.
exception
(
"Unable to create folder
%
s in
%
s for
%
s"
,
name
,
path
,
unicode
(
request
.
user
))
name
,
path
,
unicode
(
request
.
user
))
messages
.
error
(
request
,
_
(
"Unable to create folder."
))
messages
.
error
(
request
,
_
(
"Unable to create folder."
))
return
redirect
(
"/"
)
return
redirect
(
"
%
s?directory=
%
s"
%
(
return
redirect
(
"
%
s?directory=
%
s"
%
(
reverse
(
"dashboard.views.store-list"
),
path
))
reverse
(
"dashboard.views.store-list"
),
path
))
...
...
Kálmán Viktor
@kviktor
mentioned in issue
#219 (closed)
Jul 26, 2014
mentioned in issue
#219 (closed)
mentioned in issue #219
Toggle commit list
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