Fakultas Ilmu Komputer UI

Commit 7624509d authored by Saul Andre's avatar Saul Andre
Browse files

Merge branch 'staging' of...

Merge branch 'staging' of https://gitlab.cs.ui.ac.id/ppl-fasilkom-ui/2020/ppl-c/diskominfo-depok-digipus/marjinal-digipus into PBI-7-Detail_Materi-NEW
parents 67e2cb06 13b69c88
......@@ -123,10 +123,12 @@
</div>
</div>
</div>
<div class="col-9 books">
{% for item in materi_list %}
<div class="card book">
<img src={{item.cover.url}} class="card-img-top" alt="cover"></img>
<img src={{item.cover.url}} class="card-img-top" alt="cover"
style="height:200px; widows: 200px;; overflow: hidden;"></img>
<div class="card-body">
<h5 class="card-title">{{item.title}}</h5>
<p class="card-text">{{item.author}}</p>
......@@ -136,9 +138,9 @@
</div>
{% endfor %}
</div>
</div>
</div>
</div>
<!-- /.container -->
</body>
......
{% 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 Admin</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">
<!-- 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="/profil-admin/">
<span>Halaman Profil</span></a>
</li>
<!--
<li class="nav-item">
<a class="nav-link" href="/sunting/">
<span>Sunting Profil</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="/administration/">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">Administrasi</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/profil-admin/">
<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>
<!-- 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>
</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
......@@ -134,7 +134,9 @@
<div class="col-md-6">
<div class="fieldWrapper">
{{ field.label_tag }} {{ field }}
<p> </p>
{{ field.errors }}
<p> </p>
{% if field.help_text %}
<p class="help">{{ field.help_text|safe }}</p>
{% endif %}
......
......@@ -14,7 +14,8 @@ from authentication.models import User
from .models import Category, Comment, Materi
from .views import (DaftarKatalog, DashboardKontributorView, DetailMateri,
ProfilKontributorView, SuksesLoginAdminView,
SuksesLoginKontributorView, SuntingProfilView)
SuksesLoginKontributorView, SuntingProfilView,
ProfilAdminView)
class DaftarKatalogTest(TestCase):
......@@ -299,6 +300,43 @@ class DashboardKontributorViewTest(TestCase):
response = self.client.get(self.url)
self.assertEqual(response.status_code, 403)
class ProfilAdminTest(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 = "/profil-admin/"
self.view = ProfilAdminView
self.template_name = "profil-admin.html"
def test_profil_Admin_view(self):
found = resolve(self.url)
self.assertEqual(found.func.__name__, self.view.as_view().__name__)
def test_profil_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_profil_admin_url(self):
# Login
response = self.client.get(self.url)
self.assertNotEqual(response.status_code, 200)
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()
class ProfilKontributorTest(TestCase):
def setUp(self):
......
......@@ -3,7 +3,8 @@ from django.urls import path, re_path
from app import views
from app.views import (DashboardKontributorView, ProfilKontributorView,
SuksesLoginAdminView, SuksesLoginKontributorView,
SuntingProfilView, UploadMateriHTML, UploadMateriView)
SuntingProfilView, UploadMateriHTML, UploadMateriView,
ProfilAdminView)
urlpatterns = [
path("", views.DaftarKatalog.as_view(), name="daftar_katalog"),
......@@ -20,4 +21,5 @@ urlpatterns = [
name="sukses-kontributor"),
path("sukses-admin/", SuksesLoginAdminView.as_view(), name="sukses-admin"),
re_path(r"^.*\.html", views.pages, name="pages"),
path("profil-admin/", ProfilAdminView.as_view(), name="profil-admin"),
]
......@@ -10,15 +10,17 @@ from django.http import (Http404, HttpResponse, HttpResponseRedirect,
JsonResponse)
from django.shortcuts import get_object_or_404, redirect, render
from django.template import loader
from django.views.generic import TemplateView
from django.views.generic import TemplateView, ListView
from authentication.models import User
from .forms import SuntingProfilForm, UploadMateriForm
from .models import Category, Comment, Materi
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
class DaftarKatalog(TemplateView):
paginate_by = 2
template_name = "app/katalog_materi.html"
def get_context_data(self, **kwargs):
......@@ -161,6 +163,9 @@ class UploadMateriView(TemplateView):
materi = form.save(commit=False)
materi.uploader = request.user
materi.save()
kateg = form.cleaned_data['categories']
for i in kateg:
materi.categories.add(i)
return HttpResponseRedirect("/unggah/")
else:
context = self.get_context_data(**kwargs)
......@@ -205,6 +210,23 @@ class DashboardKontributorView(TemplateView):
context["materi_list"] = materi_list
return self.render_to_response(context)
class ProfilAdminView(TemplateView):
template_name = "profil-admin.html"
def dispatch(self, request, *args, **kwargs):
if not request.user.is_authenticated or not request.user.is_admin:
raise PermissionDenied(request)
return super(ProfilAdminView, self).dispatch(request, *args, **kwargs)
def get_context_data(self, **kwargs):
context = super(ProfilAdminView, 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 ProfilKontributorView(TemplateView):
template_name = "profil.html"
......
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