Commit 0c78be67 by Dudás Ádám

one: code beautification

parent 64faefe2
......@@ -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', ]
......
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
......
from django.core.urlresolvers import reverse
from django.test import TestCase
class ViewsTestCase(TestCase):
def test_index(self):
'''Test whether index is reachable.'''
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment