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
69de0b7a
authored
Feb 11, 2013
by
tarokkk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
webui: Added share peruser quota
parent
9ffe65d1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
4 deletions
+9
-4
one/models.py
+1
-0
one/templates/home.html
+3
-3
one/views.py
+5
-1
No files found.
one/models.py
View file @
69de0b7a
...
...
@@ -169,6 +169,7 @@ class Share(models.Model):
per_user_limit
=
models
.
IntegerField
(
verbose_name
=
_
(
'per user limit'
),
help_text
=
_
(
'Maximal count of instances launchable by a single user.'
))
def
get_running_or_stopped
(
self
):
return
Instance
.
objects
.
all
()
.
exclude
(
state
=
'DONE'
)
.
filter
(
share
=
self
)
.
count
()
def
get_running
(
self
):
...
...
one/templates/home.html
View file @
69de0b7a
...
...
@@ -27,9 +27,9 @@
<li
class=
"wm"
>
<div
class=
"summary"
>
<div
class=
"quota"
>
<div
class=
"used"
style=
"width:
{{ s.get_instance_pc|unlocalize }}%"
></div>
<div
class=
"used"
style=
"width:
{% if s.running_shared >= s.per_user_limit %}100%{% else %}{{ s.get_instance_pc|unlocalize }}%{% endif %}"
/
></div>
</div>
<div
class=
"name wm-on"
>
{{s.name}}
</div>
<div
class=
"name wm-on"
>
{{s.name}}
- {{ s.group.name }} ({{ s.running_shared }}/{{ s.per_user_limit }})
</div>
<div
class=
"status"
>
{{s.get_running}}/{{s.instance_limit}}
</div>
...
...
@@ -49,7 +49,7 @@
<span
class=
"value"
>
<form
method=
"POST"
action=
"/vm/new/s{{s.pk}}/"
>
{% csrf_token %}
<input
type=
"submit"
value=
"{% trans "
Launch
"
%}"
/>
<input
{%
if
s
.
running_shared
>
= s.per_user_limit or s.get_running >= s.instance_limit%}disabled{% endif %}
type="submit" value="{% trans "Launch" %}"/>
</form>
</span>
<div
class=
"clear"
></div>
...
...
one/views.py
View file @
69de0b7a
...
...
@@ -73,8 +73,12 @@ def _list_instances(request):
@require_GET
@login_required
def
home
(
request
):
shares
=
[
s
for
s
in
request
.
user
.
person_set
.
all
()[
0
]
.
get_shares
()]
for
i
,
s
in
enumerate
(
shares
):
s
.
running_shared
=
s
.
instance_set
.
all
()
.
exclude
(
state
=
"DONE"
)
.
filter
(
owner
=
request
.
user
)
.
count
()
shares
[
i
]
=
s
return
render_to_response
(
"home.html"
,
RequestContext
(
request
,
{
'shares'
:
request
.
user
.
person_set
.
all
()[
0
]
.
get_shares
()
,
'shares'
:
shares
,
'templates'
:
Template
.
objects
.
filter
(
state
=
'READY'
),
'mytemplates'
:
Template
.
objects
.
filter
(
owner
=
request
.
user
),
'publictemplates'
:
Template
.
objects
.
filter
(
public
=
True
,
state
=
'READY'
),
...
...
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