Fakultas Ilmu Komputer UI
Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
PMPL
Class Project
DIGIPUS
Commits
7bed4644
Commit
7bed4644
authored
Oct 31, 2020
by
Mutia Rahmatun Husna
Browse files
[
#23
] Contributor: Most Contributing Author
parent
c1810816
Changes
14
Hide whitespace changes
Inline
Side-by-side
app/services.py
View file @
7bed4644
...
...
@@ -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
))
...
...
app/templates/app/includes/sidebar.html
View file @
7bed4644
...
...
@@ -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>
...
...
app/templates/app/includes/sidebar_profile.html
View file @
7bed4644
...
...
@@ -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
app/templates/change-password.html
View file @
7bed4644
{% extends 'app/base_profile.html' %}
{% block title %}
Change Password
{% endblock%}
{% block title %}{% endblock%}
{% block content %}
...
...
app/templates/most-contributor.html
0 → 100644
View file @
7bed4644
{% 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
app/templates/password_reset.html
View file @
7bed4644
{% extends 'app/base_reset.html' %}
{% block title %}
Reset Password
{% endblock%}
{% block title %}{% endblock%}
{% block content %}
...
...
app/templates/password_reset_done.html
View file @
7bed4644
{% extends 'app/base_reset.html' %}
{% block title %}
Password reset complete
{% endblock%}
{% block title %}{% endblock%}
{% block content %}
...
...
app/templates/password_reset_form.html
View file @
7bed4644
{% extends 'app/base_reset.html' %}
{% block title %}
Enter new password
{% endblock%}
{% block title %}{% endblock%}
{% block content %}
...
...
app/templates/password_reset_sent.html
View file @
7bed4644
{% extends 'app/base_reset.html' %}
{% block title %}
Password reset sent
{% endblock%}
{% block title %}{% endblock%}
{% block content %}
...
...
app/templates/password_success.html
View file @
7bed4644
{% extends 'app/base_profile.html' %}
{% block title %}
Change Password
{% endblock%}
{% block title %}{% endblock%}
{% block content %}
...
...
app/templates/user_favorite_materi.html
View file @
7bed4644
{% extends 'app/base_
dashboard
.html' %}
{% extends 'app/base_
profile
.html' %}
{% load static %}
{% block title %}
...
...
app/tests.py
View file @
7bed4644
...
...
@@ -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
):
...
...
app/urls.py
View file @
7bed4644
...
...
@@ -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"
)
]
app/views.py
View file @
7bed4644
...
...
@@ -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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment