Fakultas Ilmu Komputer UI

Commit 1277a8be authored by Saul Andre's avatar Saul Andre
Browse files

[RED] creating test for detail materi

parent 83a7e862
# Generated by Django 3.0.3 on 2020-04-24 17:07
# Generated by Django 3.0.3 on 2020-04-27 07:51
from django.db import migrations, models
......@@ -7,16 +7,17 @@ class Migration(migrations.Migration):
initial = True
dependencies = []
dependencies = [
]
operations = [
migrations.CreateModel(
name="VerificationSetting",
name='VerificationSetting',
fields=[
("id", models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID")),
("title", models.CharField(max_length=250)),
("description", models.TextField(default="")),
("archived", models.BooleanField(default=False)),
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=250)),
('description', models.TextField(default='')),
('archived', models.BooleanField(default=False)),
],
),
]
......@@ -86,23 +86,12 @@ body{
.comment{
border-bottom: 1px solid #d4d4d4;
}
.comment .user {
display: flex;
flex-direction: row;
margin-bottom: 10px;
}
.comment .user p{
margin: 0
}
.comment .user .profile{
display: inline-block;
height: 25px;
width: 25px;
background-color: #bbb;
border-radius: 50%;
display: inline-block;
margin-right: 10px;
}
......
......@@ -3,7 +3,6 @@
{% block header %}
<link rel="stylesheet" type="text/css" href="{% static 'app/css/detail_materi.css' %}">
<script src="{% static 'app/js/detail_materi.js' %}"></script>
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,500;1,100&display=swap" rel="stylesheet">
{% endblock header %}
......@@ -96,13 +95,17 @@ Materi
<button type="submit" class="btn btn-book shadow-sm p-2 mb-1 bg-white rounded">Kirim</button>
</div>
</form>
</div>
{% for comment in materi_data.comments.all %}
<div class="col col-8 comment shadow-sm p-3 mb-1 bg-white rounded">
<div class="user">
<span class="profile"></span>
<p><b>{{comment.user}}</b></p>
<div class="d-flex bd-highlight mb-3 align-items-center user">
<span style="background-color: #{{comment.profile}}" class="profile p-1 bd-highligh"></span>
<p class="p-1 bd-highligh"><b>{{comment.user}}</b></p>
{% if user.is_admin %}
<a class="ml-auto p-1 bd-highlight close" href="{% url 'delete-comment' materi_data.id comment.id %}">
<span aria-hidden="true">&times;</span>
</a>
{% endif %}
</div>
<p class="text">{{comment.comment}}</p>
</div>
......
......@@ -5,6 +5,7 @@ from app import views
urlpatterns = [
path("", views.DaftarKatalog.as_view(), name="daftar_katalog"),
path("materi/<int:pk>/", views.DetailMateri.as_view(), name="detail-materi"),
path("delete/<int:pk_materi>/<int:pk_comment>", views.delete_comment, name="delete-comment"),
path("materi/<int:pk>/unduh", views.download_materi, name="download-materi"),
path("materi/<int:pk>/view", views.view_materi, name="view-materi"),
path("dashboard/", views.dashboard, name="dashboard"),
......
......@@ -12,7 +12,7 @@ from django.template import loader
from django.views.generic import TemplateView
from .forms import UploadMateriForm
from .models import Category, Materi
from .models import Category, Materi, Comment
class DaftarKatalog(TemplateView):
......@@ -71,6 +71,41 @@ class DetailMateri(TemplateView):
context["materi_data"] = get_object_or_404(Materi, pk=kwargs["pk"])
return self.render_to_response(context=context)
def post(self, request, *args, **kwargs):
comment = request.POST.get("comment", None)
url = request.path
comment = Comment.objects.create(comment=comment)
materi = get_object_or_404(Materi, pk=kwargs['pk'])
if comment == None or comment =='':
context = self.get_context_data(*args, **kwargs)
context["error_message"] = "Anda belum menuliskan komentar"
return self.render_to_response(context=context)
else:
if request.user.is_authenticated:
if request.user.is_superuser:
username = "Admin"
else:
username = request.user.name
comment.user = username
comment.save()
materi.comments.add(comment)
materi.save()
return HttpResponseRedirect(url)
else:
comment.user = "Anonim"
comment.save()
materi.comments.add(comment)
materi.save()
return HttpResponseRedirect(url)
def delete_comment(request, pk_materi, pk_comment):
materi = get_object_or_404(Materi, pk=pk_materi)
comment = get_object_or_404(Comment, pk=pk_comment)
url = '/materi/' + str(pk_materi) + "/"
materi.comments.remove(comment)
comment.delete()
return HttpResponseRedirect(url)
def download_materi(request, pk):
materi = get_object_or_404(Materi, pk=pk)
......
.get_in_tauch_area .touch_form .submit_btn .boxed-btn3 {
width: 100%;
text-align: center;
}
/* line 1, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area {
position: relative;
}
/* line 3, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area.extra_margin_bottom {
margin-bottom: 160px;
}
@media (max-width: 767px) {
/* line 3, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area.extra_margin_bottom {
margin-bottom: 70px;
}
}
@media (min-width: 768px) and (max-width: 991px) {
/* line 3, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area.extra_margin_bottom {
margin-bottom: 100px;
}
}
/* line 12, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area.extra_margin {
margin-top: 160px;
}
@media (max-width: 767px) {
/* line 12, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area.extra_margin {
margin-top: 70px;
}
}
@media (min-width: 768px) and (max-width: 991px) {
/* line 12, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area.extra_margin {
margin-top: 100px;
}
}
/* line 21, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area::before {
position: absolute;
content: '';
width: 50%;
right: 0;
top: 0;
height: 100%;
background-image: url(../images/login_admin.jpg);
background-size: cover;
background-position: center center;
-webkit-border-radius: 20px 0 0 20px;
-moz-border-radius: 20px 0 0 20px;
border-radius: 20px 0 0 20px;
}
@media (max-width: 767px) {
/* line 21, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area::before {
display: none;
}
}
@media (min-width: 768px) and (max-width: 991px) {
/* line 21, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area::before {
display: none;
}
}
/* line 39, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info {
padding: 180px 0;
}
@media (max-width: 767px) {
/* line 39, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info {
padding: 80px 0;
}
}
@media (min-width: 768px) and (max-width: 991px) {
/* line 39, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info {
padding: 100px 0;
}
}
/* line 48, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info .section_title .mid_text {
font-size: 18px;
font-family: "Muli", sans-serif;
color: #1F1F1F;
font-weight: 400;
margin-bottom: 25px;
}
/* line 55, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info .section_title .last_p {
font-size: 16px;
color: #707070;
font-weight: 400;
}
/* line 61, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info .video_watch {
margin-top: 37px;
}
/* line 64, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info .video_watch .play_btn a {
width: 60px;
height: 60px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
background: #615CFD;
font-size: 14px;
text-align: center;
line-height: 60px;
color: #fff;
display: inline-block;
}
/* line 76, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info .video_watch span {
font-size: 20px;
color: #1F1F1F;
font-weight: 400;
font-family: "Roboto", sans-serif;
margin-left: 20px;
}
.how_we_work_area .work_info {
padding: 180px 0;
}
@media (max-width: 767px) {
/* line 39, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info {
padding: 80px 0;
}
}
@media (min-width: 768px) and (max-width: 991px) {
/* line 39, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info {
padding: 100px 0;
}
}
/* line 48, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info .section_title .mid_text {
font-size: 18px;
font-family: "Muli", sans-serif;
color: #1F1F1F;
font-weight: 400;
margin-bottom: 25px;
}
/* line 55, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info .section_title .last_p {
font-size: 16px;
color: #707070;
font-weight: 400;
}
/* line 61, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info .video_watch {
margin-top: 37px;
}
/* line 64, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info .video_watch .play_btn a {
width: 60px;
height: 60px;
-webkit-border-radius: 50%;
-moz-border-radius: 50%;
border-radius: 50%;
background: #615CFD;
font-size: 14px;
text-align: center;
line-height: 60px;
color: #fff;
display: inline-block;
}
/* line 76, ../../Arafath/CL/December/233. Startup/HTML/scss/_work.scss */
.how_we_work_area .work_info .video_watch span {
font-size: 20px;
color: #1F1F1F;
font-weight: 400;
font-family: "Roboto", sans-serif;
margin-left: 20px;
}
\ No newline at end of file
(function ($) {
"use strict";
/*==================================================================
[ Clickable scroll ]*/
$('a.js-scroll-trigger[href*="#"]:not([href="#"])').click(function () {
if (location.pathname.replace(/^\//, '') == this.pathname.replace(/^\//, '') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) + ']');
if (target.length) {
$('html, body').animate({
scrollTop: (target.offset().top - 72)
}, 1000, "easeInOutExpo");
return false;
}
}
});
// Closes responsive menu when a scroll trigger link is clicked
$('.js-scroll-trigger').click(function () {
$('.navbar-collapse').collapse('hide');
});
/*==================================================================
[ Focus Contact2 ]*/
$('.input100').each(function(){
$(this).on('blur', function(){
if($(this).val().trim() != "") {
$(this).addClass('has-val');
}
else {
$(this).removeClass('has-val');
}
})
})
/*==================================================================
[ Validate ]*/
var input = $('.validate-input .input100');
$('.validate-form').on('submit',function(){
var check = true;
for(var i=0; i<input.length; i++) {
if(validate(input[i]) == false){
showValidate(input[i]);
check=false;
}
}
return check;
});
$('.validate-form .input100').each(function(){
$(this).focus(function(){
hideValidate(this);
});
});
function validate (input) {
if($(input).attr('type') == 'email' || $(input).attr('name') == 'email') {
if($(input).val().trim().match(/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{1,5}|[0-9]{1,3})(\]?)$/) == null) {
return false;
}
}
else {
if($(input).val().trim() == ''){
return false;
}
}
}
function showValidate(input) {
var thisAlert = $(input).parent();
$(thisAlert).addClass('alert-validate');
}
function hideValidate(input) {
var thisAlert = $(input).parent();
$(thisAlert).removeClass('alert-validate');
}
})(jQuery);
\ No newline at end of file
This diff is collapsed.
Supports Markdown
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