Fakultas Ilmu Komputer UI

Commit a19d8f95 authored by Muhammad Ariq Basyar's avatar Muhammad Ariq Basyar
Browse files

Merge branch 'dev-ariq-fix' into 'development'

[CHORE] fix cant add fasilitas

See merge request !73
parents 54f031be 8bd88964
Pipeline #82011 passed with stages
in 7 minutes and 34 seconds
from rest_framework import serializers
from .models import Lokasi, Fasilitas, Kegiatan, \
KomentarKegiatan, FotoKegiatan, Likes, Dislikes
KomentarKegiatan, FotoKegiatan, Likes, Dislikes, JENIS_DISABILITAS
import pytz
TIMEZONE_INDONESIA = {
......@@ -43,6 +43,9 @@ class FasilitasSerializer(serializers.ModelSerializer):
class FasilitasSerializerWrite(FasilitasSerializer):
disabilitas = serializers.MultipleChoiceField(required=True,
choices=JENIS_DISABILITAS)
class Meta:
model = FasilitasSerializer.Meta.model
fields = FasilitasSerializer.Meta.fields + ('lokasi', 'user')
......@@ -56,6 +59,13 @@ class FasilitasSerializerWrite(FasilitasSerializer):
'jumlah': {"required": True},
}
def to_internal_value(self, data):
parsed_data = data.copy()
input_disabilitas = parsed_data.get('disabilitas')
if input_disabilitas is not None:
parsed_data['disabilitas'] = input_disabilitas.split()
return super().to_internal_value(parsed_data)
class FasilitasSerializerRead(FasilitasSerializer):
place_id = serializers.CharField(source='lokasi.place_id', 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