Fakultas Ilmu Komputer UI

Commit f5e722ad authored by Bimo Iman Smartadi's avatar Bimo Iman Smartadi
Browse files

Revert "Merge branch 'staging' into 'PBI-6-melihat_halaman_detail_fasilitas_publik'"

This reverts commit 91cc7744, reversing
changes made to 7ccccacd.
parent 7d2eae76
Pipeline #44963 canceled with stages
in 8 minutes and 50 seconds
......@@ -251,3 +251,20 @@ Make `POST` request to API endpoint `/layanan-khusus/penyandang/register/` with
* `nama_wali` : name of parent/guardian
* `alamat_wali` : address of parent/guardian
* `telp_wali` : phone number of parent/guardian
### 17. To add a comment an a facility:
Make `POST` request to API endpoint `/informasi-fasilitas/lokasi/add-komentar/*nama_lokasi*/*id_fasilitas*/`. <br>
with key:
* `deskripsi` : The comment message
<b>Make sure you have token it your request header.</b>
<b>Add this to your request header. `Authorization` with value `token *your_token_from_request*`</b>
### 18. To view a comment list on a facility:
Make `GET` request to API endpoint `/informasi-fasilitas/lokasi/list-komentar/*nama_lokasi*/*id_fasilitas*/`. <br>
It will return a json with these key:
* `*int*` : The index of the model, with dictionary of Komentar model with key below
* `id` : The id of the comment
* `deskripsi` : The description of the comment
* `creator` : The last name of the commentator
* `date_time` : The time when the comment was posted
from django.contrib import admin
from .models import Sekolah, Penyandang
from .models import Sekolah
# Register your models here.
admin.site.register(Sekolah)
admin.site.register(Penyandang)
# Generated by Django 2.1.5 on 2020-05-03 04:13
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('layanan_khusus', '0011_auto_20200430_1308'),
]
operations = [
migrations.CreateModel(
name='Penyandang',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
],
),
migrations.AlterField(
model_name='sekolah',
name='jenis_sekolah',
field=models.CharField(choices=[('IK', 'Inklusi'), ('SG', 'Segregasi')], default='IK', max_length=2),
),
]
# Generated by Django 2.1.5 on 2020-05-03 04:34
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('layanan_khusus', '0012_auto_20200503_1113'),
]
operations = [
migrations.AddField(
model_name='penyandang',
name='alamat',
field=models.CharField(default='empty', max_length=100),
preserve_default=False,
),
migrations.AddField(
model_name='penyandang',
name='name',
field=models.CharField(default='empty', max_length=50),
preserve_default=False,
),
migrations.AddField(
model_name='penyandang',
name='no_telp',
field=models.CharField(default='empty', max_length=16),
preserve_default=False,
),
]
# Generated by Django 2.1.5 on 2020-05-03 13:44
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('layanan_khusus', '0013_auto_20200503_1134'),
]
operations = [
migrations.AddField(
model_name='penyandang',
name='tanggal_lahir',
field=models.DateField(default=django.utils.timezone.now),
preserve_default=False,
),
migrations.AddField(
model_name='penyandang',
name='tempat_lahir',
field=models.CharField(default='empty', max_length=50),
preserve_default=False,
),
]
# Generated by Django 2.1.5 on 2020-05-03 18:16
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('layanan_khusus', '0014_auto_20200503_2044'),
]
operations = [
migrations.AddField(
model_name='penyandang',
name='kategori',
field=models.CharField(choices=[('FS', 'Fisik'), ('IN', 'Intelektual'), ('MN', 'Mental'), ('SN', 'Sensorik')], default='FS', max_length=2),
),
migrations.AddField(
model_name='penyandang',
name='pekerjaan',
field=models.CharField(choices=[('PT', 'Petani'), ('BR', 'Buruh'), ('WS', 'Pedagang/Wiraswasta'), ('JS', 'Jasa'), ('PN', 'PNS/TNI/POLRI'), ('SN', 'Pensiunan'), ('IR', 'Ibu Rumah Tangga'), ('PL', 'Pelajar'), ('LA', 'Lainnya'), ('NA', 'Tidak Bekerja')], default='NA', max_length=2),
),
migrations.AddField(
model_name='penyandang',
name='pendidikan',
field=models.CharField(choices=[('SD', 'SD'), ('MP', 'SMP/SLTP'), ('MA', 'SMA/SLTA'), ('D1', 'Diploma 1'), ('D2', 'Diploma 2'), ('D3', 'Diploma 3'), ('S1', 'Sarjana'), ('S2', 'Magister'), ('S3', 'Doktor'), ('NF', 'Non-Formal/Lainnya'), ('NA', 'Tidak Sekolah')], default='NA', max_length=2),
),
]
# Generated by Django 2.1.5 on 2020-05-03 18:36
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('layanan_khusus', '0015_auto_20200504_0116'),
]
operations = [
migrations.AddField(
model_name='penyandang',
name='jenis_kelamin',
field=models.CharField(choices=[('LAKI-LAKI', 'Laki-Laki'), ('PEREMPUAN', 'Perempuan')], default='LAKI-LAkI', max_length=9),
),
]
# Generated by Django 2.1.5 on 2020-05-03 18:51
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('layanan_khusus', '0016_penyandang_jenis_kelamin'),
]
operations = [
migrations.AddField(
model_name='penyandang',
name='email',
field=models.CharField(max_length=50, null=True),
),
migrations.AlterField(
model_name='penyandang',
name='no_telp',
field=models.CharField(max_length=16, null=True),
),
]
# Generated by Django 2.1.5 on 2020-05-03 19:08
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('layanan_khusus', '0017_auto_20200504_0151'),
]
operations = [
migrations.AddField(
model_name='penyandang',
name='alamat_wali',
field=models.CharField(max_length=100, null=True),
),
migrations.AddField(
model_name='penyandang',
name='nama_wali',
field=models.CharField(max_length=50, null=True),
),
migrations.AddField(
model_name='penyandang',
name='telp_wali',
field=models.CharField(max_length=16, null=True),
),
]
......@@ -2,14 +2,19 @@ from django.db import models
class Sekolah(models.Model):
SWASTA = "SW"
NEGRI = "NG"
INTERNASIONAL = "IT"
INKLUSI = "IK"
SEGREGASI = "SG"
STATUS_SEKOLAH = (
("SW", "Swasta"),
("NG", "Negri"),
("IT", "Internasional")
(SWASTA, "Swasta"),
(NEGRI, "Negri"),
(INTERNASIONAL, "Internasional")
)
JENIS = (
("IK", "Inklusi"),
("SG", "Segregasi")
(INKLUSI, "Inklusi"),
(SEGREGASI, "Segregasi")
)
name = models.CharField(max_length=50)
alamat = models.CharField(max_length=100)
......@@ -19,79 +24,11 @@ class Sekolah(models.Model):
status = models.CharField(
max_length=2,
choices=STATUS_SEKOLAH,
default="SW"
default=SWASTA
)
jenis_sekolah = models.CharField(
max_length=2,
choices=JENIS,
default="IK"
default=INKLUSI
)
akreditasi = models.CharField(max_length=1, null=True, default=None)
class Penyandang(models.Model):
JENIS_KELAMIN_OPTION = (
("LAKI-LAKI", "Laki-Laki"),
("PEREMPUAN", "Perempuan")
)
PENDIDIKAN_TERAKHIR = (
("SD", "SD"),
("MP", "SMP/SLTP"),
("MA", "SMA/SLTA"),
("D1", "Diploma 1"),
("D2", "Diploma 2"),
("D3", "Diploma 3"),
("S1", "Sarjana"),
("S2", "Magister"),
("S3", "Doktor"),
("NF", "Non-Formal/Lainnya"),
("NA", "Tidak Sekolah")
)
PEKERJAAN_OPTION = (
("PT", "Petani"),
("BR", "Buruh"),
("WS", "Pedagang/Wiraswasta"),
("JS", "Jasa"),
("PN", "PNS/TNI/POLRI"),
("SN", "Pensiunan"),
("IR", "Ibu Rumah Tangga"),
("PL", "Pelajar"),
("LA", "Lainnya"),
("NA", "Tidak Bekerja")
)
KATEGORI_DISABILITAS = (
("FS", "Fisik"),
("IN", "Intelektual"),
("MN", "Mental"),
("SN", "Sensorik")
)
name = models.CharField(max_length=50)
alamat = models.CharField(max_length=100)
tempat_lahir = models.CharField(max_length=50)
tanggal_lahir = models.DateField()
jenis_kelamin = models.CharField(
max_length=9,
choices=JENIS_KELAMIN_OPTION,
default="LAKI-LAkI"
)
pendidikan = models.CharField(
max_length=2,
choices=PENDIDIKAN_TERAKHIR,
default="NA"
)
pekerjaan = models.CharField(
max_length=2,
choices=PEKERJAAN_OPTION,
default="NA"
)
kategori = models.CharField(
max_length=2,
choices=KATEGORI_DISABILITAS,
default="FS"
)
no_telp = models.CharField(max_length=16, null=True)
email = models.CharField(max_length=50, null=True)
nama_wali = models.CharField(max_length=50, null=True)
alamat_wali = models.CharField(max_length=100, null=True)
telp_wali = models.CharField(max_length=16, null=True)
from rest_framework import serializers
from .models import Sekolah, Penyandang
from .models import Sekolah
class SekolahSerializer(serializers.HyperlinkedModelSerializer):
......@@ -16,24 +16,3 @@ class SekolahSerializer(serializers.HyperlinkedModelSerializer):
'jenis_sekolah',
'akreditasi'
)
class PenyandangSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = Penyandang
fields = (
'id',
'name',
'alamat',
'tempat_lahir',
'tanggal_lahir',
'jenis_kelamin',
'pendidikan',
'pekerjaan',
'kategori',
'no_telp',
'email',
'nama_wali',
'alamat_wali',
'telp_wali'
)
......@@ -3,111 +3,45 @@ from http import HTTPStatus
from django.test import TestCase, Client
from django.db.utils import IntegrityError
from django.urls import path, include, reverse
from .models import Sekolah, Penyandang
from .models import Sekolah
from .serializers import SekolahSerializer
NOT_NULL_CONSTRAINT_FAILED_MESSAGE = 'NOT NULL constraint failed'
ID = 'id'
NAME = 'name'
ALAMAT = 'alamat'
NO_TELP = 'no_telp'
WEBSITE = 'website'
JUMLAH_SISWA = 'jumlah_siswa'
STATUS = 'status'
JENIS_SEKOLAH = 'jenis_sekolah'
AKREDITASI = 'akreditasi'
MOCK_SEKOLAH = {
MOCK_DATA = {
ID: 1,
NAME: 'Sekolah Cita Buana',
ALAMAT: 'Jl. Paso No.84, Jagakarsa, Jakarta Selatan',
NO_TELP: '(021)7820088',
WEBSITE: 'https://www.sekolahcitabuana.com',
WEBSITE: 'http://www.sekolahcitabuana.com',
JUMLAH_SISWA: 250,
STATUS: 'SW',
JENIS_SEKOLAH: 'IK',
AKREDITASI: 'B'
}
TEMPAT_LAHIR = 'tempat_lahir'
TANGGAL_LAHIR = 'tanggal_lahir'
JENIS_KELAMIN = 'jenis_kelamin'
PENDIDIKAN = 'pendidikan'
PEKERJAAN = 'pekerjaan'
KATEGORI = 'kategori'
EMAIL = 'email'
NAMA_WALI = 'nama_wali'
ALAMAT_WALI = 'alamat_wali'
TELP_WALI = 'telp_wali'
MOCK_PENYANDANG = {
ID: 1,
NAME: 'Nadia Anggraini',
ALAMAT: 'Depok, Jawa Barat',
TEMPAT_LAHIR: 'Depok',
TANGGAL_LAHIR: '1999-02-01',
JENIS_KELAMIN: 'PEREMPUAN',
PENDIDIKAN: 'S1',
PEKERJAAN: 'PL',
KATEGORI: 'FS',
NO_TELP: '082577776666',
EMAIL: 'nadiaag@email.com',
NAMA_WALI: 'wali',
ALAMAT_WALI: 'sama',
TELP_WALI: 'sama'
}
def sekolah_setup():
def setup():
Sekolah.objects.create(
name=MOCK_SEKOLAH[NAME],
alamat=MOCK_SEKOLAH[ALAMAT],
no_telp=MOCK_SEKOLAH[NO_TELP],
website=MOCK_SEKOLAH[WEBSITE],
jumlah_siswa=MOCK_SEKOLAH[JUMLAH_SISWA],
status=MOCK_SEKOLAH[STATUS],
jenis_sekolah=MOCK_SEKOLAH[JENIS_SEKOLAH],
akreditasi=MOCK_SEKOLAH[AKREDITASI]
)
def penyandang_setup():
Penyandang.objects.create(
name=MOCK_PENYANDANG[NAME],
alamat=MOCK_PENYANDANG[ALAMAT],
tempat_lahir=MOCK_PENYANDANG[TEMPAT_LAHIR],
tanggal_lahir=MOCK_PENYANDANG[TANGGAL_LAHIR],
jenis_kelamin=MOCK_PENYANDANG[JENIS_KELAMIN],
pendidikan=MOCK_PENYANDANG[PENDIDIKAN],
pekerjaan=MOCK_PENYANDANG[PEKERJAAN],
kategori=MOCK_PENYANDANG[KATEGORI],
no_telp=MOCK_PENYANDANG[NO_TELP],
email=MOCK_PENYANDANG[EMAIL],
nama_wali=MOCK_PENYANDANG[NAMA_WALI],
alamat_wali=MOCK_PENYANDANG[ALAMAT_WALI],
telp_wali=MOCK_PENYANDANG[TELP_WALI]
name=MOCK_DATA[NAME],
alamat=MOCK_DATA[ALAMAT],
no_telp=MOCK_DATA[NO_TELP],
website=MOCK_DATA[WEBSITE],
jumlah_siswa=MOCK_DATA[JUMLAH_SISWA],
status=MOCK_DATA[STATUS],
jenis_sekolah=MOCK_DATA[JENIS_SEKOLAH],
akreditasi=MOCK_DATA[AKREDITASI]
)
def auth_setup():
email = 'mock_user@email.com'
passcode = 'pass12345'
Client().post('/api/register/', {
'name': 'name',
'email': email,
'phone_number': 000000000,
'password': passcode
})
token_response = Client().post('/api-token-auth/',
{'username': email, 'password': passcode})
content = json.loads(token_response.content.decode('utf-8'))
token = content['token']
return Client(HTTP_AUTHORIZATION='token '+token)
class LayananKhususModelTest(TestCase):
def test_models_sekolah_not_created(self):
......@@ -118,22 +52,10 @@ class LayananKhususModelTest(TestCase):
NOT_NULL_CONSTRAINT_FAILED_MESSAGE))
def test_models_create_new_sekolah(self):
sekolah_setup()
setup()
count = Sekolah.objects.all().count()
self.assertNotEqual(count, 0)
def test_models_penyandang_not_created(self):
with self.assertRaises(IntegrityError) as ex:
obj = Penyandang(name=None)
obj.save()
self.assertTrue(str(ex.exception).startswith(
NOT_NULL_CONSTRAINT_FAILED_MESSAGE))
def test_models_create_new_penyandang(self):
penyandang_setup()
count = Penyandang.objects.all().count()
self.assertNotEqual(count, 0)
class LayananKhususViewsTest(TestCase):
urlpatterns = [
......@@ -141,23 +63,19 @@ class LayananKhususViewsTest(TestCase):
]
def test_sekolah_serializer_valid(self):
serializer = SekolahSerializer(data=MOCK_SEKOLAH)
self.assertTrue(serializer.is_valid)
def test_penyandang_serializer_valid(self):
serializer = SekolahSerializer(data=MOCK_PENYANDANG)
serializer = SekolahSerializer(data=MOCK_DATA)
self.assertTrue(serializer.is_valid)
def test_can_get_list_sekolah(self):
sekolah_setup()
setup()
response = Client().get(reverse('list-sekolah'))
self.assertEqual(response.status_code, HTTPStatus.OK)
def test_get_lokasi_list_json(self):
sekolah_setup()
setup()
response = Client().get(reverse('list-sekolah'))
content = json.loads(response.content.decode('utf-8'))
expected_json = [MOCK_SEKOLAH]
expected_json = [MOCK_DATA]
self.assertEqual(content, expected_json)
def test_cannot_post_list_sekolah(self):
......@@ -165,23 +83,23 @@ class LayananKhususViewsTest(TestCase):
self.assertEqual(response.status_code, HTTPStatus.METHOD_NOT_ALLOWED)
def test_can_get_detail_sekolah(self):
sekolah_setup()
setup()
response = Client().get(
reverse('detail-sekolah', kwargs={'id_sekolah': 1})
)
self.assertEqual(response.status_code, HTTPStatus.OK)
def test_get_details_detail_json(self):
sekolah_setup()
def test_can_get_lokasi_details_json(self):
setup()
response = Client().get(
reverse('detail-sekolah', kwargs={'id_sekolah': 1})
)
content = json.loads(response.content.decode('utf-8'))
expected_json = MOCK_SEKOLAH
expected_json = MOCK_DATA
self.assertEqual(content, expected_json)
def test_cannot_post_detail_sekolah(self):
sekolah_setup()
setup()
response = Client().post(
reverse('detail-sekolah', kwargs={'id_sekolah': 1})
)
......@@ -191,28 +109,3 @@ class LayananKhususViewsTest(TestCase):
response = Client().get(
reverse('detail-sekolah', kwargs={'id_sekolah': 1}))
self.assertEqual(response.status_code, HTTPStatus.NOT_FOUND)
def test_can_post_register_penyandang(self):
client = auth_setup()
response = client.post(reverse('register-penyandang-disabilitas'),
MOCK_PENYANDANG)
self.assertEqual(response.status_code, HTTPStatus.CREATED)
def test_post_register_penyandang_json(self):
client = auth_setup()
response = client.post(reverse('register-penyandang-disabilitas'),
MOCK_PENYANDANG)
content = json.loads(response.content.decode("utf-8"))
expected_json = MOCK_PENYANDANG
self.assertEqual(content, expected_json)
def test_cannot_get_register_penyandang(self):
client = auth_setup()
response = client.get(reverse('register-penyandang-disabilitas'),
MOCK_PENYANDANG)
self.assertEqual(response.status_code, HTTPStatus.METHOD_NOT_ALLOWED)
def test_post_bad_request_register_penyandang(self):
client = auth_setup()
response = client.post(reverse('register-penyandang-disabilitas'))
self.assertEqual(response.status_code, HTTPStatus.BAD_REQUEST)
......@@ -4,7 +4,5 @@ from . import views
urlpatterns = [
path('sekolah/list/', views.list_sekolah, name='list-sekolah'),