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
9ac80a3f
authored
Apr 12, 2013
by
Bence Dányi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: share editing quota issues fixed
parent
e9a240ed
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
8 deletions
+19
-8
one/models.py
+6
-0
one/views.py
+13
-8
No files found.
one/models.py
View file @
9ac80a3f
...
...
@@ -228,6 +228,9 @@ class Share(models.Model):
return
u"
%(group)
s:
%(tpl)
s
%(owner)
s"
%
{
'group'
:
self
.
group
,
'tpl'
:
self
.
template
,
'owner'
:
self
.
owner
}
def
get_used_quota
(
self
):
return
self
.
template
.
get_credits_per_instance
()
*
self
.
instance_limit
class
Disk
(
models
.
Model
):
"""Virtual disks automatically synchronized with OpenNebula."""
name
=
models
.
CharField
(
max_length
=
100
,
unique
=
True
,
...
...
@@ -381,6 +384,9 @@ class Template(models.Model):
logger
.
info
(
"Could not delete template. Instances still running!"
)
return
False
def
get_credits_per_instance
(
self
):
return
self
.
instance_type
.
credit
class
Instance
(
models
.
Model
):
"""Virtual machine instance."""
name
=
models
.
CharField
(
max_length
=
100
,
...
...
one/views.py
View file @
9ac80a3f
...
...
@@ -228,16 +228,21 @@ class AjaxShareEditWizard(View):
stype
=
request
.
POST
[
'type'
]
if
not
stype
in
TYPES
.
keys
():
raise
PermissionDenied
()
il
=
request
.
POST
[
'instance_limit'
]
if
det
.
get_weighted_share_count
()
+
int
(
il
)
*
share
.
template
.
instance_type
.
credit
>
det
.
share_quota
:
instance_limit
=
int
(
request
.
POST
[
'instance_limit'
])
current_used_share_quota
=
det
.
get_weighted_share_count
()
current_used_share_quota_without_current_share
=
current_used_share_quota
-
share
.
get_used_quota
()
new_quota_for_current_share
=
instance_limit
*
share
.
template
.
get_credits_per_instance
()
new_used_share_quota
=
current_used_share_quota_without_current_share
+
new_quota_for_current_share
allow_stype_modify
=
True
if
new_used_share_quota
<=
det
.
share_quota
else
False
if
not
allow_stype_modify
:
messages
.
error
(
request
,
_
(
'You do not have enough free share quota.'
))
return
redirect
(
'/'
)
share
.
name
=
request
.
POST
[
'name'
]
share
.
description
=
request
.
POST
[
'description'
]
share
.
type
=
stype
share
.
instance_limit
=
il
share
.
per_user_limit
=
request
.
POST
[
'per_user_limit'
]
share
.
owner
=
request
.
user
share
.
name
=
request
.
POST
[
'name'
]
share
.
description
=
request
.
POST
[
'description'
]
share
.
type
=
stype
share
.
instance_limit
=
instance_limit
share
.
per_user_limit
=
request
.
POST
[
'per_user_limit'
]
share
.
owner
=
request
.
user
share
.
save
()
messages
.
success
(
request
,
_
(
'Successfully edited share
%
s.'
)
%
share
)
return
redirect
(
share
.
group
)
...
...
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