Provider and Provider Management

Change-Id: I8c72bbc02ad975ee02fc282ddc894f49b5cfb254
This commit is contained in:
Paarhati Ozkasgarli 2016-12-01 21:07:11 +00:00
parent b0c21942ab
commit cc0308df9c
15 changed files with 193 additions and 2 deletions

View File

@ -12,7 +12,7 @@ _ = _translators.primary
# The contextual translation function using the name "_C"
# requires oslo.i18n >=2.1.0
_C = _translators.contextual_form
ya
# The plural translation function using the name "_P"
# requires oslo.i18n >=2.1.0
_P = _translators.plural_form

View File

@ -55,6 +55,7 @@ INSTALLED_APPS = [
'security',
'server',
'user_profile',
'provider',
]
MIDDLEWARE = [

0
provider/__init__.py Normal file
View File

13
provider/admin.py Normal file
View File

@ -0,0 +1,13 @@
from django.contrib import admin
from .models import Provider, Type
class ProviderAdmin(admin.ModelAdmin):
model = Provider
list_display = ['id', 'name', 'provider', 'enabled', 'validated']
class TypeAdmin(admin.ModelAdmin):
model = Type
list_display = ['id', 'name', 'type', 'logo']
admin.site.register(Provider,ProviderAdmin)
admin.site.register(Type,TypeAdmin)

7
provider/apps.py Normal file
View File

@ -0,0 +1,7 @@
from __future__ import unicode_literals
from django.apps import AppConfig
class ProviderConfig(AppConfig):
name = 'provider'

View File

@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-12-02 19:51
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Provider',
fields=[
('id', models.IntegerField(primary_key=True, serialize=False)),
('provider', models.CharField(max_length=64)),
('name', models.CharField(db_index=True, max_length=255, unique=True)),
('region', models.CharField(db_index=True, max_length=255, unique=True)),
('project_id', models.CharField(db_index=True, max_length=255)),
('default_role', models.CharField(max_length=255)),
('default_domain_id', models.CharField(max_length=255)),
('username', models.CharField(db_index=True, max_length=255, unique=True)),
('password', models.CharField(max_length=255)),
('api_version', models.CharField(max_length=255)),
('url', models.TextField()),
('created_at', models.DateField()),
('enabled', models.BooleanField(default=True)),
('validated', models.BooleanField(default=False)),
],
),
]

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-12-02 20:42
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('provider', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='provider',
name='id',
field=models.AutoField(primary_key=True, serialize=False),
),
]

View File

@ -0,0 +1,24 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-12-04 10:00
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('provider', '0002_auto_20161202_2042'),
]
operations = [
migrations.CreateModel(
name='Type',
fields=[
('id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(db_index=True, max_length=255, unique=True)),
('type', models.CharField(choices=[('1', 'Public Cloud Provider'), ('2', 'Private Cloud Provider'), ('3', 'Container Provider'), ('4', 'VPS Provider')], max_length=1)),
('logo', models.FileField(upload_to='static/provider-logo/')),
],
),
]

View File

62
provider/models.py Normal file
View File

@ -0,0 +1,62 @@
from __future__ import unicode_literals
from django.db import models
class Provider(models.Model):
id = models.AutoField(primary_key=True)
provider = models.CharField(max_length=64)
name = models.CharField(
max_length=255,
unique=True,
db_index=True
)
region = models.CharField(
max_length=255,
unique=True,
db_index=True
)
project_id = models.CharField(
max_length=255,
db_index=True
)
default_role = models.CharField(max_length=255)
default_domain_id = models.CharField(max_length=255)
username = models.CharField(
max_length=255,
unique=True,
db_index=True
)
password = models.CharField(max_length=255)
api_version = models.CharField(max_length=255)
url = models.TextField()
created_at = models.DateField()
enabled = models.BooleanField(default=True)
validated = models.BooleanField(default=False)
def __unicode__(self):
return self.name
class Type(models.Model):
types = (
('1', 'Public Cloud Provider'),
('2', 'Private Cloud Provider'),
('3', 'Container Provider'),
('4', 'VPS Provider'),
)
id = models.AutoField(primary_key=True)
name = models.CharField(
max_length=255,
unique=True,
db_index=True
)
type = models.CharField(
max_length=1,
choices=types
)
logo = models.FileField(upload_to='static/provider-logo/')
def __unicode__(self):
return self.name

3
provider/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
provider/views.py Normal file
View File

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2016-12-01 21:20
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('user_profile', '0001_initial'),
]
operations = [
migrations.AlterField(
model_name='profile',
name='avatar',
field=models.FileField(upload_to='static/avatar/%Y-%m-%d'),
),
]

View File

@ -5,7 +5,10 @@ from django.contrib.auth.models import User
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
user = models.OneToOneField(
User,
on_delete=models.CASCADE
)
avatar = models.FileField(upload_to='static/avatar/%Y-%m-%d')
provider_password = models.CharField(max_length=50)
selected_provider = models.IntegerField()