Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 67e2cb06 authored by Saul Andre's avatar Saul Andre
Browse files

[REFACTOR] Add profile to comment and add more sharing options

parent e925f4ff
No related branches found
No related tags found
No related merge requests found
function copyToClipboard(element) {
var $temp = $("<input>");
$("body").append($temp);
$temp.val($(element).text()).select();
document.execCommand("copy");
$temp.remove();
window.alert("Link copied");
}
\ No newline at end of file
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
<link rel="stylesheet" type="text/css" href="{% static 'app/css/detail_materi.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'app/css/detail_materi.css' %}">
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,500;1,100&display=swap" rel="stylesheet"> <link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,400;0,500;1,100&display=swap" rel="stylesheet">
<script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v6.0"></script> <script async defer crossorigin="anonymous" src="https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v6.0"></script>
<script src="{% static 'js/detail_materi.js'%}"></script>
{% endblock header %} {% endblock header %}
{% block title %} {% block title %}
...@@ -108,9 +109,14 @@ ...@@ -108,9 +109,14 @@
</div> </div>
<a class="twitter-share-button dropdown-item" <a class="twitter-share-button dropdown-item"
href="https://twitter.com/intent/tweet?text=Cek%20materi%20ini%20yuk%20https%3A%2F%2Fdigipus-staging-2.herokuapp.com%2Fmateri%2F{{materi_data.id}}%2F" href="https://twitter.com/intent/tweet?text=Cek%20materi%20ini%20yuk%20https%3A%2F%2Fdigipus-staging-2.herokuapp.com%2Fmateri%2F{{materi_data.id}}%2F"
target="_blank"
data-size="large"> data-size="large">
Twitter Twitter
</a> </a>
<a class="dropdown-item" href="whatsapp://send?text=Cek materi ini yuk! https://digipus-staging-2.herokuapp.com{{request.path}}" target="_blank">Whatsapp</a>
<a class="dropdown-item" href="https://social-plugins.line.me/lineit/share?url=https%3A%2F%2Fdigipus-staging-2.herokuapp.com%2Fmateri%2F{{materi_data.id}}%2F" target="_blank">Line</a>
<p id="url" style="display: none">https://digipus-staging-2.herokuapp.com{{request.path}}</p>
<button class="dropdown-item btn-book" onclick="copyToClipboard('#url')">Bagikan Tautan</button>
</div> </div>
</div> </div>
</div> </div>
...@@ -153,12 +159,16 @@ ...@@ -153,12 +159,16 @@
{% for comment in comment_data %} {% for comment in comment_data %}
<div class="col col-8 comment shadow-sm p-3 mb-1 bg-white rounded"> <div class="col col-8 comment shadow-sm p-3 mb-1 bg-white rounded">
<div class="d-flex bd-highlight mb-3 align-items-center user"> <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> {% if comment.user != Null %}
<p class="p-1 bd-highligh m-0"><b>{{comment.user}}</b></p> <img class="profile" src="{{ comment.user.profile_picture.url }}" alt="profile-picture">
{% else %}
<span style="background-color: #{{comment.profile}}" class="profile p-1 bd-highligh"></span>
{% endif %}
<p class="p-1 bd-highligh m-0"><b>{{comment.user.name}}</b></p>
{% if user.is_admin %} {% if user.is_admin %}
<a class="ml-auto p-1 bd-highlight close" href="{% url 'delete-comment' materi_data.id comment.id %}"> <a class="ml-auto p-1 bd-highlight close" href="{% url 'delete-comment' materi_data.id comment.id %}">
<span aria-hidden="true">&times;</span> <span aria-hidden="true">&times;</span>
</a> </a>
{% endif %} {% endif %}
</div> </div>
<p class="text">{{comment.comment}}</p> <p class="text">{{comment.comment}}</p>
......
...@@ -101,6 +101,7 @@ class DetailMateri(TemplateView): ...@@ -101,6 +101,7 @@ class DetailMateri(TemplateView):
materi = get_object_or_404(Materi, pk=kwargs["pk"]) materi = get_object_or_404(Materi, pk=kwargs["pk"])
user_obj = request.user if request.user.is_authenticated else None user_obj = request.user if request.user.is_authenticated else None
print(user_obj)
comment = Comment.objects.create(comment=commentText, comment = Comment.objects.create(comment=commentText,
username=self.get_user_name(request), materi=materi, user=user_obj) username=self.get_user_name(request), materi=materi, user=user_obj)
comment.save() comment.save()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment