Commit 408913b5 authored by Lukas Burgey's avatar Lukas Burgey

Remove experimental models file

parent 226df6a3
......@@ -40,7 +40,6 @@ STATIC_ROOT = 'static'
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'polymorphic',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
......
import logging
from django.db import models
from polymorphic.models import PolymorphicModel
from rest_framework import serializers
from rest_polymorphic.serializers import PolymorphicSerializer
LOGGER = logging.getLogger(__name__)
class Credential(PolymorphicModel):
# name of the credential
name = models.CharField(
max_length=150,
)
# the credential itself (e.g. the ssh public key)
value = models.TextField(
max_length=1000
)
class SSHKey(Credential):
@property
def type(self):
return 'ssh_public_key'
class PasswordHash(Credential):
# the used hash algorithm
hash_algorithm = models.CharField(
max_length=150,
)
@property
def type(self):
return 'password_hash'
class SSHKeySerializer(serializers.ModelSerializer):
class Meta:
model = SSHKey
fields = ('name', 'value', 'type',)
class PasswordHashSerializer(serializers.ModelSerializer):
class Meta:
model = PasswordHash
fields = ('name', 'value', 'type', 'hash_algorithm',)
class CredentialSerializer(PolymorphicSerializer):
mode_serializer_mapping = {
SSHKey: SSHKeySerializer,
PasswordHash: PasswordHashSerializer,
}
......@@ -18,11 +18,11 @@ echo "Generating secret at ./.secret.key"
dd if=/dev/urandom bs=64 count=1 | base64 > ./.secret.key
echo
virtualenv -p /usr/bin/python3.5 ./env
virtualenv -p /usr/bin/python3 ./env
source env/bin/activate
# TODO check dependencies
pip install Django django-cors-headers django-mysql django-polymorphic django-rest-polymorphic djangorestframework oic urllib3 mysqlclient pika ipython
pip install Django django-cors-headers django-mysql djangorestframework oic urllib3 mysqlclient pika
echo "Starting database migration (is your database configured?)"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment