class CabinetSerializerForSelect(serializers.ModelSerializer): cabinet_set = BriefCabinetSetSerializer() user = user_serializers.UserSerializer() class Meta: model = models.Cabinet fields = ('cabinet_number', 'xpos', 'ypos', 'id', 'start_date', 'cabinet_set', 'end_date', 'is_usable', 'is_clean', 'user')
class InputMembershipHistorySerializer(serializers.ModelSerializer): membership = MembershipSerializer(read_only=True) creator = user_serializers.UserSerializer() action = ActionSerializer(read_only=True) class Meta: model = models.MembershipHistory fields = ('membership', 'creator', 'action')
class HistorySerializer(serializers.ModelSerializer): cabinet = CabinetSerializerForSelect() cabinet_action = CabinetActionSerializer() user = user_serializers.UserSerializer() class Meta: model = models.CabinetHistory fields = ('id', 'user', 'cabinet', 'start_date', 'end_date', 'cabinet_action', 'created_at')
class CabinetDetailSerializer(serializers.ModelSerializer): cabinet_historys = HistorySerializer(many=True) user = user_serializers.UserSerializer() cabinet_lock = CabLockSerializer() class Meta: model = models.Cabinet fields = ('id', 'cabinet_number', 'cabinet_set', 'xpos', 'ypos', 'updated_at', 'start_date', 'end_date', 'cabinet_historys', 'user', 'cabinet_lock')
class MembershipSerializer(serializers.ModelSerializer): user = user_serializers.UserSerializer() branch = branch_serializers.BranchForMembershipSerializer() start_date = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S") end_date = serializers.DateTimeField(format="%Y-%m-%d %H:%M:%S") # creator = user_serializers.UserSerializer(read_only=True) class Meta: model = models.Membership fields = ('id', 'user', 'branch', 'start_date', 'end_date', 'is_usable', 'created_at', 'updated_at')