From 4304b9d683f02e985638fb52840810ee80c8cf99 Mon Sep 17 00:00:00 2001 From: Drikus Roor Date: Sat, 12 Oct 2024 19:03:56 -0300 Subject: [PATCH] Implement unread notifications filter and enhance NotificationViewSet (#105) * feat: implement unread notifications filter in NotificationViewSet * refactor: Improve notifications --- src/animals/static/js/add_animal.js | 1 - src/blog/urls.py | 8 -- .../static/css/brazil_blog_compiled.css | 23 ++++ src/brazil_blog/urls.py | 1 + src/drinks/static/js/add_drink.js | 1 - src/drinks/views.py | 2 - .../notifications/all-notifications.html | 103 ++++++++++++++++++ .../notifications/includes/notifications.html | 46 ++++++-- src/notifications/urls.py | 8 +- src/notifications/views.py | 14 ++- 10 files changed, 182 insertions(+), 25 deletions(-) create mode 100644 src/notifications/templates/notifications/all-notifications.html diff --git a/src/animals/static/js/add_animal.js b/src/animals/static/js/add_animal.js index fff4280..3b6e3ab 100644 --- a/src/animals/static/js/add_animal.js +++ b/src/animals/static/js/add_animal.js @@ -32,7 +32,6 @@ document.addEventListener('DOMContentLoaded', function() { }) .then(response => response.json()) .then(data => { - console.log('Animal added:', data); // You can add some feedback here, like a toast notification showToast('Animal added successfully!'); }) diff --git a/src/blog/urls.py b/src/blog/urls.py index fda5107..8ac721e 100644 --- a/src/blog/urls.py +++ b/src/blog/urls.py @@ -17,15 +17,7 @@ router.register(r"likes", LikeViewSet) router.register(r"comment-likes", CommentLikeViewSet, basename="comment-likes") - -# path('api/posts-by-date/', posts_by_date, name='posts_by_date'), -# router.register(r"posts-by-date", posts_by_date, basename="posts-by-date") - urlpatterns = [ - path( - "api/", - include("notifications.urls"), - ), path("api/", include(router.urls)), path("api/posts-by-date/", posts_by_date, name="posts_by_date"), path( diff --git a/src/brazil_blog/static/css/brazil_blog_compiled.css b/src/brazil_blog/static/css/brazil_blog_compiled.css index 151b56a..bb22e2d 100644 --- a/src/brazil_blog/static/css/brazil_blog_compiled.css +++ b/src/brazil_blog/static/css/brazil_blog_compiled.css @@ -1598,6 +1598,10 @@ select { margin-top: 1rem; } +.mt-6 { + margin-top: 1.5rem; +} + .mt-8 { margin-top: 2rem; } @@ -1725,6 +1729,10 @@ select { min-height: 12rem; } +.min-h-96 { + min-height: 24rem; +} + .min-h-screen { min-height: 100vh; } @@ -2398,6 +2406,10 @@ select { padding-bottom: 1rem; } +.pb-8 { + padding-bottom: 2rem; +} + .pl-0 { padding-left: 0px; } @@ -2513,6 +2525,11 @@ select { color: rgb(243 244 246 / var(--tw-text-opacity)); } +.text-gray-400 { + --tw-text-opacity: 1; + color: rgb(156 163 175 / var(--tw-text-opacity)); +} + .text-gray-500 { --tw-text-opacity: 1; color: rgb(107 114 128 / var(--tw-text-opacity)); @@ -2590,6 +2607,12 @@ select { opacity: 0.5; } +.shadow { + --tw-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); + --tw-shadow-colored: 0 1px 3px 0 var(--tw-shadow-color), 0 1px 2px -1px var(--tw-shadow-color); + box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow); +} + .shadow-lg { --tw-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1); --tw-shadow-colored: 0 10px 15px -3px var(--tw-shadow-color), 0 4px 6px -4px var(--tw-shadow-color); diff --git a/src/brazil_blog/urls.py b/src/brazil_blog/urls.py index 889079c..4a5cf72 100644 --- a/src/brazil_blog/urls.py +++ b/src/brazil_blog/urls.py @@ -26,6 +26,7 @@ path("locations/", include("locations.urls")), path("drinks/", include(drinks_urls)), path("animals/", include(animals_urls)), + path("notifications/", include("notifications.urls")), ] diff --git a/src/drinks/static/js/add_drink.js b/src/drinks/static/js/add_drink.js index 73b7f78..8f6c95f 100644 --- a/src/drinks/static/js/add_drink.js +++ b/src/drinks/static/js/add_drink.js @@ -32,7 +32,6 @@ document.addEventListener('DOMContentLoaded', function() { }) .then(response => response.json()) .then(data => { - console.log('Drink added:', data); // You can add some feedback here, like a toast notification showToast('Drink added successfully!'); }) diff --git a/src/drinks/views.py b/src/drinks/views.py index 0bb28d6..c13ff1f 100644 --- a/src/drinks/views.py +++ b/src/drinks/views.py @@ -224,8 +224,6 @@ def get_context_data(self, **kwargs): today_date = date.today() total_days_amount = (today_date - start_date).days + 1 - print(total_days_amount) - # Average drinks per day per type avg_drinks = ( DrinkType.objects.all() diff --git a/src/notifications/templates/notifications/all-notifications.html b/src/notifications/templates/notifications/all-notifications.html new file mode 100644 index 0000000..d2d3a0e --- /dev/null +++ b/src/notifications/templates/notifications/all-notifications.html @@ -0,0 +1,103 @@ +{% extends "base.html" %} {% load static %} {% block content %} +
+
+

All Notifications

+ +
+ +
+ + +
+
+ + +{% endblock %} diff --git a/src/notifications/templates/notifications/includes/notifications.html b/src/notifications/templates/notifications/includes/notifications.html index 2637569..0cc4809 100644 --- a/src/notifications/templates/notifications/includes/notifications.html +++ b/src/notifications/templates/notifications/includes/notifications.html @@ -12,7 +12,7 @@ -