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
cef3365b
Commit
cef3365b
authored
Jun 04, 2020
by
Mika dabelza abi
Browse files
Merge branch 'PBI-6-Halaman_Katalog' into 'staging'
Pbi 6 halaman katalog See merge request
!64
parents
a285cfe7
4611a047
Changes
5
Hide whitespace changes
Inline
Side-by-side
app/static/app/css/heroic-features.css
View file @
cef3365b
...
...
@@ -6,3 +6,26 @@
body
{
padding-top
:
56px
;
}
.center
{
text-align
:
center
;
}
.pagination
{
display
:
inline-block
;
}
.pagination
a
{
color
:
black
;
float
:
left
;
padding
:
8px
16px
;
text-decoration
:
none
;
transition
:
background-color
.3s
;
border
:
1px
solid
#ddd
;
margin
:
0
4px
;
}
.pagination
a
.active
{
background-color
:
#4CAF50
;
color
:
white
;
border
:
1px
solid
#4CAF50
;
}
\ No newline at end of file
app/static/app/css/katalog_materi.css
View file @
cef3365b
body
{
color
:
#615CFD
;
}
.center
{
text-align
:
center
;
}
.pagination
{
display
:
inline-block
;
}
.pagination
a
{
color
:
black
;
float
:
left
;
padding
:
8px
16px
;
text-decoration
:
none
;
transition
:
background-color
.3s
;
border
:
1px
solid
#ddd
;
margin
:
0
4px
;
}
.pagination
a
.active
{
background-color
:
#4CAF50
;
color
:
white
;
border
:
1px
solid
#4CAF50
;
}
.header
{
display
:
flex
;
...
...
@@ -111,4 +134,5 @@ body{
.card-body
.btn
:hover
{
color
:
#ffffff
;
background-color
:
#615CFD
;
}
\ No newline at end of file
}
\ No newline at end of file
app/templates/app/katalog_materi.html
View file @
cef3365b
...
...
@@ -138,10 +138,36 @@
</div>
{% endfor %}
</div>
<div
class=
"center"
>
<div
class=
"pagination"
>
<span
class=
"step-links"
>
<span
class=
"current"
>
Page {{ materi_list.number }} of {{ materi_list.paginator.num_pages }}
</span>
<br>
</br>
{% if materi_list.has_previous %}
<a
href=
"?page=1"
>
«
first
</a>
<a
href=
"?page={{ materi_list.previous_page_number }}"
>
previous
</a>
{% endif %}
{% if materi_list.has_next %}
<a
href=
"?page={{ materi_list.next_page_number }}"
>
next
</a>
<a
href=
"?page={{ materi_list.paginator.num_pages }}"
>
last
»
</a>
{% endif %}
</span>
</div>
</div>
</div>
</div>
</div>
<!-- /.container -->
</body>
...
...
app/templates/unggah.html
View file @
cef3365b
...
...
@@ -154,7 +154,9 @@
<div
class=
"col-md-6"
>
<div
class=
"fieldWrapper"
>
{{ field.label_tag }} {{ field }}
<p>
</p>
{{ field.errors }}
<p>
</p>
{% if field.help_text %}
<p
class=
"help"
>
{{ field.help_text|safe }}
</p>
{% endif %}
...
...
@@ -163,10 +165,7 @@
{% endfor %}
<div
class=
"row marl text-center m-3"
>
<a
href=
"{% url 'unggah' %}"
class=
"secondary_btn clear"
style=
"border-radius:20px;color:white;"
id=
"create_user_cancel"
><i
class=
"fa fa-undo"
aria-hidden=
"true"
>
</i>
Batal
</a>
<button
type=
"submit"
class=
"btn btn-success"
style=
"background-color: #615CFD; border-color: #615CFD;"
>
Simpan
</button>
...
...
app/views.py
View file @
cef3365b
...
...
@@ -66,6 +66,11 @@ class DaftarKatalog(TemplateView):
elif
(
getSort
==
"pengunggah"
):
context
[
"materi_list"
]
=
list
.
order_by
(
'uploader'
)
paginator
=
Paginator
(
context
[
"materi_list"
],
15
)
page_number
=
request
.
GET
.
get
(
'page'
)
page_obj
=
paginator
.
get_page
(
page_number
)
context
[
"materi_list"
]
=
page_obj
return
self
.
render_to_response
(
context
=
context
)
...
...
@@ -166,6 +171,7 @@ def download_materi(request, pk):
else
:
raise
Http404
(
"File tidak dapat ditemukan."
)
def
view_materi
(
request
,
pk
):
materi
=
get_object_or_404
(
Materi
,
pk
=
pk
)
path
=
materi
.
content
.
path
...
...
@@ -184,6 +190,7 @@ def view_materi(request, pk):
else
:
raise
Http404
(
"File tidak dapat ditemukan."
)
class
UploadMateriView
(
TemplateView
):
template_name
=
"unggah.html"
context
=
{}
...
...
@@ -209,7 +216,8 @@ class UploadMateriView(TemplateView):
kateg
=
form
.
cleaned_data
[
'categories'
]
for
i
in
kateg
:
materi
.
categories
.
add
(
i
)
messages
.
success
(
request
,
"Materi berhasil diunggah, periksa riwayat unggah anda"
)
messages
.
success
(
request
,
"Materi berhasil diunggah, periksa riwayat unggah anda"
)
return
HttpResponseRedirect
(
"/unggah/"
)
else
:
context
=
self
.
get_context_data
(
**
kwargs
)
...
...
@@ -234,6 +242,7 @@ class UploadMateriView(TemplateView):
class
UploadMateriHTML
(
TemplateView
):
template_name
=
"unggah.html"
context
=
{}
def
get_template_names
(
self
):
if
self
.
request
.
path
==
"/unggah/"
:
template_name
=
"unggah.html"
...
...
@@ -336,6 +345,7 @@ class SuntingProfilView(TemplateView):
context
[
"form"
]
=
form
return
self
.
render_to_response
(
context
)
class
SuntingProfilAdminView
(
TemplateView
):
template_name
=
"sunting_admin.html"
...
...
@@ -345,7 +355,8 @@ class SuntingProfilAdminView(TemplateView):
return
super
(
SuntingProfilAdminView
,
self
).
dispatch
(
request
,
*
args
,
**
kwargs
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
SuntingProfilAdminView
,
self
).
get_context_data
(
**
kwargs
)
context
=
super
(
SuntingProfilAdminView
,
self
).
get_context_data
(
**
kwargs
)
return
context
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
...
...
@@ -416,11 +427,12 @@ class SuksesLoginAdminView(TemplateView):
return
self
.
render_to_response
(
context
)
class
CommentsView
(
TemplateView
):
template_name
=
"comments.html"
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
if
not
request
.
user
.
pk
==
kwargs
[
"pk_user"
]
:
if
not
request
.
user
.
pk
==
kwargs
[
"pk_user"
]:
raise
PermissionDenied
(
request
)
return
super
(
CommentsView
,
self
).
dispatch
(
request
,
*
args
,
**
kwargs
)
...
...
@@ -428,7 +440,7 @@ class CommentsView(TemplateView):
context
=
super
(
CommentsView
,
self
).
get_context_data
(
**
kwargs
)
user
=
get_object_or_404
(
User
,
pk
=
kwargs
[
"pk_user"
])
users_materi
=
Materi
.
objects
.
filter
(
uploader
=
user
)
numb_of_comments
=
0
numb_of_comments
=
0
qset_comments
=
Comment
.
objects
.
none
()
for
materi
in
users_materi
:
materi_comments
=
Comment
.
objects
.
filter
(
materi
=
materi
).
count
()
...
...
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