Fakultas Ilmu Komputer UI

Commit 6eebaaa5 authored by Samuel Dimas Partogi's avatar Samuel Dimas Partogi
Browse files

Revisi Materi oleh Kontributor

parent 3c22be34
......@@ -113,3 +113,15 @@ h2 {
.comment .text {
padding-left: 20px;
}
.feedback:hover,
.feedback:active {
cursor: pointer;
}
.black-text,
.black-text:hover,
.black-text:active {
color: black;
}
......@@ -29,19 +29,58 @@
<!-- Topbar Navbar -->
<ul class="navbar-nav ml-auto">
{% if request.user.is_contributor %}
{% if materi_data.status == "DISAPPROVE" %}
<li class="nav-item black-text">
<a class="nav-link feedback" data-toggle="modal" data-target="#umpanBalikModal">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">Umpan Balik Materi</span>
</a>
<div class="modal fade" id="umpanBalikModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title black-text" id="exampleModalLabel">Umpan Balik Materi</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
{% for item in report %}
<p class="black-text">Alasan materi ditolak:</p>
<p class="black-text">{{ item.report.feedback }}</p>
<p class="black-text">Untuk merevisi materi, sila tekan tombol perbarui di halaman riwayat unggah.</p>
{% endfor %}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">Tutup</button>
</div>
</div>
</div>
</div>
</li>
{% endif %}
{% endif %}
<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>
{% if request.user.is_contributor %}
<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>
{% endif %}
<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">
<a class="nav-link dropdown-toggle" href="/dashboard/">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">{{ user.name }}</span>
{% if not user.default_profile_picture %}
<img class="img-profile rounded-circle" src="https://i.ibb.co/9wgPzyZ/default-image.png" alt="User profile picture">
......@@ -172,7 +211,11 @@
<div class="col col-8 comment shadow-sm p-3 mb-1 bg-white rounded">
<div class="d-flex bd-highlight mb-3 align-items-center user">
{% if comment.user != Null %}
{% if not user.default_profile_picture %}
<img class="profile" src="https://i.ibb.co/9wgPzyZ/default-image.png" alt="profile-picture">
{% else %}
<img class="profile" src="{{ comment.user.profile_picture.url }}" alt="profile-picture">
{% endif %}
{% else %}
<span style="background-color: #{{comment.profile}}" class="profile p-1 bd-highligh"></span>
{% endif %}
......
......@@ -149,3 +149,4 @@
{% endblock %}
\ No newline at end of file
......@@ -162,9 +162,13 @@
<td>{{materi.author}}</td>
<td>{{materi.get_status_display}}</td>
<td class="verif-buttons">
<a href="/materi/{{materi.id}}/" class="accept-button"
style="background-color:#4e73df">Detail
</a>
<span>
<a href="/materi/{{materi.id}}/" class="accept-button button-decoration"
style="background-color:#4e73df">Detail</a>
{% if materi.get_status_display == "Ditolak" or materi.get_status_display == "Perbaikan" %}
<a href="/revisi/materi/{{materi.id}}/" class="reject-button button-decoration">Revisi</a>
{% endif %}
</span>
</td>
</tr>
{% endfor %}
......
{% 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>Revisi Materi | Digipus</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 -->
<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="{% url 'unggah' %}">
<span>Unggah Materi</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'dashboard' %}">
<span>Riwayat Unggah</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">
<span>Statisik Materi</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'comments' user.id %}">
<span>Komentar</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>
<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>
{% if not user.default_profile_picture %}
<img class="img-profile rounded-circle" src="https://i.ibb.co/9wgPzyZ/default-image.png" alt="User profile picture">
{% else %}
<img class="img-profile rounded-circle" src="{{ user.profile_picture.url }}" alt="User profile picture">
{% endif %}
</a>
</li>
</ul>
</nav>
<!-- End of Topbar -->
<!-- Begin Page Content -->
<div class="container-fluid">
<div class="container margin-content">
<div class="col-20">
<h1 class="mt-2">Revisi 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 revisi_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="/revisi/materi/{{materi.id}}/" 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>
</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>
</body>
</html>
\ No newline at end of file
......@@ -46,12 +46,12 @@
<!-- Nav Item - Dashboard -->
<li class="nav-item">
<a class="nav-link" href="{% url 'profil' %}">
<a class="nav-link" href="/profil-admin/">
<span>Halaman Profil</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'sunting' %}">
<a class="nav-link" href="/sunting-admin/">
<span>Sunting Profil</span></a>
</li>
......@@ -78,8 +78,8 @@
<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 class="nav-link" href="/administration/">
<span class="mr-2 d-none d-lg-inline text-gray-600 small">Administrasi</span>
</a>
</li>
......
......@@ -208,8 +208,6 @@
<i class="fas fa-angle-up"></i>
</a>
</body>
</html>
\ No newline at end of file
......@@ -15,7 +15,7 @@ from .models import Category, Comment, Materi, Like, ViewStatistics, DownloadSta
from .views import (DaftarKatalog, DashboardKontributorView, DetailMateri,
ProfilKontributorView, SuksesLoginAdminView,
SuksesLoginKontributorView, SuntingProfilView,
ProfilAdminView, CommentsView, SuntingProfilAdminView)
ProfilAdminView, CommentsView, SuntingProfilAdminView, RevisiMateriView)
from app.views import UploadMateriHTML, UploadMateriView
from authentication.models import User
......@@ -868,4 +868,64 @@ class DownloadMateriStatissticsTest(TestCase):
response = Client().get(self.url)
num_of_downloads = self.materi1.unduh.all().count()
self.assertEqual(num_of_downloads, 2)
\ No newline at end of file
self.assertEqual(num_of_downloads, 2)
class RevisiMateriTest(TestCase):
def setUp(self):
self.client = Client()
self.view = RevisiMateriView
self.template_name = "revisi.html"
self.contributor_credential = {
"email": "kontributor@gov.id",
"password": id_generator()
}
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="REVISION", cover=self.cover, content=self.content).save()
self.materi1 = Materi.objects.first()
self.url = "/revisi/materi/" + str(self.materi1.id) + "/"
def test_revisi_materi_view(self):
found = resolve(self.url)
self.assertEqual(found.func.__name__, self.view.as_view().__name__)
def test_revisi_materi_template(self):
# Login
self.client.login(**self.contributor_credential)
# Test
response = self.client.get(self.url)
self.assertTemplateUsed(response, self.template_name)
# Logout
self.client.logout()
def test_revisi_materi_url(self):
# Login
self.client.login(**self.contributor_credential)
# Test
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
# Logout
self.client.logout()
def test_revisi_materi_access(self):
# Kontributor
# Login
self.client.login(**self.contributor_credential)
# Test
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
# Logout
self.client.logout()
\ No newline at end of file
......@@ -15,6 +15,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/", DashboardKontributorView.as_view(), name="dashboard"),
path("revisi/materi/<int:pk>/", views.RevisiMateriView.as_view(), name="revisi"),
path("unggah/", UploadMateriView.as_view(), name="unggah"),
path("profil/", ProfilKontributorView.as_view(), name="profil"),
path("sunting/", SuntingProfilView.as_view(), name="sunting"),
......
......@@ -16,6 +16,7 @@ from django.urls import reverse
from django.views.generic import TemplateView, ListView
from .models import Category, Comment, Materi
from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger
from administration.models import VerificationReport
from app.forms import SuntingProfilForm, UploadMateriForm
from app.models import Category, Comment, Materi, Like, ViewStatistics, DownloadStatistics
from authentication.models import User
......@@ -78,6 +79,7 @@ class DetailMateri(TemplateView):
materi = get_object_or_404(Materi, pk=kwargs["pk"])
context["session_id"] = self.request.session.session_key
context["materi_data"] = materi
context["report"] = VerificationReport.objects.filter(materi=materi)
context["has_liked"] = Like.objects.filter(
materi=materi, session_id=self.request.session.session_key).exists()
return context
......@@ -429,6 +431,47 @@ class CommentsView(TemplateView):
context = self.get_context_data(**kwargs)
return self.render_to_response(context=context)
class RevisiMateriView(TemplateView):
template_name = "revisi.html"
def dispatch(self, request, *args, **kwargs):
if not request.user.is_contributor:
raise PermissionDenied(request)
return super(RevisiMateriView, self).dispatch(request, *args, **kwargs)
def get_context_data(self, **kwargs):
context = super(RevisiMateriView, self).get_context_data(**kwargs)
current_materi = get_object_or_404(Materi, pk=kwargs["pk"])
context["materi"] = current_materi
context["revisi_form"] = UploadMateriForm(instance=current_materi)
return context
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
return self.render_to_response(context)
def post(self,request, *args, **kwargs):
if request.user.is_authenticated == False:
raise PermissionDenied(request)
current_materi = get_object_or_404(Materi, pk=kwargs["pk"])
form = UploadMateriForm(
request.POST, request.FILES, instance=current_materi)
if form.is_valid():
materi = form.save(commit=False)
materi.uploader = request.user
materi.status = "REVISION"
materi.save()
kateg = form.cleaned_data['categories']
for i in kateg:
materi.categories.add(i)
materi.save()
return HttpResponseRedirect("/dashboard/")
else:
context = self.get_context_data(**kwargs)
context["form_revisi"] = form
return self.render_to_response(context)
def pages(request):
context = {}
# All resource paths end in .html.
......
......@@ -111,4 +111,9 @@
.admin-page {
padding-left: 0;
}
.margin-content {
margin: 0;
padding: 0;
}
\ No newline at end of file
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