Fakultas Ilmu Komputer UI

Commit e0f49fd1 authored by Bunga Amalia Kurniawati's avatar Bunga Amalia Kurniawati 🌺
Browse files

Merge branch 'master' of...

Merge branch 'master' of https://gitlab.cs.ui.ac.id/pmpl/class-project/marjinal-digipus into 1706022104-125
parents 9d89111a b034328f
Pipeline #60112 passed with stages
in 20 minutes and 26 seconds
......@@ -4,21 +4,24 @@ import random
import shutil
from functools import cmp_to_key
import requests
from administration.models import VerificationReport
from digipus import settings
from django.contrib import messages
from django.contrib.auth.models import AnonymousUser
from django.core.exceptions import ValidationError
from django.db.models import Case, When, Count, Q
from django.db.models import Case, Count, Q, When
from django.shortcuts import get_object_or_404
from django.utils import timezone
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from administration.models import VerificationReport
from app.forms import SuntingProfilForm
from app.models import Category, Like, LikeComment, DislikeComment, Materi, Comment, Rating, DownloadStatistics, \
ViewStatistics, ReadLater
from app.utils.fileManagementUtil import get_random_filename, remove_image_exifdata
from digipus import settings
import requests
from app.models import (Category, Comment, DislikeComment, DownloadStatistics,
Like, LikeComment, Materi, Rating, ReadLater,
ViewStatistics)
from app.utils.fileManagementUtil import (get_random_filename,
remove_image_exifdata)
class DafterKatalogService:
......@@ -162,7 +165,7 @@ class CitationService:
@staticmethod
def get_citation_ieee(request, materi):
current_date = datetime.datetime.now()
current_date = timezone.now()
current_day = str(current_date.day)
current_month = current_date.strftime("%b")
current_year = str(current_date.year)
......@@ -485,4 +488,4 @@ class ReadLaterService:
else:
ReadLater(materi=materi, user=current_user).save()
response = {"success": True, "read_later_checked": True}
return response
\ No newline at end of file
return response
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<title>Digipus</title>
<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="">
{% block title %}{% endblock %}
<!-- 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 -->
-->
</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 -->
</nav>
<!-- End of Topbar -->
<!-- Begin Page Content -->
<div class="container-fluid">
{% block content %}{% endblock %}
</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">
<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
{% extends 'app/base_reset.html' %}
{% block title %}Reset Password{% endblock%}
{% block content %}
<h1> Reset Password </h1>
<br/><br/>
<p>Forgotten your password ? Enter email address below, and we'll email instructions for setting a new one.</p>
<div class = "from-group">
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button class="btn btn-secondary"> Submit</button>
</form>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'app/base_reset.html' %}
{% block title %}Password reset complete{% endblock%}
{% block content %}
<h1> Password reset complete </h1>
<br/><br/>
<p>Your password has been set. You may go ahead and log in now.</p>
<a href='/login'>Log in</a>
{% endblock %}
\ No newline at end of file
{% extends 'app/base_reset.html' %}
{% block title %}Enter new password{% endblock%}
{% block content %}
<h1> Enter new password </h1>
<br/><br/>
<div class = "from-group">
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button class="btn btn-secondary"> Update Password</button>
</form>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'app/base_reset.html' %}
{% block title %}Password reset sent{% endblock%}
{% block content %}
<h1> Password reset sent </h1>
<br/><br/>
<p>We’ve emailed you instructions for setting your password, if an account exists with the email you entered. You should receive them shortly.</p>
<br/>
<p>If you don’t receive an email, please make sure you’ve entered the address you registered with, and check your spam folder.</p>
{% endblock %}
\ No newline at end of file
import json, tempfile, os, mock, base64
import pandas as pd
from io import StringIO
import base64
import datetime as dt
import json
import os
import random
import re
import tempfile
import time
import random
from django.test import override_settings
from datetime import datetime
from io import StringIO
from time import sleep
import mock
import pandas as pd
import pytz
from administration.models import VerificationReport, VerificationSetting
from administration.utils import id_generator
from authentication.models import User
from bs4 import BeautifulSoup
from datetime import datetime
from digipus.settings import TIME_ZONE
from django.conf import settings
from django.contrib import messages as dj_messages
from django.contrib.auth import get_user_model
from django.core import mail, serializers
from django.core.files import File
from django.core.exceptions import PermissionDenied, ValidationError
from django.core.files import File
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.management import call_command
from django.test import Client, TestCase, TransactionTestCase
from django.urls import resolve, reverse
from django.db.utils import IntegrityError
from django.test import Client, RequestFactory, TestCase, TransactionTestCase
from pytz import timezone
from time import sleep
import datetime as dt
from django.test import (Client, RequestFactory, TestCase, TransactionTestCase,
override_settings)
from django.urls import resolve, reverse
from django.utils import timezone
from administration.models import VerificationSetting, VerificationReport
from administration.utils import id_generator
from app.views import UploadMateriHTML, add_rating_materi
from authentication.models import User
from digipus.settings import TIME_ZONE
from .models import (
Category,
Comment,
Review,
DislikeComment,
DownloadStatistics,
Materi,
Like,
LikeComment,
Rating,
ReqMaterial,
RatingContributor,
ViewStatistics,
ReadLater
)
from .services import (
DetailMateriService,
)
from .views import (
DaftarKatalog,
DashboardKontributorView,
DetailMateri,
ProfilView,
SuntingProfilView,
SuksesLoginAdminView,
SuksesLoginKontributorView,
PostsView,
RevisiMateriView,
ReqMateriView,
KatalogPerKontributorView,
UploadMateriView,
UploadMateriExcelView,
PasswordChangeViews,
password_success,
MateriFavorite,
)
from app.forms import SuntingProfilForm, year_choices
from app.utils.fileManagementUtil import get_random_filename, remove_image_exifdata
from app.utils.fileManagementUtil import (get_random_filename,
remove_image_exifdata)
from app.utils.PasswordValidator import PasswordPolicyValidator
from app.views import UploadMateriHTML, add_rating_materi
from .models import (Category, Comment, DislikeComment, DownloadStatistics,
Like, LikeComment, Materi, Rating, RatingContributor,
ReadLater, ReqMaterial, Review, ViewStatistics)
from .services import DetailMateriService
from .views import (DaftarKatalog, DashboardKontributorView, DetailMateri,
KatalogPerKontributorView, MateriFavorite,
PasswordChangeViews, PostsView, ProfilView, ReqMateriView,
RevisiMateriView, SuksesLoginAdminView,
SuksesLoginKontributorView, SuntingProfilView,
UploadMateriExcelView, UploadMateriView, password_success)
ERROR_403_MESSAGE = "Kamu harus login untuk mengakses halaman ini"
from statistics import mean
import requests
from django.test import LiveServerTestCase
from selenium import webdriver
from selenium.common.exceptions import NoSuchElementException
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from webdriver_manager.chrome import ChromeDriverManager
from selenium.common.exceptions import NoSuchElementException
import requests
from statistics import mean
class DaftarKatalogTest(TestCase):
......@@ -384,7 +362,7 @@ class DetailMateriTest(TestCase):
self.materi_with_published_date = Materi.objects.create(title="Materi 1", author="Agas", uploader=self.contributor,
publisher="Kelas SC", descriptions="Deskripsi Materi 1",
status="APPROVE", cover=self.cover, content=self.content,
date_modified=datetime.now(), date_created=datetime.now())
date_modified=timezone.now(), date_created=timezone.now())
self.materi_with_published_date_url = "/materi/" + str(self.materi_with_published_date.id) + "/"
VerificationReport.objects.create(report='{"feedback": "Something", "kriteria": [{"title": "Kriteria 1", "status": true},' + \
' {"title": "Kriteria 2", "status": true}, {"title": "Kriteria 3", "status": true}]}', \
......@@ -799,7 +777,7 @@ class DetailMateriTest(TestCase):
def test_citation_IEEE_materi_has_no_published_date(self):
response = self.client.get(self.url)
current_date = datetime.now()
current_date = timezone.now()
current_day = str(current_date.day)
current_month = current_date.strftime("%b")
current_year = str(current_date.year)
......@@ -822,7 +800,7 @@ class DetailMateriTest(TestCase):
def test_citation_IEEE_materi_has_published_date(self):
response = self.client.get(self.materi_with_published_date_url)
current_date = datetime.now()
current_date = timezone.now()
current_day = str(current_date.day)
current_month = current_date.strftime("%b")
current_year = str(current_date.year)
......@@ -1024,7 +1002,7 @@ class PostsViewTest(TestCase):
for j in range (LIKES_COUNT_PER_POST[i]):
Like.objects.create(
timestamp=datetime.now(),
timestamp=timezone.now(),
materi=post,
session_id=("dummysession-" + str(i) + '-' + str(j))
)
......@@ -1091,6 +1069,8 @@ class PostsViewTest(TestCase):
response = self._request_as_user()
posts = list(self.data.keys())
posts.sort()
comments = {
i: [comment.id for comment in self.data[post_id]["comments"]]
for i, post_id in enumerate(posts)
......@@ -2781,7 +2761,7 @@ class DownloadHistoryViewTest(TestCase):
self.client.get(self.download_url2)
self.client.get(self.download_url1)
jkt_timezone = timezone(TIME_ZONE)
jkt_timezone = pytz.timezone(TIME_ZONE)
download_history = self.user_anonim.riwayat_unduh.all()
response = self.client.get(self.history_url)
......@@ -2801,7 +2781,7 @@ class DownloadHistoryViewTest(TestCase):
self.client.get(self.download_url2)
self.client.get(self.download_url1)
jkt_timezone = timezone(TIME_ZONE)
jkt_timezone = pytz.timezone(TIME_ZONE)
response = self.client.get(self.history_url)
resp_html = response.content.decode('utf8')
......@@ -2821,7 +2801,7 @@ class DownloadHistoryViewTest(TestCase):
self.client.logout()
jkt_timezone = timezone(TIME_ZONE)
jkt_timezone = pytz.timezone(TIME_ZONE)
download_history = self.user_anonim.riwayat_unduh.all()
response = self.client.get(self.history_url)
......@@ -2897,16 +2877,16 @@ class MateriModelTest(TestCase):
self.materi = Materi.objects.create(title="Materi 1", author="Agas", uploader=self.contributor,
publisher="Kelas SC", descriptions="Deskripsi Materi 1",
status="APPROVE", cover=self.cover, content=self.content,
date_modified=datetime.now(), date_created=datetime.now())
date_modified=timezone.now(), date_created=timezone.now())
def test_like_count_return_zero_when_there_is_no_like(self):
self.assertEqual(0, self.materi.like_count)
def test_like_count_return_right_value_when_there_is_like(self):
Like.objects.create(timestamp=datetime.now(), materi=self.materi, session_id="dummysessionid1")
Like.objects.create(timestamp=timezone.now(), materi=self.materi, session_id="dummysessionid1")
self.assertEqual(1, self.materi.like_count)
Like.objects.create(timestamp=datetime.now(), materi=self.materi, session_id="dummysessionid2")
Like.objects.create(timestamp=timezone.now(), materi=self.materi, session_id="dummysessionid2")
self.assertEqual(2, self.materi.like_count)
class MateriFavoriteTest(TestCase):
......@@ -2945,8 +2925,8 @@ class RandomizedMateriTest(TestCase):
status="APPROVE",
cover=self.cover,
content=self.content,
date_modified=datetime.now(),
date_created=datetime.now(),
date_modified=timezone.now(),
date_created=timezone.now(),
)
self.materi = Materi.objects.create(
......@@ -2958,8 +2938,8 @@ class RandomizedMateriTest(TestCase):
status="APPROVE",
cover=self.cover,
content=self.content,
date_modified=datetime.now(),
date_created=datetime.now(),
date_modified=timezone.now(),
date_created=timezone.now(),
)
def test_randomized_materi_returns_200(self):
......@@ -3039,8 +3019,9 @@ class YTUrlVideoTest(TestCase):
@override_settings(MEDIA_ROOT=tempfile.gettempdir())
def setUpImage(self):
from django.core.files.uploadedfile import InMemoryUploadedFile
from io import BytesIO
from django.core.files.uploadedfile import InMemoryUploadedFile
self.cover = InMemoryUploadedFile(
BytesIO(base64.b64decode(TEST_IMAGE)),
field_name='tempfile',
......@@ -3408,8 +3389,8 @@ class MateriRecommendationTest(TestCase):
status="APPROVE",
cover=self.cover,
content=self.content,
date_modified=datetime.now(),
date_created=datetime.now(),
date_modified=timezone.now(),
date_created=timezone.now(),
)
Like.objects.create(materi=materi1)
......@@ -3424,8 +3405,8 @@ class MateriRecommendationTest(TestCase):
status="APPROVE",
cover=self.cover,
content=self.content,
date_modified=datetime.now(),
date_created=datetime.now(),
date_modified=timezone.now(),
date_created=timezone.now(),
)
Like.objects.create(materi=materi2)
......@@ -3441,8 +3422,8 @@ class MateriRecommendationTest(TestCase):
status="APPROVE",
cover=self.cover,
content=self.content,
date_modified=datetime.now(),
date_created=datetime.now(),
date_modified=timezone.now(),
date_created=timezone.now(),
)
response = Client().get("/?recommendation=1")
......@@ -3459,8 +3440,8 @@ class MateriRecommendationTest(TestCase):
status="APPROVE",
cover=self.cover,
content=self.content,
date_modified=datetime.now(),
date_created=datetime.now(),
date_modified=timezone.now(),
date_created=timezone.now(),
)
Like.objects.create(materi=materi2)
......@@ -3475,8 +3456,8 @@ class MateriRecommendationTest(TestCase):
status="APPROVE",
cover=self.cover,
content=self.content,
date_modified=datetime.now(),
date_created=datetime.now(),
date_modified=timezone.now(),
date_created=timezone.now(),
)
Like.objects.create(materi=materi1)
......
This diff is collapsed.
......@@ -45,4 +45,16 @@ urlpatterns = [
path("baca-nanti/", ReadLaterView.as_view(), name="read-later"),
path("baca-nanti-toggle/", views.toggle_readlater, name="toggle-read-later"),
path("stats/", StatisticsView.as_view(), name="stats"),
path("reset_password/",
auth_views.PasswordResetView.as_view(template_name="password_reset.html"),
name="reset_password"),
path("reset_password_sent/",
auth_views.PasswordResetDoneView.as_view(template_name="password_reset_sent.html"),
name="password_reset_done"),
path("reset/<uidb64>/<token>/",
auth_views.PasswordResetConfirmView.as_view(template_name="password_reset_form.html"),
name="password_reset_confirm"),
path("reset_password_complete/",
auth_views.PasswordResetCompleteView.as_view(template_name="password_reset_done.html"),
name="password_reset_complete"),
]
......@@ -346,6 +346,7 @@ def delete_materi(request, pk):
class UploadMateriView(TemplateView):
template_name = UNGGAH_HTML
context = {}
redirect_path = "/unggah/"
def get_context_data(self, **kwargs):
context = super(UploadMateriView, self).get_context_data(**kwargs)
......
......@@ -65,6 +65,10 @@
Belum mendaftar? klik di sini
</a>
<br>
<a href="/reset_password" class="txt1">
Lupa password? klik di sini
</a>
<br>
<a href="/registrasi" class="txt1">
Ingin jadi kontributor? klik di sini
</a>
......
Markdown is supported
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