Fakultas Ilmu Komputer UI

Commit 9eb16994 authored by Yaumi Alfadha's avatar Yaumi Alfadha
Browse files

Merge branch '1706023031-66' into 'master'

[#66] Change Password

See merge request !47
parents 2d43f764 74ca6eef
Pipeline #58931 passed with stages
in 15 minutes
<ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar"> <ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion" id="accordionSidebar">
<!-- Sidebar - Brand --> <!-- Sidebar - Brand -->
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="{% url 'daftar_katalog' %}"> <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-icon rotate-n-15"></div>
<div class="sidebar-brand-text mx-3">Digipus</div> <div class="sidebar-brand-text mx-3">Digipus</div>
</a> </a>
...@@ -10,12 +10,16 @@ ...@@ -10,12 +10,16 @@
<!-- Nav Item - Dashboard --> <!-- Nav Item - Dashboard -->
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/profil/"> <a class="nav-link" href="/profil/">
<span>Halaman Profil</span></a> <span>Halaman Profil</span></a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/sunting/"> <a class="nav-link" href="/sunting/">
<span>Sunting Profil</span></a> <span>Sunting Profil</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="/change-password/">
<span>Change Password</span></a>
</li> </li>
</ul> </ul>
\ No newline at end of file
{% extends 'app/base_profile.html' %}
{% block title %}Change Password{% endblock%}
{% block content %}
<h1> Change Password </h1>
<br/><br/>
<div class = "from-group">
<form method="POST">
{% csrf_token %}
{{ form.as_p }}
<button class="btn btn-secondary"> Change Password</button>
</form>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'app/base_profile.html' %}
{% block title %}Change Password{% endblock%}
{% block content %}
<h1> Password was Changed Successfully!</h1>
<br/><br/>
{% endblock %}
\ No newline at end of file
...@@ -56,6 +56,8 @@ from .views import ( ...@@ -56,6 +56,8 @@ from .views import (
KatalogPerKontributorView, KatalogPerKontributorView,
UploadMateriView, UploadMateriView,
UploadMateriExcelView, UploadMateriExcelView,
PasswordChangeViews,
password_success,
) )
from app.forms import SuntingProfilForm, year_choices 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
...@@ -2354,4 +2356,46 @@ class YearChoicesTest(TestCase): ...@@ -2354,4 +2356,46 @@ class YearChoicesTest(TestCase):
def test_min_release_year_is_2000(self): def test_min_release_year_is_2000(self):
choices = year_choices() choices = year_choices()
self.assertEqual((2000, 2000), choices[0]) self.assertEqual((2000, 2000), choices[0])
\ No newline at end of file class ChangePasswordTest(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 = "/change-password/"
self.view = PasswordChangeViews
self.template_name = "change-password.html"
def test_change_password_view(self):
found = resolve(self.url)
self.assertEqual(found.func.__name__, self.view.as_view().__name__)
def test_change_password_template(self):
# Login
self.client.login(email="kontributor@gov.id", password="kontributor")
# Test
response = self.client.get(self.url)
self.assertTemplateUsed(response, self.template_name)
# Logout
self.client.logout()
def test_change_password_url(self):
# Login
self.client.login(email="kontributor@gov.id", password="kontributor")
# Test
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
# Logout
self.client.logout()
def test_change_password_access(self):
# Kontributor
# Login
self.client.login(email="kontributor@gov.id", password="kontributor")
# Test
response = self.client.get(self.url)
self.assertEqual(response.status_code, 200)
# Logout
self.client.logout()
\ No newline at end of file
...@@ -5,8 +5,8 @@ from app.views import (DashboardKontributorView, ProfilKontributorView, ...@@ -5,8 +5,8 @@ from app.views import (DashboardKontributorView, ProfilKontributorView,
SuksesLoginAdminView, SuksesLoginKontributorView, DownloadHistoryView, SuksesLoginAdminView, SuksesLoginKontributorView, DownloadHistoryView,
SuntingProfilView, UploadMateriHTML, UploadMateriView, UploadMateriExcelView, SuntingProfilView, UploadMateriHTML, UploadMateriView, UploadMateriExcelView,
ProfilAdminView, PostsView, SuntingProfilAdminView, ProfilAdminView, PostsView, SuntingProfilAdminView,
ReqMateriView, KatalogPerKontributorView) ReqMateriView, KatalogPerKontributorView, PasswordChangeViews, password_success)
from django.contrib.auth import views as auth_views
urlpatterns = [ urlpatterns = [
path("", views.DaftarKatalog.as_view(), name="daftar_katalog"), path("", views.DaftarKatalog.as_view(), name="daftar_katalog"),
path("materi/<int:pk>/", views.DetailMateri.as_view(), name="detail-materi"), path("materi/<int:pk>/", views.DetailMateri.as_view(), name="detail-materi"),
...@@ -37,4 +37,6 @@ urlpatterns = [ ...@@ -37,4 +37,6 @@ urlpatterns = [
name="katalog-per-kontributor"), name="katalog-per-kontributor"),
path("materi/rate/", views.add_rating_materi, name="rate-materi"), path("materi/rate/", views.add_rating_materi, name="rate-materi"),
path("materi/<int:pk>/save-to-gdrive/", views.save_to_gdrive, name="save-to-gdrive"), path("materi/<int:pk>/save-to-gdrive/", views.save_to_gdrive, name="save-to-gdrive"),
path("change-password/", PasswordChangeViews.as_view(template_name='change-password.html')),
path("password_success/", views.password_success, name="password_success"),
] ]
...@@ -29,6 +29,10 @@ from authentication.models import User ...@@ -29,6 +29,10 @@ from authentication.models import User
from .services import DafterKatalogService, DetailMateriService, LikeDislikeService, MateriFieldValidationHelperService, \ from .services import DafterKatalogService, DetailMateriService, LikeDislikeService, MateriFieldValidationHelperService, \
DownloadViewMateriHelperService, UploadMateriService, EditProfileService, RevisiMateriService, \ DownloadViewMateriHelperService, UploadMateriService, EditProfileService, RevisiMateriService, \
DownloadHistoryService, GoogleDriveUploadService DownloadHistoryService, GoogleDriveUploadService
from django.contrib.auth.views import PasswordChangeForm
from django.urls import reverse_lazy
from django.contrib.auth.views import PasswordChangeView
from django.shortcuts import render
def permission_denied(request, exception, template_name="error_403.html"): def permission_denied(request, exception, template_name="error_403.html"):
...@@ -695,4 +699,12 @@ def save_to_gdrive(request, pk): ...@@ -695,4 +699,12 @@ def save_to_gdrive(request, pk):
else: else:
raise Http404("File tidak dapat ditemukan.") raise Http404("File tidak dapat ditemukan.")
return HttpResponseRedirect(reverse('detail-materi', kwargs={'pk': pk})) return HttpResponseRedirect(reverse('detail-materi', kwargs={'pk': pk}))
\ No newline at end of file
class PasswordChangeViews(PasswordChangeView):
from_class = PasswordChangeForm
success_url = reverse_lazy('password_success')
def password_success(request):
return render(request, 'password_success.html', {})
\ 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