Commit 1dacf811 authored by Lukas Burgey's avatar Lukas Burgey
Browse files

Move some code to module initializers

parent 2038fdda
......@@ -2,8 +2,9 @@ from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import Group
from . import models
from .models import brokers as broker_models
from .auth.v1.models import OIDCConfig
from .models import models, brokers as broker_models
class TypeFilter(admin.SimpleListFilter):
......
......@@ -7,7 +7,7 @@ from django.http import HttpResponse
from django.contrib.auth import authenticate
from django.contrib.sessions.models import Session
from ....models.models import Site
from ....models import Site
from ....models.brokers import RabbitMQInstance
from ....models.users import User
......
This diff is collapsed.
This diff is collapsed.
# we don't need to deserialize, so we do not implement the abstract methods
# pylint: disable=abstract-method
from django.contrib.auth.models import Group
from rest_framework import serializers
from ...models import SSHPublicKey
class GroupSerializer(serializers.ModelSerializer):
class Meta:
model = Group
fields = [
'id',
'name',
]
class SSHPublicKeySerializer(serializers.ModelSerializer):
class Meta:
model = SSHPublicKey
fields = [
'id',
'name',
'key',
]
class SSHPublicKeyRefSerializer(serializers.ModelSerializer):
class Meta:
model = SSHPublicKey
fields = [
'id',
'name',
]
......@@ -4,10 +4,10 @@
from django_mysql.models import JSONField
from rest_framework import serializers
from .. import models
from ... import models
from ..users import User
from ..brokers import RabbitMQInstance
from .serializers import GroupSerializer, SSHPublicKeySerializer
from . import GroupSerializer, SSHPublicKeySerializer
class ServiceSerializer(serializers.ModelSerializer):
......
# we don't need to deserialize, so we do not implement the abstract methods
# pylint: disable=abstract-method
from django.contrib.auth.models import Group
from rest_framework import serializers
from ..models import SSHPublicKey
class GroupSerializer(serializers.ModelSerializer):
class Meta:
model = Group
fields = [
'id',
'name',
]
class SSHPublicKeySerializer(serializers.ModelSerializer):
class Meta:
model = SSHPublicKey
fields = [
'id',
'name',
'key',
]
class SSHPublicKeyRefSerializer(serializers.ModelSerializer):
class Meta:
model = SSHPublicKey
fields = [
'id',
'name',
]
......@@ -3,9 +3,9 @@
from rest_framework import serializers
from .. import models
from ... import models
from ..users import User
from . import serializers as backend_serializers
from .. import serializers as backend_serializers
class SiteSerializer(serializers.ModelSerializer):
......
......@@ -5,7 +5,7 @@ from django.contrib import auth
from django.contrib.auth.models import Group
from django.test import TestCase
from django_backend.backend.models import models
from django_backend.backend import models
from django_backend.backend.auth.v1 import models as auth_models
LOGGER = logging.getLogger(__name__)
......
......@@ -158,7 +158,7 @@ class User(AbstractUser):
return 'DEACTIVATED USER {}'.format(self.username)
return 'USER {}'.format(self.username)
elif self.user_type == 'apiclient':
from .models import Site
from . import Site
try:
return 'APICLIENT {}@{}'.format(self.username, self.site)
except Site.DoesNotExist:
......@@ -236,7 +236,7 @@ class User(AbstractUser):
unity_key_value = userinfo.get('ssh_key', '')
unity_key_name = 'unity_key'
from .models import SSHPublicKey
from . import SSHPublicKey
try:
key = self._ssh_keys.get(name=unity_key_name)
if key.key != unity_key_value:
......
......@@ -9,7 +9,7 @@ from rest_framework.response import Response
from ..models.brokers import RabbitMQInstance
from ..models.serializers.webpage import DeploymentStateSerializer
from ..models.serializers.clients import RabbitMQInstanceSerializer
from ..models import models
from .. import models
LOGGER = logging.getLogger(__name__)
......
......@@ -8,8 +8,9 @@ from rest_framework import views
from rest_framework.permissions import AllowAny
from rest_framework.response import Response
from ..models import models
from ..models.serializers import webpage as serializers, serializers as model_serializers
from .. import models
from ..models.serializers import webpage as serializers
from ..models import serializers as model_serializers
LOGGER = logging.getLogger(__name__)
......
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