diff --git a/app/services.py b/app/services.py index 4ae99b55b1349e03cdcf79d9ef244944592b64b9..95cbb4a64bbb1d5920de6760245bff4d984bbfc9 100644 --- a/app/services.py +++ b/app/services.py @@ -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)) diff --git a/app/templates/app/includes/sidebar.html b/app/templates/app/includes/sidebar.html index 69425f3e24b473e9953c78d53353d3d128c23dda..ab41216fbd94001a567a6857e29c3c9bb9655d92 100644 --- a/app/templates/app/includes/sidebar.html +++ b/app/templates/app/includes/sidebar.html @@ -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> diff --git a/app/templates/app/includes/sidebar_profile.html b/app/templates/app/includes/sidebar_profile.html index d28a4c58f129d2221169186cec9927b3c1e203c9..3b01110dd5c200cd3946354ef025b3dab3c32ed7 100644 --- a/app/templates/app/includes/sidebar_profile.html +++ b/app/templates/app/includes/sidebar_profile.html @@ -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 diff --git a/app/templates/change-password.html b/app/templates/change-password.html index cd9bc26a4dbe54cda04d17359141878e91bc0332..1160d5ffb403e527430a1dd97a16920fd00f72cd 100644 --- a/app/templates/change-password.html +++ b/app/templates/change-password.html @@ -1,5 +1,5 @@ {% extends 'app/base_profile.html' %} -{% block title %}Change Password{% endblock%} +{% block title %}{% endblock%} {% block content %} diff --git a/app/templates/most-contributor.html b/app/templates/most-contributor.html new file mode 100644 index 0000000000000000000000000000000000000000..62accb00a2f7fa5861030b512c88d2bf747117a7 --- /dev/null +++ b/app/templates/most-contributor.html @@ -0,0 +1,20 @@ +{% 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 diff --git a/app/templates/password_reset.html b/app/templates/password_reset.html index 148908564a188bfaf8b1a2639bbc8162ea16a58e..37cafe7aadd684c85a9bdbdd00dd619fb6eede19 100644 --- a/app/templates/password_reset.html +++ b/app/templates/password_reset.html @@ -1,5 +1,5 @@ {% extends 'app/base_reset.html' %} -{% block title %}Reset Password{% endblock%} +{% block title %}{% endblock%} {% block content %} diff --git a/app/templates/password_reset_done.html b/app/templates/password_reset_done.html index d021c573d3b9f6794c12d754fa85ab818d6a2cf2..e8b83934671026f48c80606ccd73eaa536f5cdf6 100644 --- a/app/templates/password_reset_done.html +++ b/app/templates/password_reset_done.html @@ -1,6 +1,6 @@ {% extends 'app/base_reset.html' %} -{% block title %}Password reset complete{% endblock%} +{% block title %}{% endblock%} {% block content %} diff --git a/app/templates/password_reset_form.html b/app/templates/password_reset_form.html index 73e68f57f6785e250468678e82d7d7a2a87e4f16..f6ca8fa34ef7639bc9b9cb1a9de5591c42cdf16a 100644 --- a/app/templates/password_reset_form.html +++ b/app/templates/password_reset_form.html @@ -1,5 +1,5 @@ {% extends 'app/base_reset.html' %} -{% block title %}Enter new password{% endblock%} +{% block title %}{% endblock%} {% block content %} diff --git a/app/templates/password_reset_sent.html b/app/templates/password_reset_sent.html index 12542b5a335e1b0a400c28411f4e9a1c79c809b3..dd0121615b2f8c28e937e9561d5fb02c6fe641ab 100644 --- a/app/templates/password_reset_sent.html +++ b/app/templates/password_reset_sent.html @@ -1,6 +1,6 @@ {% extends 'app/base_reset.html' %} -{% block title %}Password reset sent{% endblock%} +{% block title %}{% endblock%} {% block content %} diff --git a/app/templates/password_success.html b/app/templates/password_success.html index 3c61031a145a7f5cbf6bfa30b7f62368419dba19..d0974638c34c611f055c01dee914b4f278d8714a 100644 --- a/app/templates/password_success.html +++ b/app/templates/password_success.html @@ -1,5 +1,5 @@ {% extends 'app/base_profile.html' %} -{% block title %}Change Password{% endblock%} +{% block title %}{% endblock%} {% block content %} diff --git a/app/templates/user_favorite_materi.html b/app/templates/user_favorite_materi.html index 7ca9ccffc1b172244c76e97fe59a9db72a231a0f..78c941530dd4484292b793081aa4313bfa008c08 100644 --- a/app/templates/user_favorite_materi.html +++ b/app/templates/user_favorite_materi.html @@ -1,4 +1,4 @@ -{% extends 'app/base_dashboard.html' %} +{% extends 'app/base_profile.html' %} {% load static %} {% block title %} diff --git a/app/tests.py b/app/tests.py index d65e62e06fe7eda4938aa653c4da9a976b4b3100..f428616f4b27e3277b84c471f51889e73dbddd05 100644 --- a/app/tests.py +++ b/app/tests.py @@ -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): diff --git a/app/urls.py b/app/urls.py index 9df11eb5fc440636480622cbb9bcf0dcd129adb3..b48be941b1a77fcacd0cae3571b7360b26199c2f 100644 --- a/app/urls.py +++ b/app/urls.py @@ -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") ] diff --git a/app/views.py b/app/views.py index cb0be086fc60e5a57b44fb13c1ad36651f930e98..cd6be9c991ea2acdaaece401b16d1959f7a2a8db 100644 --- a/app/views.py +++ b/app/views.py @@ -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