Skip to content

Commit 0f05811

Browse files
committed
second commit
1 parent a4f1c43 commit 0f05811

File tree

5 files changed

+178
-166
lines changed

5 files changed

+178
-166
lines changed

website/migrations/0177_kudos.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by Django 5.1.4 on 2024-12-30 17:47
1+
# Generated by Django 5.1.4 on 2025-01-02 13:28
22

33
import django.db.models.deletion
44
from django.conf import settings
@@ -24,7 +24,6 @@ class Migration(migrations.Migration):
2424
verbose_name="ID",
2525
),
2626
),
27-
("message", models.TextField(blank=True, null=True)),
2827
("timestamp", models.DateTimeField(auto_now_add=True)),
2928
(
3029
"receiver",

website/models.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1297,7 +1297,6 @@ def __str__(self):
12971297
class Kudos(models.Model):
12981298
sender = models.ForeignKey(User, on_delete=models.CASCADE, related_name="kudos_sent")
12991299
receiver = models.ForeignKey(User, on_delete=models.CASCADE, related_name="kudos_received")
1300-
message = models.TextField(null=True, blank=True)
13011300
timestamp = models.DateTimeField(auto_now_add=True)
13021301

13031302
class Meta:

website/templates/profile.html

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -566,6 +566,9 @@ <h4 class="text-[16px] font-semibold uppercase tracking-wide mb-2">
566566
<button class="mr-3" onclick="openBookmarkModal();">
567567
<div class="bg-[#f4f4f4] rounded-2xl p-3 m-2">📑 {% trans "Bookmarks" %} {{ bookmarks|length }}</div>
568568
</button>
569+
<button class="mr-3" onclick="openKudosModal();">
570+
<div class="bg-[#f4f4f4] rounded-2xl p-3 m-2">🌟 Kudos {{ user.kudos_received.count }}</div>
571+
</button>
569572
<button class="mr-3">
570573
<div class="bg-[#f4f4f4] rounded-2xl p-3 m-2">👁️ {% trans "Profile Views" %} {{ user.userprofile.visit_count }}</div>
571574
</button>
@@ -860,6 +863,73 @@ <h3 class="text-lg font-semibold mb-4">Assign a Badge</h3>
860863
</form>
861864
</div>
862865
</div>
866+
<!-- Kudos modal -->
867+
<div id="Kudos"
868+
class="hidden relative z-10"
869+
aria-labelledby="modal-title"
870+
role="dialog"
871+
aria-modal="true">
872+
<div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"
873+
aria-hidden="true"></div>
874+
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
875+
<div class="flex min-h-full items-center justify-center p-4 text-center sm:items-center sm:p-0">
876+
<div class="relative transform overflow-hidden rounded-lg bg-white text-left shadow-xl transition-all sm:my-8 max-sm:w-full lg:w-[30vw] ">
877+
<div class="bg-white px-4 pb-4 pt-5 sm:p-6 sm:pb-4">
878+
<div class="sm:flex sm:items-start lg:w-full">
879+
<div class="mt-3 sm:ml-4 sm:mt-0 sm:text-left lg:w-full">
880+
<div class="mt-2">
881+
<h3>Appreciation Received:</h3>
882+
<br>
883+
<p class="text-xl">
884+
<table class="table-auto w-full border-spacing-52">
885+
<tbody>
886+
{% for k in user.kudos_received.all %}
887+
<tr class="shadow-lg m-3 w-full rounded">
888+
<td>
889+
{% if k.sender.userprofile.avatar %}
890+
<img src="{{ k.sender.userprofile.avatar }}"
891+
height="50"
892+
width="50"
893+
alt="{{ k.sender.username }}">
894+
{% else %}
895+
<img src="{% gravatar_url k.sender.email 50 %}"
896+
height="50"
897+
width="50"
898+
alt="{{ k.sender.username }}">
899+
{% endif %}
900+
</td>
901+
<td>
902+
<a href="{% url 'profile' slug=k.sender.username %}">{{ k.sender.username }}</a>
903+
</td>
904+
<td>{{ k.timestamp }}</td>
905+
</tr>
906+
{% endfor %}
907+
</tbody>
908+
</table>
909+
</p>
910+
</div>
911+
</div>
912+
</div>
913+
</div>
914+
<div class="bg-gray-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6">
915+
<button type="button"
916+
class="mt-3 inline-flex w-full justify-center rounded-md bg-white px-3 py-2 text-xl font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50 sm:mt-0 sm:w-auto"
917+
id="close-kudos">Close</button>
918+
</div>
919+
</div>
920+
</div>
921+
</div>
922+
</div>
923+
<script defer>
924+
var closeKudos = document.getElementById("close-kudos");
925+
var openKudos = document.getElementById("Kudos");
926+
closeKudos.addEventListener("click", ()=>{
927+
openKudos.style.display="none";
928+
});
929+
function openKudosModal(){
930+
openKudos.style.cssText = "display:block !important;";
931+
}
932+
</script>
863933
<script>
864934
// Assign Badge Modal Logic
865935
const addBadgeButton = document.getElementById("add-badge-button");

0 commit comments

Comments
 (0)