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
4ffb3b84
authored
Feb 10, 2013
by
Őry Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: print personal quota info
parent
caf0bdcf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
3 deletions
+13
-3
one/models.py
+9
-0
one/templates/home.html
+2
-2
one/views.py
+2
-1
No files found.
one/models.py
View file @
4ffb3b84
...
@@ -68,6 +68,15 @@ class UserCloudDetails(models.Model):
...
@@ -68,6 +68,15 @@ class UserCloudDetails(models.Model):
def
reset_smb
(
self
):
def
reset_smb
(
self
):
self
.
smb_password
=
pwgen
()
self
.
smb_password
=
pwgen
()
def
get_weighted_instance_count
(
self
):
c
=
0
for
i
in
self
.
user
.
instance_set
.
all
():
if
i
.
state
in
(
'ACTIVE'
,
'PENDING'
,
):
c
=
c
+
i
.
template
.
instance_type
.
credit
return
c
def
get_instance_pc
(
self
):
return
100
*
self
.
get_weighted_instance_count
()
/
self
.
instance_quota
def
set_quota
(
sender
,
instance
,
created
,
**
kwargs
):
def
set_quota
(
sender
,
instance
,
created
,
**
kwargs
):
if
not
StoreApi
.
userexist
(
instance
.
user
.
username
):
if
not
StoreApi
.
userexist
(
instance
.
user
.
username
):
try
:
try
:
...
...
one/templates/home.html
View file @
4ffb3b84
...
@@ -63,9 +63,9 @@
...
@@ -63,9 +63,9 @@
<li
class=
"wm small"
>
<li
class=
"wm small"
>
<div
class=
"summary"
>
<div
class=
"summary"
>
<div
class=
"quota"
>
<div
class=
"quota"
>
<div
class=
"used"
style=
"background-color: rgba(0,255,0,0.2); width:
30
%"
></div>
<div
class=
"used"
style=
"background-color: rgba(0,255,0,0.2); width:
{{userdetails.get_instance_pc}}
%"
></div>
</div>
</div>
<div
class=
"name"
>
{% blocktrans with used=
3 all=10
%}Personal quota: {{used}}/{{all}}{% endblocktrans %}
</div>
<div
class=
"name"
>
{% blocktrans with used=
userdetails.get_weighted_instance_count all=userdetails.instance_quota
%}Personal quota: {{used}}/{{all}}{% endblocktrans %}
</div>
<div
class=
"clear"
></div>
<div
class=
"clear"
></div>
</div>
</div>
</li>
</li>
...
...
one/views.py
View file @
4ffb3b84
...
@@ -77,7 +77,8 @@ def home(request):
...
@@ -77,7 +77,8 @@ def home(request):
'mytemplates'
:
Template
.
objects
.
filter
(
owner
=
request
.
user
),
'mytemplates'
:
Template
.
objects
.
filter
(
owner
=
request
.
user
),
'instances'
:
_list_instances
(
request
),
'instances'
:
_list_instances
(
request
),
'groups'
:
request
.
user
.
person_set
.
all
()[
0
]
.
owned_groups
.
all
(),
'groups'
:
request
.
user
.
person_set
.
all
()[
0
]
.
owned_groups
.
all
(),
'semesters'
:
Semester
.
objects
.
all
()
'semesters'
:
Semester
.
objects
.
all
(),
'userdetails'
:
UserCloudDetails
.
objects
.
get
(
user
=
request
.
user
),
}))
}))
def
ajax_template_name_unique
(
request
,
name
):
def
ajax_template_name_unique
(
request
,
name
):
...
...
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