Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Gelencsér Szabolcs
/
cloud
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
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
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboard: allow no store
Closes #219
parent
79703087
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
6 deletions
+28
-6
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
+16
-2
No files found.
circle/circle/settings/base.py
View file @
28fc85f7
...
...
@@ -446,14 +446,14 @@ if graphite_host and graphite_port:
else
:
GRAPHITE_URL
=
None
STORE_BASIC_AUTH
=
get_env_variable
(
"STORE_BASIC_AUTH"
)
==
"True"
STORE_VERIFY_SSL
=
get_env_variable
(
"STORE_VERIFY_SSL"
)
==
"True"
STORE_SSL_AUTH
=
get_env_variable
(
"STORE_SSL_AUTH"
)
==
"True"
STORE_BASIC_AUTH
=
get_env_variable
(
"STORE_BASIC_AUTH"
,
""
)
==
"True"
STORE_VERIFY_SSL
=
get_env_variable
(
"STORE_VERIFY_SSL"
,
""
)
==
"True"
STORE_SSL_AUTH
=
get_env_variable
(
"STORE_SSL_AUTH"
,
""
)
==
"True"
STORE_CLIENT_USER
=
get_env_variable
(
"STORE_CLIENT_USER"
,
""
)
STORE_CLIENT_PASSWORD
=
get_env_variable
(
"STORE_CLIENT_PASSWORD"
,
""
)
STORE_CLIENT_KEY
=
get_env_variable
(
"STORE_CLIENT_KEY"
,
""
)
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
)
^
(
getnode
()
%
983
))
&
0xffff
)
circle/dashboard/store_api.py
View file @
28fc85f7
...
...
@@ -22,6 +22,10 @@ class NotOkException(StoreApiException):
super
(
NotOkException
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
class
NoStoreException
(
StoreApiException
):
pass
class
Store
(
object
):
def
__init__
(
self
,
user
,
default_timeout
=
0.5
):
...
...
@@ -35,6 +39,8 @@ class Store(object):
self
.
username
=
"u-
%
d"
%
user
.
pk
self
.
default_timeout
=
default_timeout
self
.
store_url
=
settings
.
STORE_URL
if
not
self
.
store_url
:
raise
NoStoreException
def
_request
(
self
,
url
,
method
=
get
,
timeout
=
None
,
raise_status_code
=
True
,
**
kwargs
):
...
...
circle/dashboard/templates/dashboard/index.html
View file @
28fc85f7
...
...
@@ -23,9 +23,11 @@
</div>
{% endif %}
{% if not no_store %}
<div
class=
"col-lg-4 col-sm-6"
>
{% include "dashboard/store/index-files.html" %}
</div>
{% endif %}
{% if perms.vm.create_template %}
<div
class=
"col-lg-4 col-sm-6"
>
...
...
circle/dashboard/views.py
View file @
28fc85f7
...
...
@@ -84,7 +84,7 @@ from storage.models import Disk
from
firewall.models
import
Vlan
,
Host
,
Rule
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__
)
saml_available
=
hasattr
(
settings
,
"SAML_CONFIG"
)
...
...
@@ -226,6 +226,7 @@ class IndexView(LoginRequiredMixin, TemplateView):
'operator'
,
user
)
.
all
()[:
5
]
# toplist
if
settings
.
STORE_URL
:
cache_key
=
"toplist-
%
d"
%
self
.
request
.
user
.
pk
cache
=
get_cache
(
"default"
)
toplist
=
cache
.
get
(
cache_key
)
...
...
@@ -239,6 +240,8 @@ class IndexView(LoginRequiredMixin, TemplateView):
cache
.
set
(
cache_key
,
toplist
,
300
)
context
[
'toplist'
]
=
toplist
else
:
context
[
'no_store'
]
=
True
return
context
...
...
@@ -3103,6 +3106,7 @@ class StoreList(LoginRequiredMixin, TemplateView):
return
context
def
get
(
self
,
*
args
,
**
kwargs
):
try
:
if
self
.
request
.
is_ajax
():
context
=
self
.
get_context_data
(
**
kwargs
)
return
render_to_response
(
...
...
@@ -3111,6 +3115,9 @@ class StoreList(LoginRequiredMixin, TemplateView):
)
else
:
return
super
(
StoreList
,
self
)
.
get
(
*
args
,
**
kwargs
)
except
NoStoreException
:
messages
.
warning
(
self
.
request
,
_
(
"No store."
))
return
redirect
(
"/"
)
def
create_up_directory
(
self
,
directory
):
return
normpath
(
join
(
'/'
,
directory
,
'..'
))
...
...
@@ -3122,7 +3129,7 @@ def store_download(request):
path
=
request
.
GET
.
get
(
"path"
)
try
:
url
=
Store
(
request
.
user
)
.
request_download
(
path
)
except
NotOk
Exception
:
except
Exception
:
messages
.
error
(
request
,
_
(
"Something went wrong during download."
))
logger
.
exception
(
"Unable to download, "
"maybe it is already deleted"
)
...
...
@@ -3183,6 +3190,12 @@ class StoreRemove(LoginRequiredMixin, TemplateView):
return
context
def
get
(
self
,
*
args
,
**
kwargs
):
try
:
return
super
(
StoreRemove
,
self
)
.
get
(
*
args
,
**
kwargs
)
except
NoStoreException
:
return
redirect
(
"/"
)
def
post
(
self
,
*
args
,
**
kwargs
):
path
=
self
.
request
.
POST
.
get
(
"path"
)
try
:
...
...
@@ -3209,6 +3222,7 @@ def store_new_directory(request):
logger
.
exception
(
"Unable to create folder
%
s in
%
s for
%
s"
,
name
,
path
,
unicode
(
request
.
user
))
messages
.
error
(
request
,
_
(
"Unable to create folder."
))
return
redirect
(
"/"
)
return
redirect
(
"
%
s?directory=
%
s"
%
(
reverse
(
"dashboard.views.store-list"
),
path
))
...
...
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