Fixed ungleich urls, created model for storing VM types, created command to load VM prices and data to database
This commit is contained in:
		
					parent
					
						
							
								5397fd9a63
							
						
					
				
			
			
				commit
				
					
						7c891fe9c4
					
				
			
		
					 9 changed files with 155 additions and 2 deletions
				
			
		| 
						 | 
					@ -5,6 +5,7 @@ from . import views
 | 
				
			||||||
from .views import ContactView, IndexView, AboutView
 | 
					from .views import ContactView, IndexView, AboutView
 | 
				
			||||||
 | 
					
 | 
				
			||||||
urlpatterns = [
 | 
					urlpatterns = [
 | 
				
			||||||
 | 
					    url(r'', IndexView.as_view(), name='home'),
 | 
				
			||||||
    url(_(r'home/?$'), IndexView.as_view(), name='home'),
 | 
					    url(_(r'home/?$'), IndexView.as_view(), name='home'),
 | 
				
			||||||
    url(_(r'about/?$'), AboutView.as_view(), name='about'),
 | 
					    url(_(r'about/?$'), AboutView.as_view(), name='about'),
 | 
				
			||||||
    url(_(r'contact/?$'), ContactView.as_view(), name='contact'),
 | 
					    url(_(r'contact/?$'), ContactView.as_view(), name='contact'),
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,4 @@
 | 
				
			||||||
from django.contrib import admin
 | 
					from django.contrib import admin
 | 
				
			||||||
from .models import RailsBetaUser 
 | 
					from .models import RailsBetaUser, VirtualMachineType
 | 
				
			||||||
 | 
					
 | 
				
			||||||
admin.site.register(RailsBetaUser)
 | 
					admin.site.register(RailsBetaUser, VirtualMachineType)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										0
									
								
								hosting/management/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								hosting/management/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
								
								
									
										0
									
								
								hosting/management/commands/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								hosting/management/commands/__init__.py
									
										
									
									
									
										Normal file
									
								
							
							
								
								
									
										54
									
								
								hosting/management/commands/create_vm_types.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										54
									
								
								hosting/management/commands/create_vm_types.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,54 @@
 | 
				
			||||||
 | 
					from django.core.management.base import BaseCommand, CommandError
 | 
				
			||||||
 | 
					from hosting.models import VirtualMachineType
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Command(BaseCommand):
 | 
				
			||||||
 | 
					    help = 'Create VM types'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def get_data(self):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        hetzner = {
 | 
				
			||||||
 | 
					            'base_price': 10,
 | 
				
			||||||
 | 
					            'core_price': 10,
 | 
				
			||||||
 | 
					            'memory_price': 10,
 | 
				
			||||||
 | 
					            'disk_size_price': 10,
 | 
				
			||||||
 | 
					            'description': 'VM auf einzelner HW, Raid1, kein HA'
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        return {
 | 
				
			||||||
 | 
					            'hetzner_nug': {
 | 
				
			||||||
 | 
					                'base_price': 5,
 | 
				
			||||||
 | 
					                'memory_price': 2,
 | 
				
			||||||
 | 
					                'core_price': 2,
 | 
				
			||||||
 | 
					                'disk_size_price': 0.5,
 | 
				
			||||||
 | 
					                'description': 'VM ohne Uptime Garantie'
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            'hetzner': hetzner,
 | 
				
			||||||
 | 
					            'hetzner_raid6': {
 | 
				
			||||||
 | 
					                'base_price': hetzner['base_price']*1.2,
 | 
				
			||||||
 | 
					                'core_price': hetzner['core_price']*1.2,
 | 
				
			||||||
 | 
					                'memory_price': hetzner['memory_price']*1.2,
 | 
				
			||||||
 | 
					                'disk_size_price': hetzner['disk_size_price']*1.2,
 | 
				
			||||||
 | 
					                'description': 'VM auf einzelner HW, Raid1, kein HA'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            'hetzner_glusterfs': {
 | 
				
			||||||
 | 
					                'base_price': hetzner['base_price']*1.4,
 | 
				
			||||||
 | 
					                'core_price': hetzner['core_price']*1.4,
 | 
				
			||||||
 | 
					                'memory_price': hetzner['memory_price']*1.4,
 | 
				
			||||||
 | 
					                'disk_size_price': hetzner['disk_size_price']*1.4,
 | 
				
			||||||
 | 
					                'description': 'VM auf einzelner HW, Raid1, kein HA'
 | 
				
			||||||
 | 
					            },
 | 
				
			||||||
 | 
					            'bern': {
 | 
				
			||||||
 | 
					                'base_price': 12,
 | 
				
			||||||
 | 
					                'core_price': 25,
 | 
				
			||||||
 | 
					                'memory_price': 7,
 | 
				
			||||||
 | 
					                'disk_size_price': 0.70,
 | 
				
			||||||
 | 
					                'description': "VM in Bern, HA Setup ohne HA Garantie",
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def handle(self, *args, **options):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        data = self.get_data()
 | 
				
			||||||
 | 
					        [VirtualMachineType.objects.create(**data[key]) for key in data.keys()]
 | 
				
			||||||
							
								
								
									
										27
									
								
								hosting/migrations/0003_virtualmachinetypes.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								hosting/migrations/0003_virtualmachinetypes.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,27 @@
 | 
				
			||||||
 | 
					# -*- coding: utf-8 -*-
 | 
				
			||||||
 | 
					# Generated by Django 1.9.4 on 2016-04-18 00:32
 | 
				
			||||||
 | 
					from __future__ import unicode_literals
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from django.db import migrations, models
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Migration(migrations.Migration):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    dependencies = [
 | 
				
			||||||
 | 
					        ('hosting', '0002_railsbetauser'),
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    operations = [
 | 
				
			||||||
 | 
					        migrations.CreateModel(
 | 
				
			||||||
 | 
					            name='VirtualMachineTypes',
 | 
				
			||||||
 | 
					            fields=[
 | 
				
			||||||
 | 
					                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
 | 
				
			||||||
 | 
					                ('description', models.TextField()),
 | 
				
			||||||
 | 
					                ('base_price', models.FloatField()),
 | 
				
			||||||
 | 
					                ('memory_price', models.FloatField()),
 | 
				
			||||||
 | 
					                ('cores_price', models.FloatField()),
 | 
				
			||||||
 | 
					                ('disk_size_price', models.FloatField()),
 | 
				
			||||||
 | 
					                ('hosting_company', models.CharField(choices=[('hetzner_nug', 'Hetzner No Uptime Guarantee'), ('hetzner', 'Hetzner'), ('hetzner_raid6', 'Hetzner Raid6'), ('hetzner_glusterfs', 'Hetzner Glusterfs'), ('bern', 'Bern')], max_length=10)),
 | 
				
			||||||
 | 
					            ],
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
							
								
								
									
										19
									
								
								hosting/migrations/0004_auto_20160418_0034.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										19
									
								
								hosting/migrations/0004_auto_20160418_0034.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,19 @@
 | 
				
			||||||
 | 
					# -*- coding: utf-8 -*-
 | 
				
			||||||
 | 
					# Generated by Django 1.9.4 on 2016-04-18 00:34
 | 
				
			||||||
 | 
					from __future__ import unicode_literals
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from django.db import migrations
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Migration(migrations.Migration):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    dependencies = [
 | 
				
			||||||
 | 
					        ('hosting', '0003_virtualmachinetypes'),
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    operations = [
 | 
				
			||||||
 | 
					        migrations.RenameModel(
 | 
				
			||||||
 | 
					            old_name='VirtualMachineTypes',
 | 
				
			||||||
 | 
					            new_name='VirtualMachineType',
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
							
								
								
									
										20
									
								
								hosting/migrations/0005_auto_20160418_0038.py
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								hosting/migrations/0005_auto_20160418_0038.py
									
										
									
									
									
										Normal file
									
								
							| 
						 | 
					@ -0,0 +1,20 @@
 | 
				
			||||||
 | 
					# -*- coding: utf-8 -*-
 | 
				
			||||||
 | 
					# Generated by Django 1.9.4 on 2016-04-18 00:38
 | 
				
			||||||
 | 
					from __future__ import unicode_literals
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					from django.db import migrations
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class Migration(migrations.Migration):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    dependencies = [
 | 
				
			||||||
 | 
					        ('hosting', '0004_auto_20160418_0034'),
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    operations = [
 | 
				
			||||||
 | 
					        migrations.RenameField(
 | 
				
			||||||
 | 
					            model_name='virtualmachinetype',
 | 
				
			||||||
 | 
					            old_name='cores_price',
 | 
				
			||||||
 | 
					            new_name='core_price',
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					    ]
 | 
				
			||||||
| 
						 | 
					@ -1,4 +1,9 @@
 | 
				
			||||||
from django.db import models
 | 
					from django.db import models
 | 
				
			||||||
 | 
					from django.utils.translation import ugettext_lazy as _
 | 
				
			||||||
 | 
					from django.core import serializers
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class RailsBetaUser(models.Model):
 | 
					class RailsBetaUser(models.Model):
 | 
				
			||||||
    email = models.EmailField(unique=True)
 | 
					    email = models.EmailField(unique=True)
 | 
				
			||||||
| 
						 | 
					@ -6,3 +11,30 @@ class RailsBetaUser(models.Model):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __str__(self):
 | 
					    def __str__(self):
 | 
				
			||||||
        return "%s - %s" % (self.email, self.received_date)
 | 
					        return "%s - %s" % (self.email, self.received_date)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class VirtualMachineType(models.Model):
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    HETZNER_NUG = 'hetzner_nug'
 | 
				
			||||||
 | 
					    HETZNER = 'hetzner'
 | 
				
			||||||
 | 
					    HETZNER_R6 = 'hetzner_raid6'
 | 
				
			||||||
 | 
					    HETZNER_G = 'hetzner_glusterfs'
 | 
				
			||||||
 | 
					    BERN = 'bern'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    HOSTING_TYPES = (
 | 
				
			||||||
 | 
					        (HETZNER_NUG, 'Hetzner No Uptime Guarantee'),
 | 
				
			||||||
 | 
					        (HETZNER, 'Hetzner'),
 | 
				
			||||||
 | 
					        (HETZNER_R6, 'Hetzner Raid6'),
 | 
				
			||||||
 | 
					        (HETZNER_G, 'Hetzner Glusterfs'),
 | 
				
			||||||
 | 
					        (BERN, 'Bern'),
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    description = models.TextField()
 | 
				
			||||||
 | 
					    base_price = models.FloatField()
 | 
				
			||||||
 | 
					    memory_price = models.FloatField()
 | 
				
			||||||
 | 
					    core_price = models.FloatField()
 | 
				
			||||||
 | 
					    disk_size_price = models.FloatField()
 | 
				
			||||||
 | 
					    hosting_company = models.CharField(max_length=10, choices=HOSTING_TYPES)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def get_serialized_data(self):
 | 
				
			||||||
 | 
					        return serializers("json", self)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue