import os

from rest_framework import serializers
from .models import SiemensUser


class SiemensUserSerializer(serializers.ModelSerializer):
    class Meta:
        model = SiemensUser
        fields = ['email', 'password', 'foto', 'is_superuser', 'is_staff', 'is_active', 'nombre', 'last_login']

    def to_representation(self, instance):
        ret = super().to_representation(instance)
        ret['foto'] = "profile_images/" + os.path.basename(ret['foto'])

        return ret
