Fakultas Ilmu Komputer UI

Commit 69dce337 authored by Saul Andre's avatar Saul Andre Committed by igor lestin sianipar
Browse files

Pbi 7 detail materi

parent 420b1ff4
No preview for this file type
# 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),
),
]
# Generated by Django 3.0.3 on 2020-04-22 15:02
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0007_auto_20200421_2151'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='profile',
field=models.CharField(default='d91905', max_length=100),
),
migrations.AlterField(
model_name='comment',
name='user',
field=models.CharField(default='2565edd4bdac454d9cd87e2e7d93d27f', max_length=100),
),
]
# Generated by Django 3.0.3 on 2020-04-22 15:06
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0008_auto_20200422_2202'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='profile',
field=models.CharField(default='cbacb3', max_length=100),
),
migrations.AlterField(
model_name='comment',
name='user',
field=models.CharField(default='31d4991724a9498fb58b631db4636bff', max_length=100),
),
migrations.AlterField(
model_name='materi',
name='verified',
field=models.BooleanField(default=False, null=True),
),
]
# Generated by Django 3.0.3 on 2020-04-22 15:06
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0009_auto_20200422_2206'),
]
operations = [
migrations.AlterField(
model_name='comment',
name='profile',
field=models.CharField(default='e2db20', max_length=100),
),
migrations.AlterField(
model_name='comment',
name='user',
field=models.CharField(default='e230956660bd4b899b4b81f03e6553a6', 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):
#TODO: file fields, cover ubah jadi image fields, uploader jadi one to one kontributor
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') #ubah jadi one to one ke kontributor
publisher = models.CharField(max_length=30, default='publiser')
descriptions = models.TextField(default='descriptions')
verified = models.BooleanField(default=False, null=True)
categories = models.ManyToManyField(Category)
comments = models.ManyToManyField(Comment)
body{
font-family: 'Poppins', sans-serif;
}
.container{
margin-top: 20px;
}
.row{}
.materi-data{
padding: 20px;
border-bottom: 1px solid #d4d4d4
}
.cover{
max-width: 300px;
}
.category-wrapper{
display: flex;
flex-direction: row;
}
.cover img{
width: 100%;
}
.book p, h2 {
margin: 0
}
.info-wrapper{
margin-top: 20px;
}
.info{
margin: 10px 0;
border-bottom: 1px solid #d4d4d4;
display: flex;
flex-direction: row;
}
.info .col{
padding: 0;
}
.btn-book {
background-color: #ffffff;
color: #5B84B1;
}
.btn-book:hover {
color: #5B84B1;
}
.menu-wrapper{
display: flex;
flex-direction: column;
}
.menu-wrapper .col{
padding: 0;
}
.menu-wrapper .navbar {
padding: 0;
border-bottom: 1px solid #d4d4d4;
margin-bottom: 10px;
}
.menu-wrapper .nav-link {
color: #bbbbbb;
}
.nav-item :hover{
color: #5B84B1;
}
.menu-wrapper .nav-item{
padding: 5px 0;
}
.description-wrapper{
border-bottom: 1px solid #d4d4d4;
margin-bottom: 10px;
}
.comment{
border-bottom: 1px solid #d4d4d4;
}
.comment .user {
display: flex;
flex-direction: row;
margin-bottom: 10px;
}
.comment .user p{
margin: 0
}
.comment .user .profile{
height: 25px;
width: 25px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
margin-right: 10px;
}
.comment .text{
padding-left: 20px;
}
\ No newline at end of file
{% extends 'base.hmtl' %}
{% extends 'base.html' %}
{% load static %}
{% block header %}
<link rel="stylesheet" type="text/css" href="{% static 'app/css/detail_materi.css' %}">
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,500;1,100&display=swap" rel="stylesheet">
{% endblock header %}
{% block title %}
Materi
{% endblock title %}
{% block content %}
<h1>babababa</h1>
{% endblock content %}
{% block verification %} {% endblock verification %}
<div class="container">
<div class="row materi-data">
<div class="col col-3 cover">
<img src={{materi_data.cover}} alt="cover">
</div>
<div class="col col-6 ml-3 book">
<h2>{{materi_data.title}}</h2>
<div class="category-wrapper">
{% for category in materi_data.categories.all %}
<span class="mr-1">#{{category.name}}</span>
{% endfor %}
</div>
<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">{{materi_data.author}}</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">{{materi_data.publisher}}</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">{{materi_data.author}}</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>{{materi_data.descriptions}}</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>
{% for comment in materi_data.comments.all %}
<div class="col col-8 comment shadow-sm p-3 mb-1 bg-white rounded">
<div class="user">
<span class="profile"></span>
<p><b>{{comment.user}}</b></p>
</div>
<p class="text">{{comment.comment}}</p>
</div>
{% endfor %}
</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 %}
\ No newline at end of file
......@@ -73,7 +73,7 @@
<h5 class="card-title">{{item.title}}</h5>
<p class="card-text">{{item.author}}</p>
<button class="btn btn-book">Baca</button>
<button class="btn btn-book">Detail</button>
<button class="btn btn-book" onclick="">Detail</button>
</div>
</div>
{% endfor %}
......
from django.test import TestCase, Client
from django.urls import resolve
from .views import DaftarKatalog, listMateri
from .models import Materi
from .views import DaftarKatalog, DetailMateri
from .models import Materi, Category, Comment
from django.core import serializers
import json
......@@ -16,7 +16,6 @@ class DaftarKatalogTest(TestCase):
response = Client().get('/')
self.assertTemplateUsed(response, 'app/katalog_materi.html')
def test_daftar_katalog_using_daftar_katalog_func(self):
found = resolve('/')
self.assertEqual(found.func.__name__, DaftarKatalog.as_view().__name__)
......@@ -31,25 +30,51 @@ class DaftarKatalogTest(TestCase):
resp = Materi.objects.get(id = materi.id