From 3015399692f871a6b33793525b5c2394bf629d7a Mon Sep 17 00:00:00 2001 From: Levi Date: Sun, 17 Apr 2016 20:05:39 -0500 Subject: [PATCH] registered VM types model in the admin --- hosting/admin.py | 4 +++- .../management/commands/create_vm_types.py | 3 ++- hosting/migrations/0006_auto_20160418_0103.py | 20 +++++++++++++++++++ hosting/migrations/0007_auto_20160418_0103.py | 20 +++++++++++++++++++ hosting/models.py | 7 ++++--- 5 files changed, 49 insertions(+), 5 deletions(-) create mode 100644 hosting/migrations/0006_auto_20160418_0103.py create mode 100644 hosting/migrations/0007_auto_20160418_0103.py diff --git a/hosting/admin.py b/hosting/admin.py index 8d5366e5..84067ff9 100644 --- a/hosting/admin.py +++ b/hosting/admin.py @@ -1,4 +1,6 @@ from django.contrib import admin from .models import RailsBetaUser, VirtualMachineType -admin.site.register(RailsBetaUser, VirtualMachineType) + +admin.site.register(RailsBetaUser) +admin.site.register(VirtualMachineType) diff --git a/hosting/management/commands/create_vm_types.py b/hosting/management/commands/create_vm_types.py index 78d9fbe3..23961bae 100644 --- a/hosting/management/commands/create_vm_types.py +++ b/hosting/management/commands/create_vm_types.py @@ -51,4 +51,5 @@ class Command(BaseCommand): def handle(self, *args, **options): data = self.get_data() - [VirtualMachineType.objects.create(**data[key]) for key in data.keys()] + [VirtualMachineType.objects.create(hosting_company=key, **data[key]) + for key in data.keys()] diff --git a/hosting/migrations/0006_auto_20160418_0103.py b/hosting/migrations/0006_auto_20160418_0103.py new file mode 100644 index 00000000..51a93abd --- /dev/null +++ b/hosting/migrations/0006_auto_20160418_0103.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2016-04-18 01:03 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0005_auto_20160418_0038'), + ] + + operations = [ + migrations.AlterField( + model_name='virtualmachinetype', + name='hosting_company', + field=models.CharField(choices=[('hetzner_nug', 'Hetzner No Uptime Guarantee'), ('hetzner', 'Hetzner'), ('hetzner_raid6', 'Hetzner Raid6'), ('hetzner_glusterfs', 'Hetzner Glusterfs'), ('bern', 'Bern')], max_length=15), + ), + ] diff --git a/hosting/migrations/0007_auto_20160418_0103.py b/hosting/migrations/0007_auto_20160418_0103.py new file mode 100644 index 00000000..bff7570e --- /dev/null +++ b/hosting/migrations/0007_auto_20160418_0103.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2016-04-18 01:03 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0006_auto_20160418_0103'), + ] + + operations = [ + migrations.AlterField( + model_name='virtualmachinetype', + name='hosting_company', + field=models.CharField(choices=[('hetzner_nug', 'Hetzner No Uptime Guarantee'), ('hetzner', 'Hetzner'), ('hetzner_raid6', 'Hetzner Raid6'), ('hetzner_glusterfs', 'Hetzner Glusterfs'), ('bern', 'Bern')], max_length=30), + ), + ] diff --git a/hosting/models.py b/hosting/models.py index ea9d4d35..e66dbe28 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -3,8 +3,6 @@ from django.utils.translation import ugettext_lazy as _ from django.core import serializers - - class RailsBetaUser(models.Model): email = models.EmailField(unique=True) received_date = models.DateTimeField('date received') @@ -34,7 +32,10 @@ class VirtualMachineType(models.Model): memory_price = models.FloatField() core_price = models.FloatField() disk_size_price = models.FloatField() - hosting_company = models.CharField(max_length=10, choices=HOSTING_TYPES) + hosting_company = models.CharField(max_length=30, choices=HOSTING_TYPES) + + def __str__(self): + return "%s" % (self.get_hosting_company_display()) def get_serialized_data(self): return serializers("json", self)