Fakultas Ilmu Komputer UI

Commit 1e4a7137 authored by Mika dabelza abi's avatar Mika dabelza abi
Browse files

[GREEN] resolving merge conflicts

parents 08beac22 3e835f1b
File added
......@@ -44,7 +44,7 @@ Staging:
- gem install dpl
- wget -qO- https://cli-assets.heroku.com/install-ubuntu.sh | sh
script:
- dpl --provider=heroku --app=$HEROKU_APPNAME_STAGING --api-key=$HEROKU_APIKEY
- dpl --provider=heroku --strategy=git --app=$HEROKU_APPNAME_STAGING --api-key=$HEROKU_APIKEY
- export HEROKU_API_KEY=$HEROKU_APIKEY
- heroku run --app $HEROKU_APPNAME_STAGING migrate
environment:
......
# Generated by Django 3.0.3 on 2020-04-18 07:52
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0002_auto_20200408_2115'),
]
operations = [
migrations.CreateModel(
name='Category',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=20)),
('description', models.CharField(max_length=20)),
],
),
migrations.AddField(
model_name='materi',
name='descriptions',
field=models.CharField(default='SOME STRING', max_length=300),
),
migrations.AddField(
model_name='materi',
name='publisher',
field=models.CharField(default='SOME STRING', max_length=30),
),
migrations.AddField(
model_name='materi',
name='uploader',
field=models.CharField(default='SOME STRING', max_length=30),
),
migrations.AlterField(
model_name='materi',
name='author',
field=models.CharField(default='SOME STRING', max_length=30),
),
migrations.AlterField(
model_name='materi',
name='title',
field=models.CharField(default='SOME STRING', max_length=50),
),
migrations.AddField(
model_name='materi',
name='categories',
field=models.ManyToManyField(to='app.Category'),
),
]
# Generated by Django 3.0.3 on 2020-04-21 08:57
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0003_auto_20200418_1452'),
]
operations = [
migrations.CreateModel(
name='Comment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('user', models.CharField(default='423a22c748b647d58f725be4ad1ffefb', max_length=100)),
('profile', models.CharField(default='795364', max_length=100)),
('comment', models.CharField(default='comments', max_length=200)),
],
),
migrations.AlterField(
model_name='materi',
name='author',
field=models.CharField(default='author', max_length=30),
),
migrations.AlterField(
model_name='materi',
name='descriptions',
field=models.CharField(default='descriptions', max_length=300),
),
migrations.AlterField(
model_name='materi',
name='publisher',
field=models.CharField(default='publiser', max_length=30),
),
migrations.AlterField(
model_name='materi',
name='title',
field=models.CharField(default='title', max_length=50),
),
migrations.AlterField(
model_name='materi',
name='uploader',
field=models.CharField(default='uploader', max_length=30),
),
migrations.AddField(
model_name='materi',
name='comments',
field=models.ManyToManyField(to='app.Comment'),
),
]
# Generated by Django 3.0.3 on 2020-04-21 09:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0004_auto_20200421_1557'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='profile',
field=models.CharField(default='bdaac0', max_length=100),
),
migrations.AlterField(
model_name='comment',
name='user',
field=models.CharField(default='22daa04c12aa4fc7878d6e3a84eec095', max_length=100),
),
migrations.AlterField(
model_name='materi',
name='descriptions',
field=models.CharField(default='descriptions', max_length=200),
),
]
# Generated by Django 3.0.3 on 2020-04-21 09:33
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0005_auto_20200421_1625'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='comment',
field=models.CharField(default='comments', max_length=150),
),
migrations.AlterField(
model_name='comment',
name='profile',
field=models.CharField(default='4cee3b', max_length=100),
),
migrations.AlterField(
model_name='comment',
name='user',
field=models.CharField(default='b2ea05df58014e768c7bafda3140e365', max_length=100),
),
migrations.AlterField(
model_name='materi',
name='descriptions',
field=models.TextField(default='descriptions'),
),
]
# Generated by Django 3.0.3 on 2020-04-21 14:51
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0006_auto_20200421_1633'),
]
operations = [
migrations.AddField(
model_name='materi',
name='verified',
field=models.BooleanField(default=False),
),
migrations.AlterField(
model_name='comment',
name='profile',
field=models.CharField(default='e0ff7f', max_length=100),
),
migrations.AlterField(
model_name='comment',
name='user',
field=models.CharField(default='bd48a042721144bf80b64c2284c39f03', max_length=100),
),
]
from django.db import models
import uuid
import random
# Create your models here.
def getRandomColor():
color = "%06x" % random.randint(0, 0xFFFFFF)
return color
def getRandomUserId():
userId = uuid.uuid4().hex
return userId
class Category(models.Model):
name = models.CharField(max_length=20)
description = models.CharField(max_length=20)
def __str__(self):
return self.name
class Comment(models.Model):
user = models.CharField(max_length = 100, default= getRandomUserId())
profile = models.CharField(max_length = 100, default= getRandomColor())
comment = models.CharField(max_length = 150, default= 'comments')
def __str__(self):
return self.user
class Materi(models.Model):
cover = models.URLField(max_length=1000)
title = models.CharField(max_length=50)
author = models.CharField(max_length=30)
\ No newline at end of file
title = models.CharField(max_length=50, default='title')
author = models.CharField(max_length=30, default='author')
uploader = models.CharField(max_length=30, default='uploader')
publisher = models.CharField(max_length=30, default='publiser')
descriptions = models.TextField(default='descriptions')
verified = models.BooleanField(default=False)
categories = models.ManyToManyField(Category)
comments = models.ManyToManyField(Comment)
{% extends 'base.hmtl' %}
{% extends 'base.html' %}
{% load static %}
{% block header %}
<link rel="stylesheet" type="text/css" href="{% static 'app/css/detail_materi.css' %}">
{% endblock header %}
{% block title %}
Materi
{% endblock title %}
{% block content %}
<h1>babababa</h1>
<div class="container">
<div class="row materi-data">
<div class="col col-3 cover">
<img src="https://cache.umusic.com/_sites/billieeilish/v2/images/pic-red.jpg" alt="cover">
</div>
<div class="col col-6 offset-md-1 book">
<h2>Billie Eilish Starter Pack</h2>
<p>kategory</p>
<div class="info-wrapper">
<div class="info" id="1">
<dt class="col col-4">
<p class="info-name">Penulis</p>
</dt>
<dd>
<p class="info-content">Saul Andre Lumban Gaol</p>
</dd>
</div>
<div class="info" id="1">
<dt class="col col-4">
<p class="info-name">Penerbit</p>
</dt>
<dd>
<p class="info-content">Gramedia</p>
</dd>
</div>
<div class="info" id="1">
<dt class="col col-4">
<p class="info-name">Jumlah Halaman</p>
</dt>
<dd>
<p class="info-content">62 Halaman</p>
</dd>
</div>
<div class="info" id="1">
<dt class="col col-4">
<p class="info-name">Ukuran File</p>
</dt>
<dd>
<p class="info-content">5 Mb</p>
</dd>
</div>
</div>
<button class="btn btn-link btn-book shadow-sm p-2 mb-1 bg-white rounded">Baca</button>
<button class="btn btn-link btn-book shadow-sm p-2 mb-1 bg-white rounded">Unduh</button>
<button class="btn btn-link btn-book shadow-sm p-2 mb-1 bg-white rounded">Bagikan</button>
</div>
</div>
<div class="row menu-wrapper">
<nav class="navbar navbar-expand-sm">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#section1">Deskripsi</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#section2">Komentar</a>
</li>
</ul>
</nav>
<div id="section1" class="container-fluid description-wrapper">
<h1>Deskripsi</h1>
<div class="col col-8 description">
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
</div>
<div id="section2" class="container-fluid comments-wrapper">
<h1>Komentar</h1>
<div class="add-comments col col-8 ">
<form>
<div class="form-group">
<textarea placeholder="komentar..."
class="form-control mb-2"
id="exampleFormControlTextarea1"
rows="3">
</textarea>
<button type="submit" class="btn btn-book shadow-sm p-2 mb-1 bg-white rounded">Confirm identity</button>
</div>
</form>
</div>
<div class="col col-8 comment shadow-sm p-3 mb-1 bg-white rounded">
<div class="user">
<span class="profile"></span>
<p><b>user1</b></p>
</div>
<p class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
<div class="col col-8 comment shadow-sm p-3 mb-1 bg-white rounded">
<div class="user">
<span class="profile"></span>
<p><b>user2</b></p>
</div>
<p class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
<div class="col col-8 comment shadow-sm p-3 mb-1 bg-white rounded">
<div class="user">
<span class="profile"></span>
<p><b>user3</b></p>
</div>
<p class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
<div class="col col-8 comment shadow-sm p-3 mb-1 bg-white rounded">
<div class="user">
<span class="profile"></span>
<p><b>user4</b></p>
</div>
<p class="text">Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
</div>
<!-- <div class="col col-12">
<nav id="navbar-example2" class="navbar ">
<ul class="nav nav-pills">
<li class="nav-item">
<a class="nav-link" href="#fat">Deskripsi</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#mdo">Komentar</a>
</li>
</ul>
</nav>
</div>
<div class="col col-8 offset-md-1">
<div data-spy="scroll" data-target="#navbar-example2" data-offset="0">
<div class="description-wrapper">
<h4 id="fat">Deskripsi</h4>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
<p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</div>
</div>
</div> -->
</div>
</div>
{% endblock content %}
from django.test import TestCase, Client
from django.urls import resolve
from .views import DaftarKatalog, listMateri
from .models import Materi
from .views import DaftarKatalog, listMateri, DetailMateri
from .models import Materi, Category, Comment
from django.core import serializers
import json
......@@ -49,12 +50,83 @@ class DaftarKatalogTest(TestCase):
expected_output = json.dumps({"pk": self.materi.pk, "model": "app.materi", "fields": {"cover": "https://cache.umusic.com/_sites/billieeilish/v2/images/pic-red.jpg", "title": "Wahyu", "author": "Saul Andre Lumban Gaol"}})
self.assertJSONEqual(queryset.json()[1:-1], expected_output)
materi = Materi.objects.create(id=1, title="wahyu",
cover='https://cache.umusic.com/_sites/billieeilish/v2/images/pic-red.jpg',
author='Saul Andre Lumban Gaol',
uploader= "Bayu",
publisher='Diskominfo Depok',
descriptions="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
)
materi.save()
objectsCategory = Category.objects.create(name="medis", description="Kategory medis")
objectsComment = Comment.objects.create(user="saul", profile="ffffff", comment="inicoments")
categoryQueryToJson = serializers.serialize('json', Category.objects.all())
commentQueryToJson = serializers.serialize('json', Comment.objects.all())
materi.categories.add(objectsCategory)
materi.comments.add(objectsComment)
client = Client()
print(serializers.serialize('json', Materi.objects.all()))
queryset = client.get('/list-materi/')
expected_output = json.dumps({"pk": materi.pk, "model": "app.materi",
"fields": {"cover": "https://cache.umusic.com/_sites/billieeilish/v2/images/pic-red.jpg",
"title": "Wahyu",
"author": "Saul Andre Lumban Gaol",
"uploader": "Bayu",
"publisher": "Diskominfo Depok",
"descriptions": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.",
"categories": [1],
"comments": [1]}})
unexpected_output = json.dumps({"pk": materi.pk, "model": "app.materi",
"fields": {"cover": "",
"title": "",
"author": "",
"uploader": "",
"publisher": "",
"descriptions": "",
"categories": [],
"comments": []}})
self.assertJSONEqual(queryset.json()[1:-1], expected_output)
self.assertJSONNotEqual(queryset.json()[1:-1], unexpected_output)
class DetailMateriTest(TestCase):
def test_detail_materi_url_exist(self):
url = "/materi/"
response = Client().get(f'{url}')
self.assertEqual(response.status_code,200)
self.assertNotEqual(response.status_code, 404)
def test_detail_materi_using_detail_materi_template(self):
response = Client().get('/materi/')
self.assertTemplateUsed(response, 'app/detail_materi.html')
def test_detail_materi_using_detail_materi_func(self):
found = resolve('/materi/')
self.assertEqual(found.func.__name__, DetailMateri.as_view().__name__)
def test_category_models_can_create_new_object(self):
test = Category.objects.create(id="1", name="medis", description="kategori medis")
countData = Category.objects.all().count()
self.assertEqual(1, countData)
self.assertNotEqual(0, countData)
self.assertEqual(test.__str__(), "medis")
self.assertNotEqual(test.__str__(), "saul")
def test_comment_models_can_create_new_object(self):
test = Comment.objects.create(user="saul", profile="121212", comment= "232323")
countData = Comment.objects.all().count()
self.assertEqual(1, countData)
self.assertNotEqual(0, countData)
self.assertEqual(test.__str__(), "saul")
self.assertNotEqual(test.__str__(), "userlain")
class TemplateLoaderTest(TestCase):
def test_template_loader_url_exist(self):
url = "/test-page.html"
response = Client().get(url)
self.assertEqual(response.status_code,200)
self.assertEqual(response.status_code, 200)
def test_template_loader_using_template_loader_template(self):
url = "/test-page.html"
......
......@@ -2,6 +2,9 @@ from django.urls import path, re_path
from app import views
urlpatterns = [
path("", views.DaftarKatalog.as_view(), name='daftar_katalog'),
path('materi/', views.DetailMateri.as_view(), name='detailMateri'),
path('list-materi/', views.listMateri, name='listMateri'),
# Matches any html file
path("", views.DaftarKatalog.as_view(), name='daftar_katalog'),
# path("detail-materi/", views.DetailMateri.as_view(), name='detail_materi'),
......
......@@ -15,6 +15,17 @@ class DaftarKatalog(TemplateView):
context = self.get_context_data(**kwargs)
context["materi_list"] = Materi.objects.all()
return self.render_to_response(context=context)
class DetailMateri(TemplateView):
template_name = "app/detail_materi.html"
def get_context_data(self, **kwargs):
return super().get_context_data(**kwargs)
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
context["materi_list"] = Materi.objects.all()
return self.render_to_response(context=context)
def listMateri(self):
queries = Materi.objects.all()
......
......@@ -75,4 +75,4 @@ class User(AbstractUser):
EMAIL_FIELD = 'email'
USERNAME_FIELD = 'email'
REQUIRED_FIELDS = []
\ No newline at end of file
REQUIRED_FIELDS = []
/*//////////////////////////////////////////////////////////////////
[ FONT ]*/
@font-face {
font-family: Poppins-Regular;
src: url('../fonts/poppins/Poppins-Regular.ttf');
}
@font-face {
font-family: Poppins-Medium;
src: url('../fonts/poppins/Poppins-Medium.ttf');
}
@font-face {
font-family: Poppins-Bold;
src: url('../fonts/poppins/Poppins-Bold.ttf');
}
@font-face {
font-family: Poppins-SemiBold;
src: url('../fonts/poppins/Poppins-SemiBold.ttf');
}
@font-face {
font-family: Montserrat-Bold;
src: url('../fonts/montserrat/Montserrat-Bold.ttf');
}
@font-face {
font-family: Montserrat-SemiBold;
src: url('../fonts/montserrat/Montserrat-SemiBold.ttf');
}
@font-face {
font-family: Montserrat-Regular;
src: url('../fonts/montserrat/Montserrat-Regular.ttf');
}
/*//////////////////////////////////////////////////////////////////
[ RESTYLE TAG ]*/
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
body, html {
height: 100%;
font-family: Poppins-Regular, sans-serif;
}
/*---------------------------------------------*/