1 ##############################################################################
2 # Copyright (c) 2016 Max Breitenfeldt and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
11 from rest_framework import serializers
13 from account.models import UserProfile
14 from notifier.models import Notifier
15 from booking.models import Booking
16 from dashboard.models import Server, Resource, ResourceStatus
18 class BookingSerializer(serializers.ModelSerializer):
19 installer_name = serializers.CharField(source='installer.name')
20 scenario_name = serializers.CharField(source='scenario.name')
21 opsys_name = serializers.CharField(source='opsys.name')
25 fields = ('id', 'changeid', 'reset', 'user', 'resource_id', 'opsys_name', 'start', 'end', 'installer_name', 'scenario_name', 'purpose')
28 class ServerSerializer(serializers.ModelSerializer):
31 fields = ('id', 'resource_id', 'name', 'model', 'cpu', 'ram', 'storage')
34 class ResourceSerializer(serializers.ModelSerializer):
37 fields = ('id', 'name', 'description', 'resource_lab', 'url', 'server_set', 'dev_pod')
39 class ResourceStatusSerializer(serializers.ModelSerializer):
41 model = ResourceStatus
42 fields = ('id', 'resource', 'timestamp','type', 'title', 'content')
44 class NotifierSerializer(serializers.ModelSerializer):
47 fields = ('id', 'title', 'content', 'user', 'sender', 'message_type', 'msg_sent')
49 class UserSerializer(serializers.ModelSerializer):
50 username = serializers.CharField(source='user.username')
53 fields = ('user', 'username', 'ssh_public_key', 'pgp_public_key', 'email_addr')