update readme + api
This commit is contained in:
parent
f588691f0d
commit
fc4ec7b0f8
6 changed files with 61 additions and 37 deletions
|
@ -5,7 +5,7 @@
|
|||
Alpine:
|
||||
|
||||
```
|
||||
apk add openldap-dev
|
||||
apk add openldap-dev postgresql-dev
|
||||
```
|
||||
|
||||
### Python requirements
|
||||
|
@ -22,3 +22,26 @@ Then install the requirements
|
|||
```
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### Database requirements
|
||||
|
||||
Due to the use of the JSONField, postgresql is required.
|
||||
|
||||
First create a role to be used:
|
||||
|
||||
```
|
||||
postgres=# create role nico login;
|
||||
```
|
||||
|
||||
Then create the database owner by the new role:
|
||||
|
||||
```
|
||||
postgres=# create database uncloud owner nico;
|
||||
```
|
||||
|
||||
|
||||
|
||||
### Secrets
|
||||
|
||||
cp `uncloud/secrets_sample.py` to `uncloud/secrets.py` and replace the
|
||||
sample values with real values.
|
||||
|
|
|
@ -3,3 +3,4 @@ djangorestframework
|
|||
django-auth-ldap
|
||||
stripe
|
||||
xmltodict
|
||||
psycopg2
|
||||
|
|
|
@ -1,12 +1,3 @@
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Live/test key from stripe
|
||||
STRIPE_KEY=""
|
||||
|
||||
|
@ -15,3 +6,5 @@ OPENNEBULA_URL='https://opennebula.ungleich.ch:2634/RPC2'
|
|||
|
||||
# user:pass for accessing opennebula
|
||||
OPENNEBULA_USER_PASS='user:password'
|
||||
|
||||
POSTGRESQL_DB_NAME="uncloud"
|
||||
|
|
|
@ -74,15 +74,6 @@ TEMPLATES = [
|
|||
WSGI_APPLICATION = 'uncloud.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
|
@ -159,8 +150,16 @@ USE_TZ = True
|
|||
STATIC_URL = '/static/'
|
||||
|
||||
|
||||
# Uncommitted file
|
||||
# import uncloud.secrets
|
||||
#
|
||||
# import stripe
|
||||
# stripe.api_key = uncloud.secrets.STRIPE_KEY
|
||||
# Uncommitted file with secrets
|
||||
import uncloud.secrets
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.postgresql',
|
||||
'NAME': uncloud.secrets.POSTGRESQL_DB_NAME,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,5 +2,5 @@ from django.contrib import admin
|
|||
|
||||
from .models import Product, Feature
|
||||
|
||||
admin.site.register(Product)
|
||||
admin.site.register(Feature)
|
||||
#admin.site.register(Product)
|
||||
#admin.site.register(Feature)
|
||||
|
|
|
@ -32,7 +32,12 @@ from django.contrib.auth import get_user_model
|
|||
# Should have a log = ... => 1:n field for most models!
|
||||
|
||||
class Product(models.Model):
|
||||
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
owner = models.ForeignKey(get_user_model(),
|
||||
on_delete=models.CASCADE)
|
||||
|
||||
# override these fields by default
|
||||
|
||||
description = ""
|
||||
recurring_period = "not_recurring"
|
||||
|
||||
|
@ -42,8 +47,12 @@ class Product(models.Model):
|
|||
('being_created', 'Being created'),
|
||||
('created_active', 'Created'),
|
||||
('deleted', 'Deleted')
|
||||
),
|
||||
default='pending'
|
||||
)
|
||||
)
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def __str__(self):
|
||||
return "{}".format(self.name)
|
||||
|
@ -106,19 +115,18 @@ class Feature(models.Model):
|
|||
# value_str
|
||||
# value_float
|
||||
|
||||
class Meta:
|
||||
abstract = True
|
||||
|
||||
def __str__(self):
|
||||
return "'{}' - '{}'".format(self.product, self.name)
|
||||
|
||||
|
||||
class Order(models.Model):
|
||||
uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
# class Order(models.Model):
|
||||
# uuid = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
|
||||
|
||||
owner = models.ForeignKey(get_user_model(),
|
||||
on_delete=models.CASCADE)
|
||||
# owner = models.ForeignKey(get_user_model(),
|
||||
# on_delete=models.CASCADE)
|
||||
|
||||
product = models.ForeignKey(Product,
|
||||
on_delete=models.CASCADE)
|
||||
|
||||
|
||||
class VMSnapshotOrder(Order):
|
||||
pass
|
||||
# product = models.ForeignKey(Product,
|
||||
# on_delete=models.CASCADE)
|
||||
|
|
Loading…
Reference in a new issue