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
041f2dc8
Commit
041f2dc8
authored
Oct 29, 2020
by
insan ramadhan
Browse files
Merge branch '1906457480-111' into 'master'
1906457480 111 See merge request
!69
parents
ba93c560
824d1c2d
Pipeline
#59969
passed with stages
in 28 minutes and 2 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
app/migrations/0026_submitvisitor.py
0 → 100644
View file @
041f2dc8
# Generated by Django 3.1 on 2020-10-29 13:45
from
django.db
import
migrations
,
models
import
django.utils.timezone
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'app'
,
'0025_review'
),
]
operations
=
[
migrations
.
CreateModel
(
name
=
'SubmitVisitor'
,
fields
=
[
(
'id'
,
models
.
AutoField
(
auto_created
=
True
,
primary_key
=
True
,
serialize
=
False
,
verbose_name
=
'ID'
)),
(
'user_id'
,
models
.
CharField
(
max_length
=
50
)),
(
'email'
,
models
.
CharField
(
max_length
=
50
)),
(
'msg'
,
models
.
CharField
(
max_length
=
100
)),
(
'timestamp'
,
models
.
DateTimeField
(
default
=
django
.
utils
.
timezone
.
now
)),
],
),
]
app/models.py
View file @
041f2dc8
...
...
@@ -197,6 +197,12 @@ class ReqMaterial(models.Model):
title
=
models
.
CharField
(
max_length
=
100
)
timestamp
=
models
.
DateTimeField
(
default
=
timezone
.
now
)
class
SubmitVisitor
(
models
.
Model
):
user_id
=
models
.
CharField
(
max_length
=
50
)
email
=
models
.
CharField
(
max_length
=
50
)
msg
=
models
.
CharField
(
max_length
=
100
)
timestamp
=
models
.
DateTimeField
(
default
=
timezone
.
now
)
class
ViewStatistics
(
models
.
Model
):
materi
=
models
.
ForeignKey
(
Materi
,
models
.
SET_NULL
,
null
=
True
,
related_name
=
"baca"
)
...
...
app/templates/app/katalog_materi.html
View file @
041f2dc8
...
...
@@ -70,6 +70,8 @@
href=
"/req-materi"
>
disini
</a></p>
<p
class=
"pageTitle"
>
Ingin diskusi lebih mendalam? Silahkan kunjungi
<a
href=
"{% url 'forum_home' %}"
>
forum kami
</a></p>
<p
class=
"pageTitle"
>
Terima kasih sudah berkunjung, mohon isi buku tamu terlebih dahulu
<a
href=
"/submit-visitor"
>
disini
</a>
jika kamu sudah terdaftar!
</p>
</div>
</div>
</div>
...
...
app/templates/submit_visitor.html
0 → 100644
View file @
041f2dc8
{% extends "base.html" %}
{% load static %}
{% block title %}Digipus Home{% endblock %}
{% block header %}
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<title>
Digipus Home
</title>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'app/css/katalog_materi.css' %}"
>
<!-- Bootstrap core CSS -->
<link
href=
"../../static/app/vendor/bootstrap/css/bootstrap.min.css"
rel=
"stylesheet"
>
<!-- Custom styles for this template -->
<link
href=
"../../static/app/css/heroic-features.css"
rel=
"stylesheet"
>
<!--===============================================================================================-->
<link
rel=
"icon"
type=
"image/png"
href=
"{% static 'images/icons/logo.ico' %}"
/>
<!--===============================================================================================-->
<!--===============================================================================================-->
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'fonts/font-awesome-4.7.0/css/font-awesome.min.css' %}"
>
<!--===============================================================================================-->
<!--===============================================================================================-->
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'vendor/animate/animate.css' %}"
>
<!--===============================================================================================-->
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'vendor/css-hamburgers/hamburgers.min.css' %}"
>
<!--===============================================================================================-->
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'vendor/animsition/css/animsition.min.css' %}"
>
<!--===============================================================================================-->
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'vendor/select2/select2.min.css' %}"
>
<!--===============================================================================================-->
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'vendor/daterangepicker/daterangepicker.css' %}"
>
<!--===============================================================================================-->
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'css/styles.css' %}"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'css/util.css' %}"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"{% static 'css/main.css' %}"
>
<!--===============================================================================================-->
{% endblock header %}
{% block content %}
</head>
<body
style=
"background-color: #f8f8f8;"
>
<!-- Page Content -->
<div
class=
"container"
>
<header
class=
"jumbotron my-4"
>
<div
class=
"container"
>
<div
class=
"row header"
>
<div
class=
"col"
>
<h2
class=
"pageTitle"
>
Hi! {{ user.name }} Selamat datang di halaman buku tamu!
</h2>
<input
type=
"hidden"
id=
"user_id"
name=
"user_id"
value=
"{{ user.id}}"
/>
<input
type=
"hidden"
id=
"email"
name=
"email"
value=
"{{ user.email}}"
/>
{% if user %}
<p
class=
"description"
>
Sampaikan pesan dan kesan kamu terhadap aplikasi ini
</p>
{% else %}
<p
class=
"description"
>
Sampaikan pesan dan kesan kamu terhadap aplikasi ini
</p>
{% endif %}
<form
class=
"searchBar"
>
{% csrf_token %}
<div
class=
"col-6 form-group"
>
<input
type=
"text"
name=
'search'
class=
"form-control"
placeholder=
"Tulis di sini"
id=
"title"
value=
""
required
>
</div>
<button
id=
"btn_req_submit"
style=
"width: auto;padding-left: 10px;padding-right: 10px;"
class=
"btn btn-cari"
>
Submit pesan ke buku tamu
</button>
</form>
<p
id=
"msg"
style=
"display: none;margin: 5px"
>
Buku Tamu berhasil ditambahkan
</p>
</div>
</div>
</div>
</header>
</div>
<!-- /.container -->
</body>
</html>
<script
src=
"https://kit.fontawesome.com/bc2cedd6b2.js"
crossorigin=
"anonymous"
></script>
<script
src=
"//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"
></script>
<script
src=
"https://unpkg.com/sweetalert/dist/sweetalert.min.js"
></script>
<script
type=
"text/javascript"
>
var
csrftoken
=
jQuery
(
"
[name=csrfmiddlewaretoken]
"
).
val
();
</script>
<script>
function
csrfSafeMethod
(
method
)
{
return
(
/^
(
GET|HEAD|OPTIONS|TRACE
)
$/
.
test
(
method
));
}
</script>
<script
type=
"text/javascript"
>
$
(
'
#btn_req_submit
'
).
click
(
function
()
{
var
title
=
document
.
getElementById
(
'
title
'
);
var
msg
=
document
.
getElementById
(
'
msg
'
);
var
user_id
=
document
.
getElementById
(
'
user_id
'
);
var
email
=
document
.
getElementById
(
'
email
'
);
if
(
title
.
value
==
''
){
return
;
}
$
.
ajaxSetup
({
beforeSend
:
function
(
xhr
,
settings
)
{
if
(
!
csrfSafeMethod
(
settings
.
type
)
&&
!
this
.
crossDomain
)
{
xhr
.
setRequestHeader
(
"
X-CSRFToken
"
,
csrftoken
);
}
}
});
$
.
ajax
({
type
:
'
POST
'
,
url
:
"
{% url 'submit-visitor' %}
"
,
data
:
{
'
title
'
:
title
.
value
,
'
user_id
'
:
user_id
.
value
,
'
email
'
:
email
.
value
,
},
success
:
function
(
Json
)
{
/* clear the error message first */
if
(
Json
.
success
){
swal
(
"
Informasi!
"
,
Json
.
msg
,
"
success
"
);
msg
.
style
.
display
=
'
block
'
;
title
.
value
=
""
;
setTimeout
(
function
(){
$
(
"
#msg
"
).
fadeOut
(
"
slow
"
);
},
3000
);
}
else
{
swal
(
"
Informasi!
"
,
Json
.
msg
,
"
error
"
);
msg
.
style
.
display
=
'
block
'
;
setTimeout
(
function
(){
$
(
"
#msg
"
).
fadeOut
(
"
slow
"
);
},
3000
);
}
},
error
:
function
(
xhr
,
status
,
errorThrown
)
{
xhr
.
status
;
swal
(
"
Error!
"
,
xhr
.
responseText
,
"
error
"
);
xhr
.
responseText
;
}
});
return
false
;
});
</script>
{% endblock %}
\ No newline at end of file
app/urls.py
View file @
041f2dc8
...
...
@@ -5,7 +5,7 @@ from app import views
from
app.views
import
(
DashboardKontributorView
,
ProfilView
,
SuksesLoginAdminView
,
SuksesLoginKontributorView
,
DownloadHistoryView
,
SuntingProfilView
,
UploadMateriHTML
,
UploadMateriView
,
UploadMateriExcelView
,
PostsView
,
ReqMateriView
,
KatalogPerKontributorView
,
MateriFavorite
,
PasswordChangeViews
,
password_success
)
ReqMateriView
,
KatalogPerKontributorView
,
MateriFavorite
,
PasswordChangeViews
,
password_success
,
SubmitVisitorView
)
urlpatterns
=
[
...
...
@@ -40,4 +40,5 @@ urlpatterns = [
path
(
"change-password/"
,
PasswordChangeViews
.
as_view
(
template_name
=
'change-password.html'
)),
path
(
"password_success/"
,
views
.
password_success
,
name
=
"password_success"
),
path
(
"given-rating/"
,
views
.
see_given_rating
,
name
=
"see_given_rating"
),
path
(
"submit-visitor/"
,
SubmitVisitorView
.
as_view
(),
name
=
"submit-visitor"
),
]
app/views.py
View file @
041f2dc8
...
...
@@ -31,6 +31,7 @@ from app.models import (
Materi
,
ReqMaterial
,
Rating
,
RatingContributor
,
SubmitVisitor
)
from
authentication.models
import
User
from
.services
import
DafterKatalogService
,
DetailMateriService
,
LikeDislikeService
,
MateriFieldValidationHelperService
,
\
...
...
@@ -721,3 +722,28 @@ def see_given_rating(request):
return
render
(
request
,
'given-rating.html'
,
context
=
{
'rating_list'
:
rating_list
,
'order_by_key'
:
order_by_key
,
'order_by'
:
order_by
})
return
permission_denied
(
request
,
exception
=
None
)
class
SubmitVisitorView
(
TemplateView
):
template_name
=
"submit_visitor.html"
def
dispatch
(
self
,
request
,
*
args
,
**
kwargs
):
if
request
.
user
.
is_authenticated
==
False
:
return
HttpResponseRedirect
(
"/login/"
)
return
super
(
SubmitVisitorView
,
self
).
dispatch
(
request
,
*
args
,
**
kwargs
)
def
get_context_data
(
self
,
**
kwargs
):
context
=
super
(
SubmitVisitorView
,
self
).
get_context_data
(
**
kwargs
)
return
context
def
get
(
self
,
request
,
*
args
,
**
kwargs
):
context
=
self
.
get_context_data
(
**
kwargs
)
return
self
.
render_to_response
(
context
)
def
post
(
self
,
request
,
*
args
,
**
kwargs
):
title
=
request
.
POST
.
get
(
"title"
,
None
)
email
=
request
.
POST
.
get
(
"email"
,
None
)
user_id
=
request
.
POST
.
get
(
"user_id"
,
None
)
if
title
is
None
:
return
JsonResponse
({
"success"
:
False
,
"msg"
:
"Missing parameter"
})
SubmitVisitor
(
msg
=
title
,
user_id
=
user_id
,
email
=
email
).
save
()
return
JsonResponse
({
"success"
:
True
,
"msg"
:
"Buku tamu berhasil ditambahkan"
})
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