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
ppl-fasilkom-ui
PPL Sosial
pilar
pilar-backend
Commits
ce19f188
Commit
ce19f188
authored
Mar 25, 2021
by
Reka Paska Enda
Browse files
[REFACTOR] Memperbaiki bug Gambar produk pada halaman detail produk tidak terlihat
parent
556789f3
Pipeline
#66175
passed with stages
in 8 minutes and 26 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
api/views.py
View file @
ce19f188
...
...
@@ -626,6 +626,11 @@ class ProductList(generics.ListCreateAPIView):
def
post
(
self
,
request
,
_format
=
None
):
serializer
=
self
.
get_serializer
(
data
=
request
.
data
)
serializer
.
is_valid
(
raise_exception
=
True
)
validated_image
=
None
try
:
validated_image
=
serializer
.
validated_data
[
'image'
]
except
KeyError
:
pass
product
=
models
.
Product
.
objects
.
create
(
name
=
serializer
.
validated_data
[
'name'
],
description
=
serializer
.
validated_data
[
'description'
],
...
...
@@ -633,7 +638,8 @@ class ProductList(generics.ListCreateAPIView):
stock
=
serializer
.
validated_data
[
'stock'
],
modal
=
serializer
.
validated_data
[
'modal'
],
subcategory
=
models
.
Subcategory
.
objects
.
get
(
name
=
serializer
.
validated_data
[
'subcategory'
]),
total_profit
=
0
total_profit
=
0
,
image
=
validated_image
)
product
.
profit
=
(
product
.
price
-
product
.
modal
)
product
.
save
()
...
...
@@ -643,6 +649,7 @@ class ProductList(generics.ListCreateAPIView):
)
class
ProductDetail
(
generics
.
RetrieveUpdateDestroyAPIView
):
permission_classes
=
[
api_permissions
.
IsAdminUserOrReadOnly
,
...
...
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