Fakultas Ilmu Komputer UI

Commit 8d5a308e authored by Mutia Rahmatun Husna's avatar Mutia Rahmatun Husna
Browse files

Merge branch '1706039622-23' into 'master'

[#23] Contributor: Most Contributing Author

See merge request !97
parents 651e62c7 7bed4644
Pipeline #60141 passed with stages
in 23 minutes and 39 seconds
......@@ -103,6 +103,10 @@ class DafterKatalogService:
preserved = Case(*[When(pk=pk, then=pos) for pos, pk in enumerate(ids)])
return Materi.objects.filter(id__in=ids).order_by(preserved)
# @staticmethod
# def get_most_contributing(lst_materi):
@staticmethod
def apply_random(lst_materi):
return random.sample(list(lst_materi), len(lst_materi))
......
......@@ -31,11 +31,6 @@
<span>Statisik Materi</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'favorite' %}">
<span>Favorite Materi</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'posts' %}">
<span>Materi Diunggah</span></a>
......
......@@ -32,4 +32,10 @@
<a class="nav-link" href="/baca-nanti">
<span>Baca Nanti</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="{% url 'favorite' %}">
<span>Materi Favorite</span>
</a>
</li>
</ul>
\ No newline at end of file
{% extends 'app/base_profile.html' %}
{% block title %}Change Password{% endblock%}
{% block title %}{% endblock%}
{% block content %}
......
{% extends "base.html" %}
{% block content %}
<div class="container">
{% include 'app/includes/navbar_katalog_materi.html' %}
<br>
<h1>Most Contributor Author</h1>
{% for cont in content %}
<br>
<div class="card" style="min-width: 641px;">
<div class="card-body">
<div class="image_container">
<img class="img-responsive center-block" id="card_image" src="{{news.cover.url}}" alt="{{news.id}}">
</div>
<br><br>
<h5 class="card-title">{{content.Author}}</h5>
</div>
</div>
{% endfor %}
</div><br><br><br>
{% endblock %}
\ No newline at end of file
{% extends 'app/base_reset.html' %}
{% block title %}Reset Password{% endblock%}
{% block title %}{% endblock%}
{% block content %}
......
{% extends 'app/base_reset.html' %}
{% block title %}Password reset complete{% endblock%}
{% block title %}{% endblock%}
{% block content %}
......
{% extends 'app/base_reset.html' %}
{% block title %}Enter new password{% endblock%}
{% block title %}{% endblock%}
{% block content %}
......
{% extends 'app/base_reset.html' %}
{% block title %}Password reset sent{% endblock%}
{% block title %}{% endblock%}
{% block content %}
......
{% extends 'app/base_profile.html' %}
{% block title %}Change Password{% endblock%}
{% block title %}{% endblock%}
{% block content %}
......
{% extends 'app/base_dashboard.html' %}
{% extends 'app/base_profile.html' %}
{% load static %}
{% block title %}
......
......@@ -295,13 +295,18 @@ class DaftarKatalogPerKontributorTest(TestCase):
found = resolve(self.url)
self.assertEqual(found.func.__name__, KatalogPerKontributorView.as_view().__name__)
def test_katalog_per_kontributor_show_daftar_materi_kontributor(self):
response = self.client.get(self.url)
# def test_katalog_per_kontributor_show_daftar_materi_kontributor(self):
# response = self.client.get(self.url)
list_materi = Materi.objects.filter(uploader=self.contributor)
data = response.context_data["materi_list"]
self.assertEqual(len(list_materi), len(data))
# list_materi = Materi.objects.filter(uploader=self.contributor)
# data = response.context_data["materi_list"]
# self.assertEqual(len(list_materi), len(data))
def test_count_materi_per_contributor(self):
response = self.client.get(self.url)
list_materi = Materi.objects.filter(uploader=self.contributor)
jumlah = response.context_data["materi_list"]
self.assertEqual(len(list_materi), len(jumlah))
class DetailMateriTest(TestCase):
def _get_materi_info_html(self, info_name, info_value):
......
......@@ -6,7 +6,7 @@ from app.views import (DashboardKontributorView, ProfilView, StatisticsView,
SuksesLoginAdminView, SuksesLoginKontributorView, DownloadHistoryView,
SuntingProfilView, UploadMateriHTML, UploadMateriView, UploadMateriExcelView, PostsView,
ReqMateriView, KatalogPerKontributorView, MateriFavorite, PasswordChangeViews, password_success,
SubmitVisitorView, ReadLaterView)
SubmitVisitorView, ReadLaterView, MostContributor)
urlpatterns = [
......@@ -57,4 +57,5 @@ urlpatterns = [
path("reset_password_complete/",
auth_views.PasswordResetCompleteView.as_view(template_name="password_reset_done.html"),
name="password_reset_complete"),
path("most-contributor/", MostContributor.as_view(), name="most-contributor")
]
......@@ -876,3 +876,17 @@ class StatisticsView(TemplateView):
context['stats'] = query
return self.render_to_response(context)
class MostContributor(TemplateView):
template_name = "most-contributor.html"
def dispatch(self, request, *args, **kwargs):
if not request.user.is_authenticated:
raise PermissionDenied(request)
return super(MostContributor, self).dispatch(request, *args, **kwargs)
def count_contributor(self):
count_materi = Materi.objects.all.count()
content = {'count_materi':count_materi}
print(content)
return content
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