diff --git a/accounts/migrations/0004_userattributes.py b/accounts/migrations/0004_userattributes.py new file mode 100644 index 0000000..fb32539 --- /dev/null +++ b/accounts/migrations/0004_userattributes.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +from django.conf import settings + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('accounts', '0003_usersshkey'), + ] + + operations = [ + migrations.CreateModel( + name='UserAttributes', + fields=[ + ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), + ('max_instances', models.IntegerField(default=0)), + ('max_cpus', models.IntegerField(default=0)), + ('max_memory', models.IntegerField(default=0)), + ('user', models.OneToOneField(to=settings.AUTH_USER_MODEL)), + ], + ), + ] diff --git a/accounts/migrations/0005_userattributes_can_clone_instances.py b/accounts/migrations/0005_userattributes_can_clone_instances.py new file mode 100644 index 0000000..4539657 --- /dev/null +++ b/accounts/migrations/0005_userattributes_can_clone_instances.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('accounts', '0004_userattributes'), + ] + + operations = [ + migrations.AddField( + model_name='userattributes', + name='can_clone_instances', + field=models.BooleanField(default=False), + ), + ] diff --git a/accounts/models.py b/accounts/models.py index 15cedee..16f5f6e 100644 --- a/accounts/models.py +++ b/accounts/models.py @@ -20,3 +20,13 @@ class UserSSHKey(models.Model): def __unicode__(self): return self.keyname + +class UserAttributes(models.Model): + user = models.OneToOneField(User, on_delete=models.CASCADE) + can_clone_instances = models.BooleanField(default=False) + max_instances = models.IntegerField(default=0) + max_cpus = models.IntegerField(default=0) + max_memory = models.IntegerField(default=0) + + def __unicode__(self): + return self.user.username diff --git a/accounts/templates/accounts.html b/accounts/templates/accounts.html index cc03668..41d5448 100644 --- a/accounts/templates/accounts.html +++ b/accounts/templates/accounts.html @@ -83,6 +83,30 @@ +
{% trans "Create a clone" %}