Fakultas Ilmu Komputer UI

Commit d8fa275e authored by Samuel Dimas Partogi's avatar Samuel Dimas Partogi
Browse files

Daftar Kontributor

parent 13b3c524
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<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>Dasbor Kontributor</title>
<!-- 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 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="/administration/">
<span>Verifikasi Materi</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="/administration/daftar-kontributor/">
<span>Daftar Kontributor</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<span>Statistik Materi</span></a>
</li>
<!-- Divider -->
<hr class="sidebar-divider">
<li class="nav-item">
<a class="nav-link" href="/administration/setting/verification/">
<span>Pengaturan Verifikasi</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="/administration/setting/category/">
<span>Pengaturan Kategori</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="/dashboard/">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">Dasbor</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">{{ user.name }}</span>
<img class="img-profile rounded-circle" src="{{ user.profile_picture.url}}">
</a>
</li>
</ul>
</nav>
<!-- End of Topbar -->
<!-- Begin Page Content -->
<div class="container-fluid">
<!-- Page Heading -->
<h1 class="h3 mb-2 text-gray-800">Daftar Kontributor</h1>
<p class="mb-4">Tekan tombol detail untuk informasi lebih lanjut tentang kontributor</p>
<!-- DataTales Example -->
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">Tabel Daftar Kontributor</h6>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>Nama</th>
<th>NIK</th>
<th>Instansi</th>
<th>Detail</th>
</tr>
</thead>
<tfoot>
<tr>
<th>Nama</th>
<th>NIK</th>
<th>Instansi</th>
<th>Detail</th>
</tr>
</tr>
</tfoot>
<tbody>
{% for user in users %}
<tr>
<td>{{ user.name }}</td>
<td>{{ user.nik }}</td>
<td>{{ user.instansi }}</td>
<td class="verif-buttons">
<a href="/administration/profil/{{ user.id }}/" class="accept-button"
style="background-color:#4e73df">Detail
</a>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- /.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>
<!-- 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>
<!-- Bootstrap core JavaScript-->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
<!-- Core plugin JavaScript-->
<script src="https://code.jquery.com/jquery-3.5.0.min.js"
integrity="sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ=" crossorigin="anonymous"></script>
<!-- Custom scripts for all pages-->
<script src="{% static 'js/sb-admin-2.min.js' %}"></script>
<!-- Page level plugins -->
<script src="{% static 'vendor/datatables/jquery.dataTables.min.js' %}"></script>
<script src="{% static 'vendor/datatables/dataTables.bootstrap4.min.js' %}"></script>
<!-- Page level custom scripts -->
<script src="{% static 'js/demo/datatables-demo.js' %}"></script>
</body>
</html>
\ No newline at end of file
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<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>Profil Kontributor</title>
<!-- 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 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="/administration/">
<span>Verifikasi Materi</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="/administration/daftar-kontributor/">
<span>Daftar Kontributor</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<span>Statistik Materi</span></a>
</li>
<!-- Divider -->
<hr class="sidebar-divider">
<li class="nav-item">
<a class="nav-link" href="/administration/setting/verification/">
<span>Pengaturan Verifikasi</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="/administration/setting/category/">
<span>Pengaturan Kategori</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">
<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">{{ user.name }}</span>
<img class="img-profile rounded-circle" src="{{ user.profile_picture.url }}">
</a>
</li>
</ul>
</nav>
<!-- End of Topbar -->
<!-- Begin Page Content -->
<div class="container-fluid">
<div class="profile-content white-text">
<div>
<img src="{{ user.profile_picture.url }}" alt="Photo" class="img-thumbnail"></img>
<div class="profile-margin"></div>
<h2>{{ user.name }}</h2>
<h4>{{ user.email }}</h4>
<h4>{{ user.biography }}</h4>
<div class="profile-margin"></div>
<table>
<tr>
<td class="profile-data">Instansi</td>
<td>{{ user.instansi }}</td>
</tr>
<td class="profile-data">LinkedIn</td>
<td><a href="https://linkedin.com">{{ user.linkedin }}</a></td>
</tr>
<tr>
<td class="profile-data">Facebook</td>
<td><a href="https://facebook.com">{{ user.facebook }}</a></td>
</tr>
<tr>
<td class="profile-data">Twitter</td>
<td><a href="https://twitter.com">{{ user.twitter }}</a></td>
</tr>
<tr>
<td class="profile-data">Instagram</td>
<td><a href="https://instagram.com">{{ user.instagram }}</a></td>
</tr>
</table>
<a class="btn btn-primary btn-admin" href="/administration/daftar-kontributor/">Kembali ke Daftar Kontributor</a>
</div>
</div>
</div>
<!-- /.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>
<!-- 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>
<!-- Bootstrap core JavaScript-->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"
integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"
integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"
integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM"
crossorigin="anonymous"></script>
<!-- Core plugin JavaScript-->
<script src="https://code.jquery.com/jquery-3.5.0.min.js"
integrity="sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ=" crossorigin="anonymous"></script>
<!-- Custom scripts for all pages-->
<script src="{% static 'js/sb-admin-2.min.js' %}"></script>
<!-- Page level plugins -->
<script src="{% static 'vendor/datatables/jquery.dataTables.min.js' %}"></script>
<script src="{% static 'vendor/datatables/dataTables.bootstrap4.min.js' %}"></script>
<!-- Page level custom scripts -->
<script src="{% static 'js/demo/datatables-demo.js' %}"></script>
</body>
</html>
\ No newline at end of file
......@@ -50,7 +50,7 @@
</li>
<li class="nav-item">
<a class="nav-link" href="index.html">
<a class="nav-link" href="/administration/daftar-kontributor/">
<span>Daftar Kontributor</span></a>
</li>
......@@ -124,7 +124,7 @@
<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">
<img class="img-profile rounded-circle" src="{{ user.profile_picture.url }}" alt="User profile picture">
</a>
</li>
......
......@@ -173,7 +173,6 @@ class DetailVerifikasiMateriTest(TestCase):
response = self.client.get(self.url_materi_1)
self.assertEqual(response.status_code, 403)
def test_verification_detail_approve(self):
# Login
self.client.login(**self.admin_credential)
......@@ -210,7 +209,6 @@ class DetailVerifikasiMateriTest(TestCase):
# Logout
self.client.logout()
def test_verification_detail_disapprove(self):
# Login
self.client.login(**self.admin_credential)
......@@ -501,3 +499,112 @@ class SettingCategoriTest(TestCase):
self.assertNotIn('Deskripsi Kategori 1', el)
# Logout
self.client.logout()
class ContributorListTest(TestCase ):
def setUp(self):
self.client = Client()
self.url = '/administration/daftar-kontributor/'
self.admin_credential = {
"email": "admin@gov.id",
"password": id_generator()
}
self.contributor_credential = {
"email": "kontributor@gov.id",
"password": id_generator()
}
self.admin = get_user_model().objects.create_user(
**self.admin_credential, name="Admin", is_admin=True)
self.contributor = get_user_model().objects.create_user(
**self.contributor_credential, name="Kontributor", is_contributor=True
)
self.cover = SimpleUploadedFile(
"cover.jpg",
b"Test file"
)
self.content = SimpleUploadedFile(
"content.txt",
b"Test file"
)
Materi(title="Materi 1", author="Agas", uploader=self.contributor,
publisher="Kelas SC", descriptions="Deskripsi Materi 1",
status="PENDING", cover=self.cover, content=self.content, feedback="").save()
self.materi1 = Materi.objects.first()
def test_contributor_list_access(self):
# Login
self.client.login(**self.admin_credential)
# Test
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
# Logout
self.client.logout()
def test_contributor_list_contributor_access(self):
# Login
self.client.login(**self.contributor_credential)
# Test
response = self.client.get(self.url)
self.assertEqual(response.status_code, 403)
# Logout
self.client.logout()
def test_contributor_list_anonymous_access(self):
# Test
response = self.client.get(self.url)
self.assertEqual(response.status_code, 403)
def test_contributor_list_using_correct_template(self):
# Login
self.client.login(**self.admin_credential)
found = resolve(self.url)
self.assertEqual(found.func.__name__, views.ContributorListView.__name__)
def test_contributor_list_title(self):
# Login
self.client.login(**self.admin_credential)
response = self.client.get(self.url)
self.assertContains(response, 'Dasbor Kontributor')
self.assertNotContains(response, 'Fake Title')
class ProfileContributorAdminTest(TestCase):
def setUp(self):
self.client = Client()
self.url = '/administration/profil/1/'
self.admin_credential = {
"email": "admin@gov.id",
"password": id_generator()
}
self.contributor_credential = {
"email": "kontributor@gov.id",
"password": id_generator()
}
self.admin = get_user_model().objects.create_user(
**self.admin_credential, name="Admin", is_admin=True)
self.contributor = get_user_model().objects.create_user(
**self.contributor_credential, name="Kontributor", is_contributor=True
)
self.cover = SimpleUploadedFile(
"cover.jpg",
b"Test file"
)
self.content = SimpleUploadedFile(
"content.txt",
b"Test file"
)
Materi(title="Materi 1", author="Agas", uploader=self.contributor,
publisher="Kelas SC", descriptions="Deskripsi Materi 1",
status="PENDING", cover=self.cover, content=self.content, feedback="").save()
self.materi1 = Materi.objects.first()
def test_profile_contributor_admin_anonymous_access(self):
# Test
response = self.client.get(self.url)
self.assertEqual(response.status_code, 403)
def test_profile_contributor_admin_using_correct_template(self):
# Login
self.client.login(**self.admin_credential)
found = resolve(self.url)
self.assertEqual(found.func.__name__, views.ProfileContributorAdminView.__name__)
\ No newline at end of file
......@@ -9,4 +9,6 @@ urlpatterns = [
path("detail-verif/<int:pk>/", views.DetailVerificationView.as_view()),
path("setting/verification/", views.VerificationSettingView.as_view()),
path("setting/category/", views.CategorySettingView.as_view()),
path("daftar-kontributor/", views.ContributorListView.as_view()),
path("profil/<int:pk>/", views.ProfileContributorAdminView.as_view()),
]
......@@ -4,6 +4,7 @@ from django.shortcuts import get_object_or_404, render
from django.views.generic import TemplateView
from app.models import Category, Materi
from authentication.models import User
from .forms import CategoryForm, VerificationSettingForm
from .models import VerificationSetting, VerificationReport
......@@ -154,3 +155,38 @@ class CategorySettingView(TemplateView):
context = self.get_context_data(**kwargs)
context["form"] = form
return self.render_to_response(context)