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
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
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
10 deletions
+11
-10
one/models.py
+6
-6
one/tests/test_models.py
+4
-4
one/tests/test_views.py
+1
-0
No files found.
one/models.py
View file @
0c78be67
...
...
@@ -96,8 +96,8 @@ class UserCloudDetails(models.Model):
return
100
*
self
.
get_weighted_instance_count
()
/
inst_quota
def
get_weighted_share_count
(
self
):
credits
=
[
i
.
template
.
instance_type
.
credit
*
i
.
instance_limit
for
i
in
Share
.
objects
.
filter
(
owner
=
self
.
user
)]
credits
=
[
s
.
template
.
instance_type
.
credit
*
s
.
instance_limit
for
s
in
Share
.
objects
.
filter
(
owner
=
self
.
user
)]
return
sum
(
credits
)
def
get_share_pc
(
self
):
...
...
@@ -214,10 +214,10 @@ class Share(models.Model):
'for this share.'
))
per_user_limit
=
models
.
IntegerField
(
verbose_name
=
_
(
'per user limit'
),
help_text
=
_
(
'Maximal count of '
'instances launchable
by
'
'a single user.'
))
owner
=
models
.
ForeignKey
(
User
,
null
=
True
,
blank
=
True
,
related_name
=
'share_set'
)
'instances launchable '
'
by
a single user.'
))
owner
=
models
.
ForeignKey
(
User
,
null
=
True
,
blank
=
True
,
related_name
=
'share_set'
)
class
Meta
:
ordering
=
[
'group'
,
'template'
,
'owner'
,
]
...
...
one/tests/test_models.py
View file @
0c78be67
from
datetime
import
datetime
,
timedelta
from
django.test
import
TestCase
from
django.contrib.auth.models
import
User
from
..models
import
(
Disk
,
Instance
,
InstanceType
,
Network
,
Share
,
Template
,
UserCloudDetails
)
from
..models
import
Disk
,
Instance
,
InstanceType
,
Network
,
Share
,
Template
from
school.models
import
Course
,
Group
,
Semester
...
...
@@ -36,8 +35,9 @@ class UserCloudDetailsTestCase(TestCase):
grp1
=
Group
.
objects
.
create
(
name
=
"testgroup1"
,
semester
=
sem
,
course
=
course1
)
self
.
share1
=
Share
.
objects
.
create
(
name
=
"testshare1"
,
group
=
grp1
,
template
=
tmplt1
,
owner
=
user
,
instance_limit
=
2
,
per_user_limit
=
1
)
template
=
tmplt1
,
owner
=
user
,
instance_limit
=
2
,
per_user_limit
=
1
)
def
test_reset_keys
(
self
):
private_key
=
self
.
userdetails
.
ssh_private_key
...
...
one/tests/test_views.py
View file @
0c78be67
from
django.core.urlresolvers
import
reverse
from
django.test
import
TestCase
class
ViewsTestCase
(
TestCase
):
def
test_index
(
self
):
'''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