Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Annisa Devi Nurmalasari
walkiddie-be-test2
Commits
2429e226
Commit
2429e226
authored
Nov 30, 2021
by
Muhammad Azhar Hassanuddin
Browse files
feat: toko memiliki string identifier (gabungan nama toko dan nomor toko)
parent
8436be63
Changes
1
Hide whitespace changes
Inline
Side-by-side
toko/serializers.py
View file @
2429e226
...
...
@@ -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
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment