Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Fukász Rómeó Ervin
/
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
0c78be67
authored
Jul 07, 2013
by
Dudás Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
one: code beautification
parent
64faefe2
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
9 deletions
+10
-9
one/models.py
+6
-6
one/tests/test_models.py
+3
-3
one/tests/test_views.py
+1
-0
No files found.
one/models.py
View file @
0c78be67
...
@@ -96,8 +96,8 @@ class UserCloudDetails(models.Model):
...
@@ -96,8 +96,8 @@ class UserCloudDetails(models.Model):
return
100
*
self
.
get_weighted_instance_count
()
/
inst_quota
return
100
*
self
.
get_weighted_instance_count
()
/
inst_quota
def
get_weighted_share_count
(
self
):
def
get_weighted_share_count
(
self
):
credits
=
[
i
.
template
.
instance_type
.
credit
*
i
.
instance_limit
credits
=
[
s
.
template
.
instance_type
.
credit
*
s
.
instance_limit
for
i
in
Share
.
objects
.
filter
(
owner
=
self
.
user
)]
for
s
in
Share
.
objects
.
filter
(
owner
=
self
.
user
)]
return
sum
(
credits
)
return
sum
(
credits
)
def
get_share_pc
(
self
):
def
get_share_pc
(
self
):
...
@@ -214,10 +214,10 @@ class Share(models.Model):
...
@@ -214,10 +214,10 @@ class Share(models.Model):
'for this share.'
))
'for this share.'
))
per_user_limit
=
models
.
IntegerField
(
verbose_name
=
_
(
'per user limit'
),
per_user_limit
=
models
.
IntegerField
(
verbose_name
=
_
(
'per user limit'
),
help_text
=
_
(
'Maximal count of '
help_text
=
_
(
'Maximal count of '
'instances launchable
by
'
'instances launchable '
'a single user.'
))
'
by
a single user.'
))
owner
=
models
.
ForeignKey
(
owner
=
models
.
ForeignKey
(
User
,
null
=
True
,
blank
=
True
,
User
,
null
=
True
,
blank
=
True
,
related_name
=
'share_set'
)
related_name
=
'share_set'
)
class
Meta
:
class
Meta
:
ordering
=
[
'group'
,
'template'
,
'owner'
,
]
ordering
=
[
'group'
,
'template'
,
'owner'
,
]
...
...
one/tests/test_models.py
View file @
0c78be67
from
datetime
import
datetime
,
timedelta
from
datetime
import
datetime
,
timedelta
from
django.test
import
TestCase
from
django.test
import
TestCase
from
django.contrib.auth.models
import
User
from
django.contrib.auth.models
import
User
from
..models
import
(
Disk
,
Instance
,
InstanceType
,
Network
,
Share
,
from
..models
import
Disk
,
Instance
,
InstanceType
,
Network
,
Share
,
Template
Template
,
UserCloudDetails
)
from
school.models
import
Course
,
Group
,
Semester
from
school.models
import
Course
,
Group
,
Semester
...
@@ -37,7 +36,8 @@ class UserCloudDetailsTestCase(TestCase):
...
@@ -37,7 +36,8 @@ class UserCloudDetailsTestCase(TestCase):
course
=
course1
)
course
=
course1
)
self
.
share1
=
Share
.
objects
.
create
(
name
=
"testshare1"
,
group
=
grp1
,
self
.
share1
=
Share
.
objects
.
create
(
name
=
"testshare1"
,
group
=
grp1
,
template
=
tmplt1
,
owner
=
user
,
template
=
tmplt1
,
owner
=
user
,
instance_limit
=
2
,
per_user_limit
=
1
)
instance_limit
=
2
,
per_user_limit
=
1
)
def
test_reset_keys
(
self
):
def
test_reset_keys
(
self
):
private_key
=
self
.
userdetails
.
ssh_private_key
private_key
=
self
.
userdetails
.
ssh_private_key
...
...
one/tests/test_views.py
View file @
0c78be67
from
django.core.urlresolvers
import
reverse
from
django.core.urlresolvers
import
reverse
from
django.test
import
TestCase
from
django.test
import
TestCase
class
ViewsTestCase
(
TestCase
):
class
ViewsTestCase
(
TestCase
):
def
test_index
(
self
):
def
test_index
(
self
):
'''Test whether index is reachable.'''
'''Test whether index is reachable.'''
...
...
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