registered VM types model in the admin

This commit is contained in:
Levi 2016-04-17 20:05:39 -05:00
parent 368cfcecd1
commit 3015399692
5 changed files with 49 additions and 5 deletions

View file

@ -1,4 +1,6 @@
from django.contrib import admin from django.contrib import admin
from .models import RailsBetaUser, VirtualMachineType from .models import RailsBetaUser, VirtualMachineType
admin.site.register(RailsBetaUser, VirtualMachineType)
admin.site.register(RailsBetaUser)
admin.site.register(VirtualMachineType)

View file

@ -51,4 +51,5 @@ class Command(BaseCommand):
def handle(self, *args, **options): def handle(self, *args, **options):
data = self.get_data() 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()]

View file

@ -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),
),
]

View file

@ -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),
),
]

View file

@ -3,8 +3,6 @@ from django.utils.translation import ugettext_lazy as _
from django.core import serializers from django.core import serializers
class RailsBetaUser(models.Model): class RailsBetaUser(models.Model):
email = models.EmailField(unique=True) email = models.EmailField(unique=True)
received_date = models.DateTimeField('date received') received_date = models.DateTimeField('date received')
@ -34,7 +32,10 @@ class VirtualMachineType(models.Model):
memory_price = models.FloatField() memory_price = models.FloatField()
core_price = models.FloatField() core_price = models.FloatField()
disk_size_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): def get_serialized_data(self):
return serializers("json", self) return serializers("json", self)