Fakultas Ilmu Komputer UI

Commit bbe371fd authored by ilestin.il's avatar ilestin.il
Browse files

[REFACTOR] make changes to the test & html. And make html more stylish

parent 82c04b0e
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Unggah Materi</title>
<link rel="icon" type="image/png" href="../static/unggah_materi/images/logo.ico" />
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.3/css/bootstrap.min.css'>
<link rel="stylesheet" href="../static/unggah_materi/css/fileupload.css">
<!-- Custom fonts for this template -->
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="{% static 'css/sb-admin-2.min.css' %}" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/button.css' %}">
<!-- Custom styles for this page -->
<link href="{% static 'vendor/datatables/dataTables.bootstrap4.min.css' %}" rel="stylesheet">
</head>
<body>
<!-- partial:index.partial.html -->
<!DOCTYPE html>
<html>
<body>
<div class="col-md-6 offset-md-3 mt-5">
<br>
<form id="add_form" method="POST" action="" novalidate enctype="multipart/form-data">
<h2>
Unggah Materi
</h2>
<div class="row">
{% csrf_token %}
{% for field in form %}
<div class="col-md-6">
<div class="fieldWrapper">
{{ field.label_tag }} {{ field }}
{{ field.errors }}
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
<body id="page-top" style="font-family: 'Poppins', sans-serif;">
<!-- Page Wrapper -->
<div id="wrapper">
<!-- Sidebar -->
<ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">
<!-- Sidebar - Brand -->
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="{% url 'daftar_katalog' %}">
<div class="sidebar-brand-icon rotate-n-15">
</div>
<div class="sidebar-brand-text mx-3">Digipus</div>
</a>
<!-- Divider -->
<hr class="sidebar-divider my-0">
<!-- Nav Item - Dashboard -->
<li class="nav-item">
<a class="nav-link" href="{% url 'dashboard' %}">
<span>Beranda</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'unggah' %}">
<span>Unggah Materi</span></a>
</li>
</ul>
<!-- End of Sidebar -->
<!-- Content Wrapper -->
<div id="content-wrapper" class="d-flex flex-column">
<!-- Main Content -->
<div id="content">
<!-- Topbar -->
<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"></i>
</button>
<div class="sidebar-brand-text mx-3">Diskominfo Kota Depok</div>
<!-- Topbar Navbar -->
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link" href="/unggah/">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">Unggah</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/profil/">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">Profil</span>
</a>
</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">
</a>
</li>
</ul>
</nav>
<!-- End of Topbar -->
<!-- Begin Page Content -->
<div class="container-fluid">
<div class="container">
<div class="col-20">
<h1 class="mt-2">Upload Materi</h1>
<hr class="mt-0 mb-4">
<form form id="add_form" method="POST" action="" novalidate enctype="multipart/form-data">
{% csrf_token %}
{% for field in form%}
<div class="col-md-6">
<div class="fieldWrapper">
{{ field.label_tag }} {{ field }}
{{ field.errors }}
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
</div>
</div>
{% endfor %}
<div class="row marl text-center m-3">
<a href="{% url 'unggah' %}" class="secondary_btn clear" style="border-radius:20px;color:white;"
id="create_user_cancel"><i class="fa fa-undo" aria-hidden="true">
</i>
Batal</a>
<button type="submit" class="btn btn-success"
style="background-color: #615CFD; border-color: #615CFD;">Simpan</button>
</button>
</div>
</div>
</form>
</div>
</div>
{% endfor %}
</div>
</div>
<div class="row marl text-center m-3">
<a href="/file_text/" class="secondary_btn clear" style="border-radius:20px;color:white;"
id="create_user_cancel"><i class="fa fa-undo" aria-hidden="true">
</i>Batal</a>
<button class="primary_btn save" style="border-radius:20px;" type="submit">
<i class="far fa-save">
</i>
Simpan
</button>
<!-- /.container-fluid -->
</div>
<!-- End of Main Content -->
<!-- Footer -->
<footer class="sticky-footer bg-white">
<div class="container my-auto">
<div class="copyright text-center my-auto">
<span>Copyright &copy; Diskominfo Kota Depok 2020</span>
</div>
</div>
</footer>
<!-- End of Footer -->
</div>
</form>
</div>
</body>
<!-- End of Content Wrapper -->
</div>
<!-- End of Page Wrapper -->
<!-- Scroll to Top Button-->
<a class="scroll-to-top rounded" href="#page-top">
<i class="fas fa-angle-up"></i>
</a>
</html>
<!-- partial -->
</body>
......
......@@ -7,7 +7,8 @@ from django.urls import resolve
from .models import Category, Comment, Materi
from .views import DaftarKatalog, DetailMateri
from app.views import UploadMateriHTML
from app.views import UploadMateriHTML, UploadMateriView
from authentication.models import User
class DaftarKatalogTest(TestCase):
......@@ -85,27 +86,40 @@ class TemplateLoaderTest(TestCase):
class UploadPageTest(TestCase):
def setUp(self):
self.client=Client()
self.user = User.objects._create_user(email="kontributor@gov.id",
password="kontributor", is_contributor=True)
def test_upload_page_using_login_func(self):
found = resolve("/unggah/")
self.assertEqual(found.func.__name__, UploadMateriHTML.as_view().__name__)
self.assertEqual(found.func.__name__, UploadMateriView.as_view().__name__)
def test_uplaod_page_url_is_exist(self):
#Positive test
response = Client().get("/unggah/")
self.client.login(email="kontributor@gov.id",
password="kontributor")
response = self.client.get("/unggah/")
self.assertEqual(response.status_code,200)
# Negative tests
self.client.login(email="kontributor@gov.id",
password="kontributor")
response = Client().get("/fake/")
self.assertEqual(response.status_code, 404)
def test_upload_page_template(self):
url = "/unggah/"
response = Client().get(url)
self.client.login(email="kontributor@gov.id",
password="kontributor")
response = self.client.get(url)
expected_template_name = "unggah.html"
self.assertTemplateUsed(response, expected_template_name)
def test_upload_page_title(self):
response = Client().get("/unggah/")
self.client.login(email="kontributor@gov.id",
password="kontributor")
response = self.client.get("/unggah/")
# Positive tests
self.assertContains(response, "Unggah Materi")
......@@ -114,7 +128,9 @@ class UploadPageTest(TestCase):
self.assertNotContains(response, "Anything")
def test_upload_page_form_field(self):
response = Client().get("/unggah/")
self.client.login(email="kontributor@gov.id",
password="kontributor")
response = self.client.get("/unggah/")
# Positive tests
self.assertContains(response, "title")
......
from django.urls import path, re_path
from app import views
from app.views import UploadMateriHTML, DashboardKontributor
from app.views import UploadMateriHTML, DashboardKontributor, UploadMateriView
urlpatterns = [
path("", views.DaftarKatalog.as_view(), name="daftar_katalog"),
......@@ -9,7 +9,7 @@ urlpatterns = [
path("materi/<int:pk>/unduh", views.download_materi, name="download-materi"),
path("materi/<int:pk>/view", views.view_materi, name="view-materi"),
path("dashboard/", DashboardKontributor.as_view(), name="dashboard"),
path("unggah/", UploadMateriHTML.as_view(), name="unggah"),
path("unggah/", UploadMateriView.as_view(), name="unggah"),
# Matches any html file
re_path(r"^.*\.html", views.pages, name="pages"),
]
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