Fakultas Ilmu Komputer UI

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

Success Login Page and Logout Button

parent 793b4dab
......@@ -17,6 +17,7 @@
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<!-- Custom styles for this template -->
<link rel="icon" type="image/png" href="{% static 'images/icons/logo.ico' %}" />
<link href="{% static 'css/sb-admin-2.min.css' %}" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/button.css' %}">
......
......@@ -14,6 +14,7 @@
<title>Dasbor - Verifikasi Materi</title>
<!-- Custom fonts for this template -->
<link rel="icon" type="image/png" href="{% static 'images/icons/logo.ico' %}" />
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<!-- Custom styles for this template -->
......
......@@ -14,6 +14,7 @@
<title>Profil Kontributor</title>
<!-- Custom fonts for this template -->
<link rel="icon" type="image/png" href="{% static 'images/icons/logo.ico' %}" />
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<!-- Custom styles for this template -->
......
......@@ -14,6 +14,7 @@
<title>Dasbor - Pengaturan Verifikasi Materi</title>
<!-- Custom fonts for this template -->
<link rel="icon" type="image/png" href="{% static 'images/icons/logo.ico' %}" />
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<!-- Custom styles for this template -->
......
......@@ -17,6 +17,7 @@
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<!-- Custom styles for this template -->
<link rel="icon" type="image/png" href="{% static 'images/icons/logo.ico' %}" />
<link href="{% static 'css/sb-admin-2.min.css' %}" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/button.css' %}">
......
......@@ -17,6 +17,7 @@
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<!-- Custom styles for this template -->
<link rel="icon" type="image/png" href="{% static 'images/icons/logo.ico' %}" />
<link href="{% static 'css/sb-admin-2.min.css' %}" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/button.css' %}">
......
......@@ -9,6 +9,18 @@ body{
background-color: #f8f9fc
}
.brand-link {
color: inherit;
}
.brand-link:hover,
.brand-link:active {
text-decoration: none;
color: inherit;
}
.detail-materi-color {
color: black;
}
.row{
}
......
......@@ -2,7 +2,7 @@
{% load static %}
{% block header %}
<link href="{% static 'css/sb-admin-2.min.css' %}" rel="stylesheet">
<link href="{% static 'css/sb-admin-2.min.css' %}" rel="stylesheet">
<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">
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v6.0"></script>
......@@ -15,7 +15,7 @@
{% block content %}
{% block verification %} {% endblock verification %}
<div id="fb-root"></div>
<div class="container-fluid p-0 bg">
<div class="container-fluid p-0 bg detail-materi-color">
<nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">
<!-- Sidebar Toggle (Topbar) -->
......@@ -28,32 +28,16 @@
<!-- 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 class="nav-item">
<a class="nav-link" href="/">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">Halaman Katalog</span>
</a>
</li>
<div class="topbar-divider d-none d-sm-block"></div>
<!-- Nav Item - User Information -->
{% if request.user.is_authenticated %}
<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">
......@@ -61,6 +45,7 @@
<img class="img-profile rounded-circle" src="{{ user.profile_picture.url }}" alt="User profile picture">
</a>
</li>
{% endif %}
</ul>
......@@ -98,7 +83,7 @@
<p class="info-name">Jumlah Halaman</p>
</dt>
<dd>
<p class="info-content">{{materi_data.author}}</p>
<p class="info-content">{{materi_data.pages}}</p>
</dd>
</div>
<div class="info" id="1">
......
......@@ -19,7 +19,7 @@
<!-- Custom styles for this template -->
<link href="{% static 'css/sb-admin-2.min.css' %}" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/button.css' %}">
<link rel="icon" type="image/png" href="{% static 'images/icons/logo.ico' %}">
<!-- Custom styles for this page -->
<link href="{% static 'vendor/datatables/dataTables.bootstrap4.min.css' %}" rel="stylesheet">
......@@ -92,6 +92,12 @@
<span class="mr-2 d-none d-lg-inline text-gray-600 small">Profil</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/dashboard/">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">Logout</span>
</a>
</li>
<div class="topbar-divider d-none d-sm-block"></div>
......
......@@ -17,6 +17,7 @@
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<!-- Custom styles for this template -->
<link rel="icon" type="image/png" href="{% static 'images/icons/logo.ico' %}" />
<link href="{% static 'css/sb-admin-2.min.css' %}" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/button.css' %}">
......@@ -87,6 +88,12 @@
<span class="mr-2 d-none d-lg-inline text-gray-600 small">Profil</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/logout/">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">Logout</span>
</a>
</li>
<div class="topbar-divider d-none d-sm-block"></div>
......
{% 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 rel="icon" type="image/png" href="{% static 'images/icons/logo.ico' %}" />
<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">
<!-- Content Wrapper -->
<div id="content-wrapper" class="d-flex flex-column">
<!-- Main Content -->
<div id="content">
<!-- Begin Page Content -->
<div class="container-fluid page-height">
<div class="profile-content white-text">
<div class="main-content">
<img src="https://i.ibb.co/Gk3yQWR/tick.jpg" alt="Photo" class="img-thumbnail"></img>
<div class="profile-margin"></div>
<h2>Halo {{ user.name }}, anda telah sukses login!</h2>
<div class="profile-margin"></div>
<span>
<a class="btn btn-primary main-content" href="/"> Halaman Katalog</a>
<a class="btn btn-primary main-content" href="/administration/">Halaman Administrasi</a>
</span>
</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>
</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 rel="icon" type="image/png" href="{% static 'images/icons/logo.ico' %}" />
<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">
<!-- Content Wrapper -->
<div id="content-wrapper" class="d-flex flex-column">
<!-- Main Content -->
<div id="content">
<!-- Begin Page Content -->
<div class="container-fluid page-height">
<div class="profile-content white-text">
<div class="main-content">
<img src="https://i.ibb.co/Gk3yQWR/tick.jpg" alt="Photo" class="img-thumbnail"></img>
<div class="profile-margin"></div>
<h2>Halo {{ user.name }}, anda telah sukses login!</h2>
<div class="profile-margin"></div>
<h2>Pilih halaman yang dituju</h2>
<div class="profile-margin"></div>
<span>
<a class="btn btn-primary main-content" href="/"> Halaman Katalog</a>
<a class="btn btn-primary main-content" href="/sunting/">Sunting Profil</a>
<a class="btn btn-primary main-content" href="/profil/">Profil</a>
<a class="btn btn-primary main-content" href="/dashboard/">Dasbor</a>
</span>
</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>
</body>
</html>
\ No newline at end of file
......@@ -14,6 +14,7 @@
<title>Profil Kontributor</title>
<!-- Custom fonts for this template -->
<link rel="icon" type="image/png" href="{% static 'images/icons/logo.ico' %}" />
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<!-- Custom styles for this template -->
......@@ -76,6 +77,12 @@
<!-- 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>
......@@ -83,10 +90,10 @@
</li>
<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 class="nav-link" href="/logout/">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">Logout</span>
</a>
</li>
</li>
<div class="topbar-divider d-none d-sm-block"></div>
......
......@@ -14,6 +14,7 @@
<title>Unggah Materi</title>
<!-- Custom fonts for this template -->
<link rel="icon" type="image/png" href="{% static 'images/icons/logo.ico' %}" />
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet">
<!-- Custom styles for this template -->
......@@ -96,15 +97,21 @@
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/dashboard/">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">Logout</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>
<span class="mr-2 d-none d-lg-inline text-gray-600 small">{{ user.name }}</span>
<img class="img-profile rounded-circle"
src="https://source.unsplash.com/QAB-WJcbgJk/60x60">
src="{{ user.profile_picture.url }}">
</a>
</li>
......
......@@ -8,10 +8,10 @@ from django.urls import resolve
from authentication.models import User
from django.contrib.auth import get_user_model
from django.core.files import File
from .views import DaftarKatalog, DetailMateri, DashboardKontributorView, ProfilKontributorView, SuntingProfilView
from .views import DaftarKatalog, DetailMateri, DashboardKontributorView, ProfilKontributorView, SuntingProfilView, SuksesLoginAdminView, SuksesLoginKontributorView
from .models import Materi, Category, Comment
from app.views import UploadMateriHTML, UploadMateriView
from administration.utils import id_generator
class DaftarKatalogTest(TestCase):
def test_daftar_katalog_url_exist(self):
......@@ -393,4 +393,96 @@ class SuntingProfilTest(TestCase):
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
# Logout
self.client.logout()
\ No newline at end of file
self.client.logout()
class SuksesLoginKontributorTest(TestCase):
def setUp(self):
self.client = Client()
self.kontributor = User.objects.create_contributor(email="kontributor@gov.id",
password="kontributor")
self.admin = User.objects.create_admin(email="admin@gov.id",
password="admin")
self.url = "/sukses-kontributor/"
self.view = SuksesLoginKontributorView
self.template_name = "sukses_kontri.html"
def test_sukses_login_kontributor_view(self):
found = resolve(self.url)
self.assertEqual(found.func.__name__, self.view.as_view().__name__)
def test_sukses_login_kontributor_template(self):
# Login
self.client.login(email="kontributor@gov.id",
password="kontributor")
# Test
response = self.client.get(self.url)
self.assertTemplateUsed(response, self.template_name)
# Logout
self.client.logout()
def test_sukses_login_kontributor_url(self):
# Login
self.client.login(email="kontributor@gov.id",
password="kontributor")
# Test
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
# Logout
self.client.logout()
def test_sukses_login_kontributor_access(self):
# Kontributor
# Login
self.client.login(email="kontributor@gov.id",
password="kontributor")
# Test
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
# Logout
self.client.logout()
class SuksesLoginAdminTest(TestCase):
def setUp(self):
self.client = Client()
self.kontributor = User.objects.create_contributor(email="kontributor@gov.id",
password="kontributor")
self.admin = User.objects.create_admin(email="admin@gov.id",
password="admin")
self.url = "/sukses-admin/"
self.view = SuksesLoginAdminView
self.template_name = "sukses_admin.html"
def test_sukses_login_admin_view(self):
found = resolve(self.url)
self.assertEqual(found.func.__name__, self.view.as_view().__name__)
def test_sukses_login_admin_template(self):
# Login
self.client.login(email="admin@gov.id",
password="admin")
# Test
response = self.client.get(self.url)
self.assertTemplateUsed(response, self.template_name)
# Logout
self.client.logout()
def test_sukses_login_admin_url(self):
# Login
self.client.login(email="admin@gov.id",
password="admin")
# Test
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
# Logout
self.client.logout()
def test_sukses_login_admin_access(self):
# Kontributor
# Login
self.client.login(email="admin@gov.id",
password="admin")
# Test
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
# Logout
self.client.logout()
from django.urls import path, re_path
from app import views
from app.views import UploadMateriHTML, DashboardKontributorView, UploadMateriView, ProfilKontributorView, SuntingProfilView
from app.views import UploadMateriHTML, DashboardKontributorView, UploadMateriView, ProfilKontributorView, SuntingProfilView, SuksesLoginKontributorView, SuksesLoginAdminView
urlpatterns = [
path("", views.DaftarKatalog.as_view(), name="daftar_katalog"),
......@@ -13,6 +13,7 @@ urlpatterns = [
path("unggah/", UploadMateriView.as_view(), name="unggah"),
path("profil/", ProfilKontributorView.as_view(), name="profil"),
path("sunting/", SuntingProfilView.as_view(), name="sunting"),
# Matches any html file
path("sukses-kontributor/", SuksesLoginKontributorView.as_view(), name="sukses-kontributor"),
path("sukses-admin/", SuksesLoginAdminView.as_view(), name="sukses-admin"),
re_path(r"^.*\.html", views.pages, name="pages"),
]
......@@ -249,6 +249,46 @@ class SuntingProfilView(TemplateView):
context["form"] = form
return self.render_to_response(context)
class SuksesLoginKontributorView(TemplateView):
template_name = "sukses_kontri.html"
def dispatch(self, request, *args, **kwargs):
if not request.user.is_contributor:
raise PermissionDenied(request)
return super(SuksesLoginKontributorView, self).dispatch(request, *args, **kwargs)
def get_context_data(self, **kwargs):
context = super(SuksesLoginKontributorView, self).get_context_data(**kwargs)
return context
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
current_user = self.request.user
context["user"] = current_user
return self.render_to_response(context)
class SuksesLoginAdminView(TemplateView):
template_name = "sukses_admin.html"