Fakultas Ilmu Komputer UI

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

Merge branch 'optimization' into 'staging'

Optimization

See merge request ppl-fasilkom-ui/2020/ppl-c/diskominfo-depok-digipus/marjinal-digipus!63
parents c4793fd3 9945df2f
# Generated by Django 3.0.3 on 2020-06-03 12:57
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('administration', '0004_auto_20200517_1713'),
]
operations = [
migrations.CreateModel(
name='DeletionHistory',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('deleted_user_name', models.CharField(max_length=150)),
('deleted_user_role', models.CharField(max_length=150)),
('timestamp', models.DateTimeField(default=django.utils.timezone.now)),
('deletor_admin', models.ForeignKey(null=True, on_delete=django.db.models.deletion.SET_NULL, to=settings.AUTH_USER_MODEL)),
],
),
]
......@@ -19,3 +19,9 @@ class VerificationReport(models.Model):
timestamp = models.DateTimeField(default=timezone.now)
status = models.CharField(
max_length=30, choices=VERIFICATION_STATUS, default=VERIFICATION_STATUS[0][0])
class DeletionHistory(models.Model):
deleted_user_name = models.CharField(max_length=150)
deleted_user_role = models.CharField(max_length=150)
timestamp = models.DateTimeField(default=timezone.now)
deletor_admin = models.ForeignKey(User, on_delete=models.SET_NULL, null=True)
\ No newline at end of file
......@@ -186,6 +186,40 @@
<a class="btn btn-primary btn-admin" href="/administration/kelola-admin/">Kembali ke Kelola Admin</a>
</div>
</div>
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary" id="titleTabelPending">Daftar Pengguna yang Pernah Dihapus</h6>
</div>
<div class="card-body">
<div class="table-responsive">
<table class="table table-bordered" id="dataTablePending" aria-describedby="titleTabelPending">
<thead>
<tr>
<th scope="col">Nama</th>
<th scope="col">Peran</th>
<th scope="col">Waktu Penghapusan</th>
</tr>
</thead>
<tfoot>
<tr>
<th scope="col">Nama</th>
<th scope="col">Peran</th>
<th scope="col">Waktu Penghapusan</th>
</tr>
</tfoot>
<tbody>
{% for history in deletion_history %}
<tr>
<td>{{ history.deleted_user_name }}</td>
<td>{{ history.deleted_user_role }}</td>
<td>{{ history.timestamp }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
</div>
<!-- /.container-fluid -->
......
......@@ -184,9 +184,9 @@
<td>{{ user.instansi }}</td>
<td class="verif-buttons">
<span>
<a href="/administration/profil/{{ current.id }}/" class="accept-button button-decoration">Detail</a>
<button type="button" class="reject-button button-decoration" data-toggle="modal" data-target="#confirmModal{{ current.id }}">Hapus</button>
<div class="modal fade" id="confirmModal{{ current.id }}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<a href="/administration/profil/{{ user.id }}/" class="accept-button button-decoration">Detail</a>
<button type="button" class="reject-button button-decoration" data-toggle="modal" data-target="#confirmModal{{ user.id }}">Hapus</button>
<div class="modal fade" id="confirmModal{{ user.id }}" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
......@@ -200,7 +200,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Batal</button>
<a href="/administration/hapus-kontributor/{{current.id}}/" type="button" class="btn btn-danger">Hapus</a>
<a href="/administration/hapus-kontributor/{{user.id}}/" type="button" class="btn btn-danger">Hapus</a>
</div>
</div>
</div>
......
......@@ -6,7 +6,7 @@ from django.http import HttpResponseRedirect, JsonResponse
from django.shortcuts import get_object_or_404, render
from django.views.generic import TemplateView, View
from django.contrib import messages
from administration.models import VerificationReport, VerificationSetting
from administration.models import VerificationReport, VerificationSetting, DeletionHistory
from administration.forms import CategoryForm, VerificationSettingForm, RegistrasiAdminForm, PeriodForm
from app.models import Category, Materi
from authentication.models import User
......@@ -50,7 +50,10 @@ class DetailVerificationView(TemplateView):
context["materi_data"] = materi
context["kriteria_list"] = VerificationSetting.objects.filter(
archived=False)
riwayat = True if materi.status != "PENDING" else False
if materi.status == "PENDING" or materi.status == "REVISION":
riwayat = False
else:
riwayat = True
context["riwayat"] = riwayat
context["verification_report"] = materi.verificationreport_set.first()
return context
......@@ -198,7 +201,6 @@ class KelolaAdminView(TemplateView):
context = self.get_context_data(**kwargs)
return self.render_to_response(context)
class ProfileContributorAdminView(TemplateView):
template_name = "detail_kontri_admin.html"
......@@ -216,7 +218,6 @@ class ProfileContributorAdminView(TemplateView):
context["user"] = get_object_or_404(User, pk=kwargs["pk"])
return self.render_to_response(context=context)
class StatisticsView(TemplateView):
template_name = "administration/data_statistik.html"
......@@ -260,6 +261,7 @@ class ProfileAdminAdministrationView(TemplateView):
def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs)
context["user"] = get_object_or_404(User, pk=kwargs["pk"])
context["deletion_history"] = DeletionHistory.objects.filter(deletor_admin=get_object_or_404(User, pk=kwargs["pk"]))
return self.render_to_response(context=context)
......@@ -362,6 +364,14 @@ class EditCategoryView(TemplateView):
def delete_admin(request, *args, **kwargs):
if not request.user.is_authenticated or not request.user.is_admin:
raise PermissionDenied(request)
user_to_be_deleted = User.objects.get(pk=kwargs["pk"])
DeletionHistory.objects.create(
deleted_user_name=user_to_be_deleted.name,
deleted_user_role="Admin",
deletor_admin=request.user
)
User.objects.filter(pk=kwargs["pk"]).delete()
return HttpResponseRedirect("/administration/kelola-admin/")
......@@ -369,6 +379,14 @@ def delete_admin(request, *args, **kwargs):
def delete_contributor(request, *args, **kwargs):
if not request.user.is_authenticated or not request.user.is_admin:
raise PermissionDenied(request)
user_to_be_deleted = User.objects.get(pk=kwargs["pk"])
DeletionHistory.objects.create(
deleted_user_name=user_to_be_deleted.name,
deleted_user_role="Kontributor",
deletor_admin=request.user
)
User.objects.filter(pk=kwargs["pk"]).delete()
return HttpResponseRedirect("/administration/kelola-kontributor/")
......
......@@ -48,7 +48,7 @@
{% 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>
<p class="black-text">Untuk merevisi materi, sila tekan tombol revisi di halaman riwayat unggah.</p>
{% endfor %}
</div>
<div class="modal-footer">
......
......@@ -121,7 +121,7 @@
<div class="col-20">
<h1 class="mt-2">Sunting Profil</h1>
<hr class="mt-0 mb-4">
<form id="add_form" method="POST" action="{% url 'sunting' %}" novalidate enctype="multipart/form-data">
<form id="add_form" method="POST" action="{% url 'sunting-admin' %}" novalidate enctype="multipart/form-data">
{% csrf_token %}
{% for field in form %}
<div class="col-md-6">
......
......@@ -83,6 +83,7 @@
.btn-admin {
margin-top: 20px;
margin-bottom: 20px;
}
.page-height {
......
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