Skip to content

Commit

Permalink
second commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tsu-ki committed Jan 2, 2025
1 parent a4f1c43 commit 0f05811
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 166 deletions.
3 changes: 1 addition & 2 deletions website/migrations/0177_kudos.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 5.1.4 on 2024-12-30 17:47
# Generated by Django 5.1.4 on 2025-01-02 13:28

import django.db.models.deletion
from django.conf import settings
Expand All @@ -24,7 +24,6 @@ class Migration(migrations.Migration):
verbose_name="ID",
),
),
("message", models.TextField(blank=True, null=True)),
("timestamp", models.DateTimeField(auto_now_add=True)),
(
"receiver",
Expand Down
1 change: 0 additions & 1 deletion website/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1297,7 +1297,6 @@ def __str__(self):
class Kudos(models.Model):
sender = models.ForeignKey(User, on_delete=models.CASCADE, related_name="kudos_sent")
receiver = models.ForeignKey(User, on_delete=models.CASCADE, related_name="kudos_received")
message = models.TextField(null=True, blank=True)
timestamp = models.DateTimeField(auto_now_add=True)

class Meta:
Expand Down
70 changes: 70 additions & 0 deletions website/templates/profile.html
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,9 @@ <h4 class="text-[16px] font-semibold uppercase tracking-wide mb-2">
<button class="mr-3" onclick="openBookmarkModal();">
<div class="bg-[#f4f4f4] rounded-2xl p-3 m-2">📑 {% trans "Bookmarks" %} {{ bookmarks|length }}</div>
</button>
<button class="mr-3" onclick="openKudosModal();">
<div class="bg-[#f4f4f4] rounded-2xl p-3 m-2">🌟 Kudos {{ user.kudos_received.count }}</div>
</button>
<button class="mr-3">
<div class="bg-[#f4f4f4] rounded-2xl p-3 m-2">👁️ {% trans "Profile Views" %} {{ user.userprofile.visit_count }}</div>
</button>
Expand Down Expand Up @@ -860,6 +863,73 @@ <h3 class="text-lg font-semibold mb-4">Assign a Badge</h3>
</form>
</div>
</div>
<!-- Kudos modal -->
<div id="Kudos"
class="hidden relative z-10"
aria-labelledby="modal-title"
role="dialog"
aria-modal="true">
<div class="fixed inset-0 bg-gray-500 bg-opacity-75 transition-opacity"
aria-hidden="true"></div>
<div class="fixed inset-0 z-10 w-screen overflow-y-auto">
<div class="flex min-h-full items-center justify-center p-4 text-center sm:items-center sm:p-0">
<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] ">
<div class="bg-white px-4 pb-4 pt-5 sm:p-6 sm:pb-4">
<div class="sm:flex sm:items-start lg:w-full">
<div class="mt-3 sm:ml-4 sm:mt-0 sm:text-left lg:w-full">
<div class="mt-2">
<h3>Appreciation Received:</h3>
<br>
<p class="text-xl">
<table class="table-auto w-full border-spacing-52">
<tbody>
{% for k in user.kudos_received.all %}
<tr class="shadow-lg m-3 w-full rounded">
<td>
{% if k.sender.userprofile.avatar %}
<img src="{{ k.sender.userprofile.avatar }}"
height="50"
width="50"
alt="{{ k.sender.username }}">
{% else %}
<img src="{% gravatar_url k.sender.email 50 %}"
height="50"
width="50"
alt="{{ k.sender.username }}">
{% endif %}
</td>
<td>
<a href="{% url 'profile' slug=k.sender.username %}">{{ k.sender.username }}</a>
</td>
<td>{{ k.timestamp }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</p>
</div>
</div>
</div>
</div>
<div class="bg-gray-50 px-4 py-3 sm:flex sm:flex-row-reverse sm:px-6">
<button type="button"
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"
id="close-kudos">Close</button>
</div>
</div>
</div>
</div>
</div>
<script defer>
var closeKudos = document.getElementById("close-kudos");
var openKudos = document.getElementById("Kudos");
closeKudos.addEventListener("click", ()=>{
openKudos.style.display="none";
});
function openKudosModal(){
openKudos.style.cssText = "display:block !important;";
}
</script>
<script>
// Assign Badge Modal Logic
const addBadgeButton = document.getElementById("add-badge-button");
Expand Down
Loading

0 comments on commit 0f05811

Please sign in to comment.