Fakultas Ilmu Komputer UI

Commit d33d1932 authored by Saul Andre's avatar Saul Andre
Browse files

[REFACTOR] finishing html and styles for detail materi. Fix bug post by anonym

parent 5c4fb46f
......@@ -5,12 +5,15 @@ body{
.container{
margin-top: 20px;
}
.bg{
background-color: #f8f9fc
}
.row{}
.row{
}
.materi-data{
padding: 20px;
border-bottom: 1px solid #d4d4d4
background-color: #ffffff;
}
.cover{
......@@ -63,9 +66,6 @@ body{
padding: 0;
}
.menu-wrapper .navbar {
padding: 0;
border-bottom: 1px solid #d4d4d4;
margin-bottom: 10px;
}
.menu-wrapper .nav-link {
color: #bbbbbb;
......
......@@ -14,8 +14,57 @@ Materi
{% block content %}
{% block verification %} {% endblock verification %}
<div id="fb-root"></div>
<div class="container">
<div class="row materi-data">
<div class="container-fluid p-0 bg">
<nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">
<!-- Sidebar Toggle (Topbar) -->
<button id="sidebarToggleTop" class="btn btn-link d-md-none rounded-circle mr-3">
<i class="fa fa-bars" aria-hidden="true"></i>
</button>
<div class="sidebar-brand-text mx-3">Diskominfo Kota Depok</div>
<!-- Topbar Navbar -->
<ul class="navbar-nav ml-auto">
<!-- Nav Item - Search Dropdown (Visible Only XS) -->
<li class="nav-item dropdown no-arrow d-sm-none">
<a class="nav-link dropdown-toggle" href="#" id="searchDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<i class="fas fa-search fa-fw" aria-hidden="true"></i>
</a>
<!-- Dropdown - Messages -->
<div class="dropdown-menu dropdown-menu-right p-3 shadow animated--grow-in"
aria-labelledby="searchDropdown">
<form class="form-inline mr-auto w-100 navbar-search">
<div class="input-group">
<input type="text" class="form-control bg-light border-0 small" placeholder="Search for..."
aria-label="Search" aria-describedby="basic-addon2">
<div class="input-group-append">
<button class="btn btn-primary" type="button">
<i class="fas fa-search fa-sm" aria-hidden="true"></i>
</button>
</div>
</div>
</form>
</div>
</li>
<div class="topbar-divider d-none d-sm-block"></div>
<!-- Nav Item - User Information -->
<li class="nav-item dropdown no-arrow">
<a class="nav-link dropdown-toggle" href="#" id="userDropdown" role="button" data-toggle="dropdown"
aria-haspopup="true" aria-expanded="false">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">Admin</span>
<img class="img-profile rounded-circle" src="https://source.unsplash.com/QAB-WJcbgJk/60x60" alt="User profile picture">
</a>
</li>
</ul>
</nav>
<div class="row materi-data mr-4 ml-4 p-3 shadow-sm rounded">
<div class="col col-3 cover">
<img src={{materi_data.cover.url}} alt="cover">
</div>
......@@ -81,8 +130,8 @@ Materi
</div>
</div>
</div>
<div class="row menu-wrapper">
<nav class="navbar navbar-expand-sm">
<div class="row menu-wrapper mr-4 ml-4 p-3">
<nav class="navbar navbar-expand-sm border-top border-bottom p-0 mt-3 mb-3">
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" href="#deskripsi">Deskripsi</a>
......@@ -92,23 +141,23 @@ Materi
</li>
</ul>
</nav>
<div id="deskripsi" class="container-fluid description-wrapper">
<div id="deskripsi" class="container-fluid description-wrapper bg-white shadow-sm rounded p-3">
<h1>Deskripsi</h1>
<div class="col col-8 description">
<p>{{materi_data.descriptions}}</p>
</div>
</div>
<div id="komentar" class="container-fluid comments-wrapper">
<h1>Komentar</h1>
<div class="add-comments col col-8 ">
<div id="komentar" class="container-fluid comments-wrapper p-0">
<div class="add-comments col col-8 bg-white shadow-sm rounded p-3 mb-3">
<form method="POST">
{% csrf_token %}
<h1>Komentar</h1>
<div class="form-group">
<textarea placeholder="komentar..." class="form-control"
<textarea placeholder="Beri komentar..." class="form-control"
id="exampleFormControlTextarea1"
rows="3" name="comment" required
></textarea>
<button type="submit" class="btn btn-book shadow-sm p-2 mb-1 bg-white rounded">Kirim</button>
<button type="submit" class="btn btn-link btn-book shadow-sm p-2 mt-2 bg-white rounded">Kirim</button>
</div>
</form>
</div>
......@@ -129,4 +178,11 @@ Materi
</div>
</div>
</div>
<footer class="sticky-footer bg-white p-4">
<div class="container my-auto">
<div class="copyright text-center my-auto">
<span>Copyright &copy; Diskominfo Kota Depok 2020</span>
</div>
</div>
</footer>
{% endblock content %}
......@@ -134,11 +134,18 @@ class DetailMateriTest(TestCase):
self.client.login(**self.anonymous_credential)
self.client.post(url, {"comment": "This is new comment by Anonymous"})
response = self.client.get(url)
self.assertContains(response, "Anonim")
self.assertContains(response, "Anonymous")
def test_detail_materi_contains_form_comment(self):
response = self.client.get(self.url)
self.assertContains(response, "komentar...")
def test_delete_comments_by_admin(self):
url = self.url
self.client.post(url, {"comment": "This is new comment by Anonymous"})
deleteURL = "/delete/" + str(self.materi1.id) + "/" + str(Comment.objects.get(comment="This is new comment by Anonymous").id)
self.client.get(deleteURL)
self.assertEqual(Comment.objects.all().filter(comment="This is new comment by Anonymous").count(),0)
class TemplateLoaderTest(TestCase):
def test_template_loader_url_exist(self):
......
......@@ -2,6 +2,7 @@ import mimetypes
import os
from authentication.models import User
from django.contrib.auth.models import AnonymousUser
from django.conf import settings
from django.core import serializers
from django.core.exceptions import PermissionDenied
......@@ -77,13 +78,12 @@ class DetailMateri(TemplateView):
def get_user_name(self, request):
user_name = ""
if request.user.is_admin:
if isinstance(request.user, AnonymousUser):
user_name = "Anonim"
elif request.user.is_admin:
user_name = "Admin"
elif request.user.is_contributor:
user_name = request.user.name
else:
user_name = "Anonim"
return user_name
def post(self, request, *args, **kwargs):
......@@ -122,7 +122,6 @@ def download_materi(request, pk):
else:
raise Http404("File tidak dapat ditemukan.")
def view_materi(request, pk):
materi = get_object_or_404(Materi, pk=pk)
path = materi.content.path
......
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