Fakultas Ilmu Komputer UI

Commit 4f2fb5de authored by Muhammad Ariq Basyar's avatar Muhammad Ariq Basyar
Browse files

Merge branch 'development' into PBI-10-edit_profile

parents e676f6e2 c54ba8bb
......@@ -2,11 +2,11 @@ from django.contrib import admin, messages
from django.utils.translation import gettext_lazy as _
from notification.utils import send_komentar_notification, get_target_fcm_device
from .models import Lokasi, Fasilitas, Komentar, Kegiatan, KomentarKegiatan, FotoKegiatan
from .models import Lokasi, Fasilitas, KomentarFasilitas, Kegiatan, KomentarKegiatan, FotoKegiatan
class KomentarAdmin(admin.ModelAdmin):
list_display = ('__str__', 'user', 'notify_to')
list_display = ('__str__', 'user', 'created', 'notify_to')
actions = ('send_notification',)
def send_notification(self, request, queryset):
......@@ -30,7 +30,7 @@ class KomentarAdmin(admin.ModelAdmin):
# Register your models here.
admin.site.register(Lokasi)
admin.site.register(Fasilitas)
admin.site.register(Komentar, KomentarAdmin)
admin.site.register(KomentarFasilitas, KomentarAdmin)
admin.site.register(Kegiatan)
admin.site.register(KomentarKegiatan, KomentarAdmin)
admin.site.register(FotoKegiatan)
# Generated by Django 3.1.7 on 2021-05-31 10:03
from django.conf import settings
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('informasi_fasilitas', '0016_kegiatan_links'),
]
operations = [
migrations.RenameModel(
old_name='Komentar',
new_name='KomentarFasilitas',
),
migrations.RenameField(
model_name='komentarfasilitas',
old_name='date_time',
new_name='created',
),
]
# Generated by Django 3.1.7 on 2021-05-31 12:02
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('informasi_fasilitas', '0017_auto_20210531_1003'),
]
operations = [
migrations.RenameField(
model_name='komentarfasilitas',
old_name='fasilitas',
new_name='informasi',
),
migrations.RenameField(
model_name='komentarkegiatan',
old_name='kegiatan',
new_name='informasi',
),
]
# Generated by Django 3.1.7 on 2021-05-31 12:41
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('informasi_fasilitas', '0018_auto_20210531_1202'),
('informasi_fasilitas', '0019_auto_20210527_2251'),
]
operations = [
]
......@@ -46,9 +46,9 @@ JENIS_DISABILITAS = (
)
TIMEZONE_INDONESIA = (
('WIB', 'Disabilitas Fisik'),
('WITA', 'Disabilitas Mental'),
('WIT', 'Disabilitas Intelektual'),
('WIB', 'WIB'),
('WITA', 'WITA'),
('WIT', 'WIT'),
)
def _default_lokasi_place_id():
......@@ -97,14 +97,19 @@ class Kegiatan(models.Model):
class Komentar(models.Model):
objects = models.Manager()
fasilitas = models.ForeignKey(Fasilitas, on_delete=models.CASCADE)
user = models.ForeignKey(User, on_delete=models.CASCADE)
date_time = models.DateTimeField(auto_now_add=True)
deskripsi = models.TextField()
created = models.DateTimeField(auto_now_add=True)
class Meta:
abstract = True
def __str__(self):
return self.deskripsi
class KomentarFasilitas(Komentar):
informasi = models.ForeignKey(Fasilitas, on_delete=models.CASCADE)
class Likes(models.Model):
objects = models.Manager()
user = models.ForeignKey(User, on_delete=models.CASCADE)
......@@ -117,15 +122,8 @@ class Dislikes(models.Model):
fasilitas = models.ForeignKey(Fasilitas, on_delete=models.CASCADE)
created = models.DateTimeField(auto_now_add=True)
class KomentarKegiatan(models.Model):
objects = models.Manager()
user = models.ForeignKey(User, on_delete=models.CASCADE)
kegiatan = models.ForeignKey(Kegiatan, on_delete=models.CASCADE)
deskripsi = models.TextField()
created = models.DateTimeField(auto_now_add=True)
def __str__(self):
return self.deskripsi
class KomentarKegiatan(Komentar):
informasi = models.ForeignKey(Kegiatan, on_delete=models.CASCADE)
class FotoKegiatan(models.Model):
objects = models.Manager()
......
......@@ -74,7 +74,7 @@ class KegiatanSerializerRead(KegiatanSerializer):
time = obj.time_start
zona_waktu = obj.zona_waktu
time = time_converter(time, zona_waktu)
return time.strftime('%Y-%m-%dT%H:%M%z')
return time.strftime('%Y-%m-%d %H:%M')
def get_time_end(self, obj):
time = obj.time_end
......@@ -82,11 +82,10 @@ class KegiatanSerializerRead(KegiatanSerializer):
if time is None:
return None
time = time_converter(time, zona_waktu)
return time.strftime('%Y-%m-%dT%H:%M%z')
return time.strftime('%Y-%m-%d %H:%M')
class KomentarKegiatanSerializer(serializers.ModelSerializer):
kegiatan = serializers.IntegerField(source='kegiatan.id', read_only=True)
kegiatan = serializers.IntegerField(source='informasi.id', read_only=True)
creator = serializers.CharField(source='user.last_name', read_only=True)
creator_email = serializers.CharField(source='user.email', read_only=True)
......
......@@ -37,7 +37,8 @@ class TestAdmin(TestCase):
def test_list_display(self):
list_display = self.komentar_admin.get_list_display(request)
self.assertEqual(list_display, ('__str__', 'user', 'notify_to'))
self.assertEqual(list_display, ('__str__', 'user', 'created',
'notify_to'))
def test_list_actions(self):
list_action = self.komentar_admin.get_action_choices(request)
......
......@@ -12,7 +12,7 @@ from django.core.files.base import ContentFile
from .models import (
Lokasi,
Fasilitas,
Komentar,
KomentarFasilitas,
KURSI_RODA,
Likes,
Dislikes,
......@@ -58,15 +58,15 @@ class InformasiFasilitasTest(TestCase):
time_end = timezone.now() + timedelta(days=2)
time_start_zone = {
"WIB": time_start.astimezone(TIMEZONE_INDONESIA["WIB"]).strftime("%Y-%m-%dT%H:%M%z"),
"WITA": time_start.astimezone(TIMEZONE_INDONESIA["WITA"]).strftime("%Y-%m-%dT%H:%M%z"),
"WIT": time_start.astimezone(TIMEZONE_INDONESIA["WIT"]).strftime("%Y-%m-%dT%H:%M%z"),
"WIB": time_start.astimezone(TIMEZONE_INDONESIA["WIB"]).strftime("%Y-%m-%d %H:%M%z"),
"WITA": time_start.astimezone(TIMEZONE_INDONESIA["WITA"]).strftime("%Y-%m-%d %H:%M%z"),
"WIT": time_start.astimezone(TIMEZONE_INDONESIA["WIT"]).strftime("%Y-%m-%d %H:%M%z"),
}
time_end_zone = {
"WIB": time_end.astimezone(TIMEZONE_INDONESIA["WIB"]).strftime("%Y-%m-%dT%H:%M%z"),
"WITA": time_end.astimezone(TIMEZONE_INDONESIA["WITA"]).strftime("%Y-%m-%dT%H:%M%z"),
"WIT": time_end.astimezone(TIMEZONE_INDONESIA["WIT"]).strftime("%Y-%m-%dT%H:%M%z"),
"WIB": time_end.astimezone(TIMEZONE_INDONESIA["WIB"]).strftime("%Y-%m-%d %H:%M%z"),
"WITA": time_end.astimezone(TIMEZONE_INDONESIA["WITA"]).strftime("%Y-%m-%d %H:%M%z"),
"WIT": time_end.astimezone(TIMEZONE_INDONESIA["WIT"]).strftime("%Y-%m-%d %H:%M%z"),
}
# mock_kegiatan_test = {
......@@ -257,10 +257,10 @@ class InformasiFasilitasTest(TestCase):
fasilitas_dict=fasilitas_dict,
)
return Komentar.objects.create(
return KomentarFasilitas.objects.create(
**komentar_dict,
user=user,
fasilitas=fasilitas,
informasi=fasilitas,
)
def create_likes_test(
......@@ -364,19 +364,19 @@ class InformasiFasilitasTest(TestCase):
user=None,
komentar_kegiatan_dict=mock_komentar_kegiatan_test,
user_dict=mock_user_test,
kegiatan=None
informasi=None
):
user = self.get_or_create_user_test(
user=user,
user_dict=user_dict,
)
if kegiatan is None:
kegiatan = self.create_kegiatan_test()
if informasi is None:
informasi = self.create_kegiatan_test()
return KomentarKegiatan.objects.create(
**komentar_kegiatan_dict,
kegiatan=kegiatan,
informasi=informasi,
user=user
)
......
from django.db.utils import IntegrityError
from .test_base import InformasiFasilitasTest
from .models import (Lokasi, Fasilitas, Komentar, Likes, Dislikes,
from .models import (Lokasi, Fasilitas, KomentarFasilitas, Likes, Dislikes,
Kegiatan, FotoKegiatan, KomentarKegiatan)
......@@ -49,13 +49,13 @@ class InformasiFasilitasModelTest(InformasiFasilitasTest):
def test_models_komentar_not_created(self):
with self.assertRaises(IntegrityError) as ex:
obj = Komentar(fasilitas=None)
obj = KomentarFasilitas(informasi=None)
obj.save()
self.assertEqual(ex.expected, IntegrityError)
def test_models_create_new_komentar(self):
self.create_komentar_test()
count = Komentar.objects.all().count()
count = KomentarFasilitas.objects.all().count()
self.assertNotEqual(count, 0)
def test_models_komentar_str(self):
......
......@@ -22,6 +22,8 @@ class KegiatanRelatedViewTest(InformasiFasilitasViewTest):
super().setUp()
self.media_root = os.path.join(settings.BASE_DIR, 'test_file/media')
self.kegiatan = self.create_kegiatan_test(self.user, self.lokasi)
self.kegiatan_time_start = self.kegiatan.time_start[:16]
self.kegiatan_time_end = self.kegiatan.time_end[:16]
self.kwargs_place_id = {'place_id': self.lokasi.place_id}
self.kwargs_add_or_update_kegiatan = {
'place_id': self.lokasi.place_id,
......@@ -102,7 +104,9 @@ class KegiatanRelatedViewTest(InformasiFasilitasViewTest):
expected_json = self.mock_kegiatan_test.copy()
expected_json.update({'creator': 'mock last_name',
'place_id': 'mock_place_id',
'creator_email': self.mock_user_test['email']
'creator_email': self.mock_user_test['email'],
'time_start': self.kegiatan_time_start,
'time_end': self.kegiatan_time_end})
})
self.assertEqual(response.status_code, HTTPStatus.CREATED)
self.assertDictEqual(data, expected_json)
......@@ -138,15 +142,15 @@ class KegiatanRelatedViewTest(InformasiFasilitasViewTest):
'place_id': self.kegiatan.lokasi.place_id,
'creator': self.kegiatan.user.last_name,
'creator_email': self.kegiatan.user.email,
'nama_kegiatan' : self.kegiatan.nama_kegiatan,
'nama_kegiatan': self.kegiatan.nama_kegiatan,
'penyelenggara': self.kegiatan.penyelenggara,
'deskripsi': self.kegiatan.deskripsi,
'links': self.kegiatan.links,
'nama_kontak': self.kegiatan.nama_kontak,
'nomor_kontak': self.kegiatan.nomor_kontak,
'zona_waktu': self.kegiatan.zona_waktu,
'time_start': self.kegiatan.time_start,
'time_end': self.kegiatan.time_end,
'time_start': self.kegiatan_time_start,
'time_end': self.kegiatan_time_end,
},
}
self.assertEqual(content, expected_json)
......@@ -159,7 +163,7 @@ class KegiatanRelatedViewTest(InformasiFasilitasViewTest):
'id': self.kegiatan.id,
'place_id': self.kegiatan.lokasi.place_id,
'creator': self.kegiatan.user.last_name,
'creator_email': self.kegiatan.user.email,
'creator_email': kegiatan_wita.user.email,
'nama_kegiatan': self.kegiatan.nama_kegiatan,
'penyelenggara': self.kegiatan.penyelenggara,
'deskripsi': self.kegiatan.deskripsi,
......@@ -167,8 +171,8 @@ class KegiatanRelatedViewTest(InformasiFasilitasViewTest):
'nama_kontak': self.kegiatan.nama_kontak,
'nomor_kontak': self.kegiatan.nomor_kontak,
'zona_waktu': self.kegiatan.zona_waktu,
'time_start': self.kegiatan.time_start,
'time_end': self.kegiatan.time_end,
'time_start': self.kegiatan_time_start,
'time_end': self.kegiatan_time_end,
}
self.assertEqual(content, expected_json)
......@@ -196,8 +200,8 @@ class KegiatanRelatedViewTest(InformasiFasilitasViewTest):
'nama_kontak': kegiatan_wita.nama_kontak,
'nomor_kontak': kegiatan_wita.nomor_kontak,
'zona_waktu': kegiatan_wita.zona_waktu,
'time_start': kegiatan_wita.time_start,
'time_end': kegiatan_wita.time_end,
'time_start': kegiatan_wita.time_start[:16],
'time_end': kegiatan_wita.time_end[:16],
}
self.assertDictEqual(content, expected_json)
......@@ -225,8 +229,8 @@ class KegiatanRelatedViewTest(InformasiFasilitasViewTest):
'nama_kontak': kegiatan_wit.nama_kontak,
'nomor_kontak': kegiatan_wit.nomor_kontak,
'zona_waktu': kegiatan_wit.zona_waktu,
'time_start': kegiatan_wit.time_start,
'time_end': kegiatan_wit.time_end,
'time_start': kegiatan_wit.time_start[:16],
'time_end': kegiatan_wit.time_end[:16],
}
self.assertDictEqual(content, expected_json)
......@@ -246,8 +250,8 @@ class KegiatanRelatedViewTest(InformasiFasilitasViewTest):
'nama_kontak': self.kegiatan.nama_kontak,
'nomor_kontak': self.kegiatan.nomor_kontak,
'zona_waktu': self.kegiatan.zona_waktu,
'time_start': self.kegiatan.time_start,
'time_end': self.kegiatan.time_end,
'time_start': self.kegiatan_time_start,
'time_end': self.kegiatan_time_end,
}
self.assertEqual(content, expected_json)
......@@ -270,8 +274,11 @@ class KegiatanRelatedViewTest(InformasiFasilitasViewTest):
expected_json = self.mock_kegiatan_test.copy()
expected_json.update({'creator': 'mock last_name',
'place_id': 'mock_place_id',
'creator_email': self.mock_user_test['email']
'creator_email': self.mock_user_test['email'],
'time_start': self.kegiatan_time_start,
'time_end': self.kegiatan_time_end})
})
send_data.pop("images")
expected_json.update(send_data)
self.assertEqual(response.status_code, HTTPStatus.ACCEPTED)
......@@ -323,8 +330,8 @@ class KegiatanRelatedViewTest(InformasiFasilitasViewTest):
'nama_kontak': self.kegiatan.nama_kontak,
'nomor_kontak': self.kegiatan.nomor_kontak,
'zona_waktu': self.kegiatan.zona_waktu,
'time_start': self.kegiatan.time_start,
'time_end': self.kegiatan.time_end,
'time_start': self.kegiatan_time_start,
'time_end': self.kegiatan_time_end,
},
}
self.assertEqual(content, expected_json)
......@@ -385,9 +392,9 @@ class KegiatanRelatedViewTest(InformasiFasilitasViewTest):
response_id_in_order = list(content.keys())
self.assertEqual(content[base_mock_id]['time_start'],
self.kegiatan.time_start)
self.kegiatan_time_start)
self.assertEqual(content[ordered_time_mock_id]['time_start'],
self.mock_kegiatan_time_order_test['time_start'])
self.mock_kegiatan_time_order_test['time_start'][:16])
self.assertEqual(response_id_in_order[0], base_mock_id)
self.assertEqual(response_id_in_order[1], ordered_time_mock_id)
......
......@@ -3,7 +3,8 @@ from django.urls import reverse
from pplbackend.utils import response_decode
from .test_base import InformasiFasilitasViewTest
from .models import Komentar
from .models import KomentarFasilitas
from pplbackend.utils import response_decode
from .views import TIME_FORMAT
......@@ -25,7 +26,7 @@ class KomentarRelatedViewTest(InformasiFasilitasViewTest):
self.client.post(self.add_komentar_url, self.mock_komentar_test)
self.assertEqual(response.status_code, HTTPStatus.CREATED)
count = Komentar.objects.filter(fasilitas=self.fasilitas).count()
count = KomentarFasilitas.objects.filter(informasi=self.fasilitas).count()
self.assertEqual(count, 1)
def test_cannot_comment_facility_if_deskripsi_empty(self):
......@@ -48,7 +49,7 @@ class KomentarRelatedViewTest(InformasiFasilitasViewTest):
'deskripsi': komentar.deskripsi,
'creator': komentar.user.last_name,
'creator_email': komentar.user.email,
'date_time': komentar.date_time.strftime(TIME_FORMAT),
'created': komentar.created.strftime(TIME_FORMAT),
}
}
self.assertEqual(response_json, expected_json)
......@@ -29,7 +29,7 @@ class KomentarKegiatanRelatedViewTest(InformasiFasilitasViewTest):
self.client.post(self.add_komentar_kegiatan_url, self.mock_komentar_kegiatan_test)
self.assertEqual(response.status_code, HTTPStatus.CREATED)
count = KomentarKegiatan.objects.filter(kegiatan=self.kegiatan).count()
count = KomentarKegiatan.objects.filter(informasi=self.kegiatan).count()
self.assertEqual(count, 1)
def test_fail_add_komentar_kegiatan(self):
......@@ -38,18 +38,18 @@ class KomentarKegiatanRelatedViewTest(InformasiFasilitasViewTest):
self.client.post(self.add_komentar_kegiatan_url, None)
self.assertEqual(response.status_code, HTTPStatus.NOT_FOUND)
count = KomentarKegiatan.objects.filter(kegiatan=self.kegiatan).count()
count = KomentarKegiatan.objects.filter(informasi=self.kegiatan).count()
self.assertEqual(count, 0)
def test_can_get_list_komentar_kegiatan(self):
komentar = self.create_komentar_kegiatan_test(user=self.user, kegiatan=self.kegiatan)
komentar = self.create_komentar_kegiatan_test(user=self.user, informasi=self.kegiatan)
response = self.client.get(self.list_komentar_kegiatan_url)
self.assertEqual(response.status_code, HTTPStatus.OK)
response_json = response_decode(response)
expected_id = komentar.id
expected_creator = komentar.user.last_name
expected_kegiatan = komentar.kegiatan.id
expected_kegiatan = komentar.informasi.id
expected_deskripsi = komentar.deskripsi
self.assertEqual(response_json[str(komentar.id)]['id'], expected_id)
......@@ -59,7 +59,7 @@ class KomentarKegiatanRelatedViewTest(InformasiFasilitasViewTest):
self.assertEqual(True, ('created' in response_json[str(komentar.id)].keys()))
def test_can_get_komentar_kegiatan(self):
komentar = self.create_komentar_kegiatan_test(user=self.user, kegiatan=self.kegiatan)
komentar = self.create_komentar_kegiatan_test(user=self.user, informasi=self.kegiatan)
kwargs_get_komentar_kegiatan = {
'place_id': self.lokasi.place_id,
'kegiatan_id': self.kegiatan.id,
......@@ -73,7 +73,7 @@ class KomentarKegiatanRelatedViewTest(InformasiFasilitasViewTest):
response_json = response_decode(response)
expected_id = komentar.id
expected_creator = komentar.user.last_name
expected_kegiatan = komentar.kegiatan.id
expected_kegiatan = komentar.informasi.id
expected_deskripsi = komentar.deskripsi
self.assertEqual(response_json['id'], expected_id)
......@@ -88,7 +88,7 @@ class KomentarKegiatanRelatedViewTest(InformasiFasilitasViewTest):
def test_can_delete_komentar_kegiatan(self):
KomentarKegiatan.objects.all().delete()
komentar = self.create_komentar_kegiatan_test(user=self.user, kegiatan=self.kegiatan)
komentar = self.create_komentar_kegiatan_test(user=self.user, informasi=self.kegiatan)
kwargs_delete_komentar_kegiatan = {
'place_id': self.lokasi.place_id,
......@@ -102,7 +102,7 @@ class KomentarKegiatanRelatedViewTest(InformasiFasilitasViewTest):
response = self.client.delete(delete_komentar_kegiatan_url)
self.assertEqual(response.status_code, HTTPStatus.OK)
count = KomentarKegiatan.objects.filter(kegiatan=self.kegiatan).count()
count = KomentarKegiatan.objects.filter(informasi=self.kegiatan).count()
self.assertEqual(count, 0)
def test_fail_delete_komentar_kegiatan(self):
......
......@@ -39,6 +39,9 @@ urlpatterns = [
path('lokasi/kegiatan-terdekat',
views_kegiatan.nearest_kegiatan, name='nearest-kegiatan'),
path('lokasi/search-kegiatan',
views_kegiatan.search_kegiatan, name='search-kegiatan'),
path('lokasi/search-kegiatan/<str:query>',
views_kegiatan.search_kegiatan, name='search-kegiatan'),
......@@ -50,22 +53,22 @@ urlpatterns = [
path('lokasi/list-foto-kegiatan/<str:place_id>/<int:kegiatan_id>',
views_kegiatan.list_foto_kegiatan, name='list-foto-kegiatan'),
path('lokasi/list-kegiatan-by-latest-added/<int:start_index>/<int:query_limit>',
views_kegiatan.list_kegiatan_by_latest_added, name='list-kegiatan-by-latest-added'),
path('lokasi/list-kegiatan-by-latest-added/<int:start_index>',
views_kegiatan.list_kegiatan_by_latest_added, name='list-kegiatan-by-latest-added'),
path('lokasi/list-kegiatan-by-name/<int:start_index>/<int:query_limit>',
views_kegiatan.list_kegiatan_by_name, name='list-kegiatan-by-name'),
path('lokasi/list-kegiatan-by-name/<int:start_index>',
views_kegiatan.list_kegiatan_by_name, name='list-kegiatan-by-name'),
path('lokasi/list-kegiatan-by-time/<int:start_index>/<int:query_limit>',
views_kegiatan.list_kegiatan_by_time, name='list-kegiatan-by-time'),
path('lokasi/list-kegiatan-by-time/<int:start_index>',
views_kegiatan.list_kegiatan_by_time, name='list-kegiatan-by-time'),
......
......@@ -9,7 +9,7 @@ from rest_framework import viewsets
from notification.utils import send_komentar_notification
from .serializers import LokasiSerializer
from .models import Lokasi, Fasilitas, Komentar, Likes, Dislikes
from .models import Lokasi, Fasilitas, KomentarFasilitas, Likes, Dislikes
from .permissions import UserPermission
TIME_FORMAT = "%d-%m-%Y %H:%M:%S"
......@@ -242,13 +242,13 @@ def add_komentar(request, place_id, id):
lokasi = Lokasi.objects.get(place_id=place_id)
fasilitas = Fasilitas.objects.get(lokasi=lokasi, id=id)
deskripsi = request.POST['deskripsi']
komentar = Komentar.objects.create(fasilitas=fasilitas,
komentar = KomentarFasilitas.objects.create(informasi=fasilitas,
user=request.user,
deskripsi=deskripsi)
send_komentar_notification(komentar)
return JsonResponse({'response': 'komentar added',
'id': komentar.id,
"created_date": komentar.date_time.strftime(TIME_FORMAT)}, status=HTTPStatus.CREATED)
"created_date": komentar.created.strftime(TIME_FORMAT)}, status=HTTPStatus.CREATED)
except KeyError as e:
return JsonResponse({'response': missing_key_message(str(e))}, status=HTTPStatus.BAD_REQUEST)
except Exception as e:
......@@ -262,7 +262,7 @@ def list_komentar(request, place_id, id):
try:
lokasi = Lokasi.objects.get(place_id=place_id)
fasilitas = Fasilitas.objects.get(lokasi=lokasi, id=id)
list_komentar = Komentar.objects.filter(fasilitas=fasilitas)
list_komentar = KomentarFasilitas.objects.filter(informasi=fasilitas)
return_json = {}
for komentar in list_komentar:
return_json[komentar.id] = {}
......@@ -271,7 +271,7 @@ def list_komentar(request, place_id, id):
komentar_details["deskripsi"] = komentar.deskripsi
komentar_details["creator"] = komentar.user.last_name
komentar_details["creator_email"] = komentar.user.email
komentar_details["date_time"] = komentar.date_time.strftime(
komentar_details["created"] = komentar.created.strftime(
TIME_FORMAT)
return JsonResponse(return_json, status=HTTPStatus.OK)
except KeyError as key:
......
......@@ -98,7 +98,7 @@ def list_foto_kegiatan(request, place_id, kegiatan_id):
@api_view(['GET'])
@authentication_classes([])
@permission_classes([])
def search_kegiatan(request, query):
def search_kegiatan(request, query=''):
query_by_nama = Kegiatan.objects.filter(nama_kegiatan__icontains=query)
query_by_deskripsi = Kegiatan.objects.filter(deskripsi__icontains=query)
query_by_penyelenggara = Kegiatan.objects.filter(penyelenggara__icontains=query)
......
......@@ -15,7 +15,7 @@ from .models import Kegiatan, KomentarKegiatan
@permission_classes([])
def list_komentar_kegiatan(request, place_id, kegiatan_id):
try:
queryset = KomentarKegiatan.objects.filter(kegiatan__lokasi__place_id=place_id, kegiatan__id=kegiatan_id)
queryset = KomentarKegiatan.objects.filter(informasi__lokasi__place_id=place_id, informasi__id=kegiatan_id)
serializer = KomentarKegiatanSerializer(queryset, many=True)
data_response = serializer.data
new_dict = {item['id']: dict(item) for item in data_response}
......@@ -28,8 +28,8 @@ def list_komentar_kegiatan(request, place_id, kegiatan_id):
@permission_classes([])