Fakultas Ilmu Komputer UI

Commit 2429e226 authored by Muhammad Azhar Hassanuddin's avatar Muhammad Azhar Hassanuddin
Browse files

feat: toko memiliki string identifier (gabungan nama toko dan nomor toko)

parent 8436be63
......@@ -8,6 +8,7 @@ class TokoSerializer(serializers.ModelSerializer):
owner = serializers.ReadOnlyField(source='owner.email')
foto_profil_toko = serializers.ImageField(read_only=True)
nomor_toko = serializers.IntegerField(read_only=True)
identifier_toko = serializers.SerializerMethodField('get_identifier')
class Meta:
model = Toko
fields = [
......@@ -16,6 +17,7 @@ class TokoSerializer(serializers.ModelSerializer):
'nama_toko',
'nama_cabang',
'nomor_toko',
'identifier_toko',
'status',
'tipe_usaha',
'nomor_telepon',
......@@ -27,6 +29,10 @@ class TokoSerializer(serializers.ModelSerializer):
'foto_profil_toko'
]
@staticmethod
def get_identifier(obj):
return "{}_{:0>3}".format(obj.nama_toko, obj.nomor_toko)
class PengadaanReadSerializer(serializers.ModelSerializer):
toko = TokoSerializer(read_only=True)
......
Supports Markdown
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