Fakultas Ilmu Komputer UI

Commit a3d532b6 authored by Mutia Rahmatun Husna's avatar Mutia Rahmatun Husna
Browse files

[REFACTOR] edit navbar code

parents 764cffe7 bdacd895
Pipeline #60478 passed with stages
in 21 minutes and 40 seconds
{% extends 'administration/base_administrasi.html' %}
{% load static %}
{% block content %}
<div class="card shadow mb-4">
<div class="card-header py-3">
<h6 class="m-0 font-weight-bold text-primary">
Edit {{ page_title }}
</h6>
</div>
<div class="card-body">
<form method="POST">
{% csrf_token %}
{{ item.name }}
<div class="status d-flex align-items-baseline">
{{ form.is_active }} <br> Active
</div>
<div class="">
<button class="btn-sm btn-primary rounded p-12" type="submit">
<i class="far fa-save" aria-hidden="true"></i>
Simpan
</button>
</div>
</form>
</div>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'administration/base_administrasi2.html' %} {% extends 'administration/base_administrasi2.html' %}
{% load static %}
{% block title %} {% block title %}
<title>Kelola Admin | Digipus</title> <title>Kelola Admin | Digipus</title>
......
{% load static %} {% extends 'administration/base_administrasi2.html' %}
<!DOCTYPE html> {% block title %}
<html lang="en"> <title>Dasbor - Kelola Admin</title>
{% endblock %}
<head>
{% block content %}
<meta charset="utf-8"> <h1 class="h3 mb-2 text-gray-800">Registrasi Admin</h1>
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <div class="form-margin"></div>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <div class="container admin-page">
<meta name="description" content=""> <div class="col-20">
<meta name="author" content=""> <form id="add_form" method="POST" novalidate enctype="multipart/form-data">
{% csrf_token %}
<title>Dasbor - Kelola Admin</title> <div class="col-md-6 admin-page">
<div class="fieldWrapper">
<!-- Custom fonts for this template --> {{ form.name.errors }}
<link href="https://fonts.googleapis.com/css2?family=Poppins&display=swap" rel="stylesheet"> <label for="{{ form.subject.id_for_label }}">Nama:</label>
{{ form.name }}
<!-- Custom styles for this template --> </div>
<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>
<div class="sidebar-brand-text mx-3">Digipus</div> <div class="col-md-6 admin-page">
</a> <div class="fieldWrapper">
{{ form.instansi.errors }}
<!-- Divider --> <label for="{{ form.subject.id_for_label }}">Instansi:</label>
<hr class="sidebar-divider my-0"> {{ form.instansi }}
</div>
<!-- Nav Item - Dashboard --> </div>
<li class="nav-item"> <div class="col-md-6 admin-page">
<a class="nav-link" href="/administration/"> <div class="fieldWrapper">
<span>Verifikasi Materi</span></a> {{ form.nik.errors }}
</li> <label for="{{ form.subject.id_for_label }}">NIK:</label>
{{ form.nik }}
<li class="nav-item"> </div>
<a class="nav-link" href="#"> </div>
<span>Statistik Materi</span></a> <div class="col-md-6 admin-page">
</li> <div class="fieldWrapper">
{{ form.alamat.errors }}
<li class="nav-item"> <label for="{{ form.subject.id_for_label }}">Alamat:</label>
<a class="nav-link" href="/administration/laporan-materi/"> {{ form.alamat }}
<span>Laporan Materi</span></a> </div>
</li> </div>
<div class="col-md-6 admin-page">
<!-- Divider --> <div class="fieldWrapper">
<hr class="sidebar-divider my-0"> {{ form.email.errors }}
<label for="{{ form.subject.id_for_label }}">Email:</label>
<li class="nav-item"> {{ form.email }}
<a class="nav-link" href="/administration/setting/verification/"> </div>
<span>Pengaturan Verifikasi</span></a> </div>
</li> <div class="col-md-6 admin-page">
<div class="fieldWrapper">
<li class="nav-item"> {{ form.nomor_telpon.errors }}
<a class="nav-link" href="/administration/setting/category/"> <label for="{{ form.subject.id_for_label }}">Nomor Telepon:</label>
<span>Pengaturan Kategori</span></a> {{ form.nomor_telpon }}
</li> </div>
</div>
<!-- Divider --> <div class="col-md-6 admin-page">
<hr class="sidebar-divider my-0"> <div class="fieldWrapper">
{{ form.password.errors }}
<li class="nav-item"> <label for="{{ form.subject.id_for_label }}">Kata Sandi:</label>
<a class="nav-link" href="/administration/kelola-kontributor/"> {{ form.password }}
<span>Kelola Kontributor</span></a> </div>
</li> </div>
<div class="col-md-6 admin-page">
<li class="nav-item"> <div class="fieldWrapper">
<a class="nav-link" href="/administration/kelola-admin/"> {{ form.password2.errors }}
<span>Kelola Admin</span></a> <label for="{{ form.subject.id_for_label }}">Ulang Kata Sandi:</label>
</li> {{ form.password2 }}
</div>
<!-- Divider -->
<hr class="sidebar-divider my-0">
</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">
<em class="fa fa-bars"></em>
</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">Administrasi</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">
<!-- Page Heading -->
<h1 class="h3 mb-2 text-gray-800">Registrasi Admin</h1>
<div class="form-margin"></div>
<div class="container admin-page">
<div class="col-20">
<form id="add_form" method="POST" novalidate enctype="multipart/form-data">
{% csrf_token %}
<div class="col-md-6 admin-page">
<div class="fieldWrapper">
{{ form.name.errors }}
<label for="{{ form.subject.id_for_label }}">Nama:</label>
{{ form.name }}
</div>
</div>
<div class="col-md-6 admin-page">
<div class="fieldWrapper">
{{ form.instansi.errors }}
<label for="{{ form.subject.id_for_label }}">Instansi:</label>
{{ form.instansi }}
</div>
</div>
<div class="col-md-6 admin-page">
<div class="fieldWrapper">
{{ form.nik.errors }}
<label for="{{ form.subject.id_for_label }}">NIK:</label>
{{ form.nik }}
</div>
</div>
<div class="col-md-6 admin-page">
<div class="fieldWrapper">
{{ form.alamat.errors }}
<label for="{{ form.subject.id_for_label }}">Alamat:</label>
{{ form.alamat }}
</div>
</div>
<div class="col-md-6 admin-page">
<div class="fieldWrapper">
{{ form.email.errors }}
<label for="{{ form.subject.id_for_label }}">Email:</label>
{{ form.email }}
</div>
</div>
<div class="col-md-6 admin-page">
<div class="fieldWrapper">
{{ form.nomor_telpon.errors }}
<label for="{{ form.subject.id_for_label }}">Nomor Telepon:</label>
{{ form.nomor_telpon }}
</div>
</div>
<div class="col-md-6 admin-page">
<div class="fieldWrapper">
{{ form.password.errors }}
<label for="{{ form.subject.id_for_label }}">Kata Sandi:</label>
{{ form.password }}
</div>
</div>
<div class="col-md-6 admin-page">
<div class="fieldWrapper">
{{ form.password2.errors }}
<label for="{{ form.subject.id_for_label }}">Ulang Kata Sandi:</label>
{{ form.password2 }}
</div>
</div>
<div class="form-margin"></div>
<div class="col-md-6 admin-page">
<div class="d-flex flex-row">
<div class="p-2">
<button type="submit" class="btn btn-success btn-edit" style="background-color: #615CFD; border-color: #615CFD;">Simpan</button>
</div>
<div class="p-2">
<a href="/administrasi/kelola-admin" class="btn btn-secondary">Kembali Ke Kelola Admin</a>
</div>
</div>
<div class="fieldWrapper">
</div>
</div>
</form>
</div>
</div>
</div> </div>
<!-- /.container-fluid -->
</div> <div class="form-margin"></div>
<!-- End of Main Content --> <div class="col-md-6 admin-page">
<div class="d-flex flex-row">
<div class="p-2">
<button type="submit" class="btn btn-success btn-edit"
style="background-color: #615CFD; border-color: #615CFD;">Simpan</button>
</div>
<div class="p-2">
<a href="/administration/kelola-admin" class="btn btn-secondary">Kembali Ke Kelola Admin</a>
</div>
</div>
<div class="fieldWrapper">
<!-- 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>
</div> </div>
</footer> </form>
<!-- End of Footer -->
</div> </div>
<!-- End of Content Wrapper -->
</div> </div>
<!-- End of Page Wrapper --> {% endblock %}
\ No newline at end of file
<!-- Scroll to Top Button-->
<a class="scroll-to-top rounded" href="#page-top">
<em class="fas fa-angle-up"></em>
</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
...@@ -9,9 +9,10 @@ from django.utils import timezone ...@@ -9,9 +9,10 @@ from django.utils import timezone
from administration.models import VerificationReport, VerificationSetting, DeletionHistory from administration.models import VerificationReport, VerificationSetting, DeletionHistory
from administration.forms import CategoryForm, VerificationSettingForm, RegistrasiAdminForm, PeriodForm, EditAdminStatusForm, EditKontributorStatusForm from administration.forms import CategoryForm, VerificationSettingForm, RegistrasiAdminForm, PeriodForm, EditAdminStatusForm, EditKontributorStatusForm
from administration.services import StatisticService, DetailVerificationService, LaporanMateriService from administration.services import StatisticService, DetailVerificationService, LaporanMateriService
from app.models import Category, Materi, ViewStatistics, DownloadStatistics, Comment, Like, LaporanMateri from app.models import Category, Materi, ViewStatistics, DownloadStatistics, Comment, Like, LaporanMateri, AdminNotification
from authentication.models import User from authentication.models import User
from datetime import datetime from datetime import datetime
from app.models import NotifikasiKontributor
from administration.utils import generate_time_step from administration.utils import generate_time_step
...@@ -82,11 +83,17 @@ class DetailVerificationView(TemplateView): ...@@ -82,11 +83,17 @@ class DetailVerificationView(TemplateView):
verif_report = VerificationReport( verif_report = VerificationReport(
report=report, materi=materi, user=self.request.user, status=materi.get_status_display()) report=report, materi=materi, user=self.request.user, status=materi.get_status_display())
verif_report.save() verif_report.save()
new_kontributor_notif = NotifikasiKontributor(materi=materi, user=materi.uploader, feedback=materi.get_status_display())
new_kontributor_notif.save()
return HttpResponseRedirect("/administration/") return HttpResponseRedirect("/administration/")
def get(self, request, *args, **kwargs): def get(self, request, *args, **kwargs):
context = self.get_context_data(**kwargs) context = self.get_context_data(**kwargs)
if(request.user.is_admin):
AdminNotification.objects.filter(materi=context["materi_data"]).delete()
return self.render_to_response(context=context) return self.render_to_response(context=context)
...@@ -421,7 +428,7 @@ class EditAdminStatusView(TemplateView): ...@@ -421,7 +428,7 @@ class EditAdminStatusView(TemplateView):
class EditKontributorStatusView(TemplateView): class EditKontributorStatusView(TemplateView):
template_name = "edit_kontributor.html" template_name = "edit_admin.html"
def dispatch(self, request, *args, **kwargs): def dispatch(self, request, *args, **kwargs):
if not request.user.is_authenticated or not request.user.is_admin: if not request.user.is_authenticated or not request.user.is_admin:
...@@ -583,6 +590,8 @@ def blok_materi(request, *args, **kwargs): ...@@ -583,6 +590,8 @@ def blok_materi(request, *args, **kwargs):
if materi.status == "APPROVE" and LaporanMateri.objects.filter(is_rejected=False, materi_id=materi.id): if materi.status == "APPROVE" and LaporanMateri.objects.filter(is_rejected=False, materi_id=materi.id):
materi.status = "BLOCKED" materi.status = "BLOCKED"
materi.save() materi.save()
new_kontributor_notif = NotifikasiKontributor(materi=materi, user=materi.uploader, feedback=materi.get_status_display())
new_kontributor_notif.save()
return HttpResponseRedirect(ADMINISTRATION_REPORT) return HttpResponseRedirect(ADMINISTRATION_REPORT)
......
from django.contrib import admin from django.contrib import admin
from .models import AdminNotification
# Register your models here. # Register your models here.
admin.site.register(AdminNotification)
\ No newline at end of file
from django import forms from django import forms
from app.models import Materi, Category, RatingContributor from app.models import Materi, Category, RatingContributor, GuestBook
from authentication.models import User from authentication.models import User
import datetime import datetime
def year_choices(): def year_choices():
return[(r,r) for r in range(2000, datetime.date.today().year+1)] return[(r, r) for r in range(2000, datetime.date.today().year+1)]
class UploadMateriForm(forms.ModelForm): class UploadMateriForm(forms.ModelForm):
categories = forms.ModelMultipleChoiceField(queryset=Category.objects.all(),widget=forms.CheckboxSelectMultiple(attrs={'style' : 'column-count:2'}),required=True) categories = forms.ModelMultipleChoiceField(queryset=Category.objects.all(
release_year = forms.TypedChoiceField(coerce=int, choices=year_choices, initial=datetime.date.today().year) ), widget=forms.CheckboxSelectMultiple(attrs={'style': 'column-count:2'}), required=True)
yt_video_id = forms.CharField(label="Youtube Video Id", \ release_year = forms.TypedChoiceField(
help_text="This is not required.<br>\ coerce=int, choices=year_choices, initial=datetime.date.today().year)
yt_video_id = forms.CharField(label="Youtube Video Id",
help_text="This is not required.<br>\
Please insert only Youtube link videos! Take a note for the video id!<br>\ Please insert only Youtube link videos! Take a note for the video id!<br>\
Example : https://www.youtube.com/watch?v=DkJ-50GLi2I <br> has video id DkJ-50GLi2I", required=False) Example : https://www.youtube.com/watch?v=DkJ-50GLi2I <br> has video id DkJ-50GLi2I", required=False)
...@@ -29,14 +33,13 @@ class UploadMateriForm(forms.ModelForm): ...@@ -29,14 +33,13 @@ class UploadMateriForm(forms.ModelForm):
field.widget.attrs["class"] = "form-control" field.widget.attrs["class"] = "form-control"
field.widget.attrs["placeholder"] = field.initial field.widget.attrs["placeholder"] = field.initial
field.initial = "" field.initial = ""
self.fields['categories'].widget.attrs.update({'class' : "native"}) self.fields['categories'].widget.attrs.update({'class': "native"})
class SuntingProfilForm(forms.ModelForm): class SuntingProfilForm(forms.ModelForm):
class Meta: class Meta:
model = User model = User
fields = ["email","name","instansi", "nik", "alamat", "nomor_telpon", fields = ["email", "name", "instansi", "nik", "alamat", "nomor_telpon",
"profile_picture", "linkedin", "profile_picture", "linkedin",
"facebook", "twitter", "instagram", "biography", "facebook", "twitter", "instagram", "biography",
"is_subscribing_to_material_comments"] "is_subscribing_to_material_comments"]
...@@ -50,7 +53,6 @@ class SuntingProfilForm(forms.ModelForm): ...@@ -50,7 +53,6 @@ class SuntingProfilForm(forms.ModelForm):
if any(self.errors): if any(self.errors):
key = list(self.errors)[0] key = list(self.errors)[0]
self.fields[key].widget.attrs["autofocus"] = "" self.fields[key].widget.attrs["autofocus"] = ""
self.fields["email"].widget.attrs["readonly"] = True self.fields["email"].widget.attrs["readonly"] = True
...@@ -61,14 +63,43 @@ class RatingContributorForm(forms.ModelForm): ...@@ -61,14 +63,43 @@ class RatingContributorForm(forms.ModelForm):
fields = ['score', 'user', 'contributor'] fields = ['score', 'user', 'contributor']
SCORE_CHOICE = ( SCORE_CHOICE = (
('', 'Select score'), ('', 'Select score'),
('1', '1'), # First one is the value of select option and second is the displayed value in option # First one is the value of select option and second is the displayed value in option
('1', '1'),
('2', '2'), ('2', '2'),
('3', '3'), ('3', '3'),
('4', '4'), ('4', '4'),
('5', '5'), ('5', '5'),
) )
widgets = { widgets = {
'score': forms.Select(choices=SCORE_CHOICE, attrs={'class': 'form-control', 'id':'form-rating'},), 'score': forms.Select(choices=SCORE_CHOICE, attrs={'class': 'form-control', 'id': 'form-rating'},),
'user': forms.HiddenInput(), 'user': forms.HiddenInput(),
'contributor': forms.HiddenInput() 'contributor': forms.HiddenInput()
} }
class GuestBookForm(forms.models.ModelForm):
class Meta:
model = GuestBook
fields = ['name', 'job', 'gender']
gender_choices = (
('Male', 'Male'),
('Female', 'Female')
)
widgets = {
'name': forms.fields.TextInput(attrs={
'placeholder': 'Input your name',
'class': 'form-control input-lg'
}),
'job': forms.fields.TextInput(attrs={
'placeholder': 'Input your job',
'class': 'form-control input-lg'
}),