cuebook/cuelake

View on GitHub
api/system/serializers.py

Summary

Maintainability
A
0 mins
Test Coverage
A
92%
import json
from rest_framework import serializers
from system.models import AccountSetting

class AccountSettingSerializer(serializers.ModelSerializer):
    """
    Serializer for the model Account Setting
    """
    value = serializers.SerializerMethodField()
    
    def get_value(self, obj):
        """
        Gets account setting value
        """
        values = obj.accountsettingvalue_set.all()
        if len(values):
            return values[0].value
        else:
            return ""

    class Meta:
        model = AccountSetting
        fields = ["key", "label", "type", "value"]