From c701c075bace5d2052717e6288f1dac700dc5d84 Mon Sep 17 00:00:00 2001 From: SahilDhillon21 Date: Fri, 17 Nov 2023 17:48:59 +0530 Subject: [PATCH 1/3] like dislike backend logic done --- blt/urls.py | 7 +- .../0081_userprofile_issue_downvoted.py | 20 +++++ website/models.py | 1 + website/templates/_dislikes.html | 37 ++++++++++ website/templates/_flags.html | 4 +- website/templates/_likes.html | 6 +- website/templates/issue.html | 41 +++++++++- website/views.py | 74 +++++++++++++++++++ 8 files changed, 182 insertions(+), 8 deletions(-) create mode 100644 website/migrations/0081_userprofile_issue_downvoted.py create mode 100644 website/templates/_dislikes.html diff --git a/blt/urls.py b/blt/urls.py index e9e40ef3f..64b8d5d5c 100644 --- a/blt/urls.py +++ b/blt/urls.py @@ -285,10 +285,15 @@ re_path( r"^like_issue/(?P\d+)/$", website.views.like_issue, name="like_issue" ), + re_path( + r"^dislike_issue/(?P\d+)/$", website.views.dislike_issue, name="dislike_issue" + ), + re_path( + r"^update_issue_likes_dislikes/(?P\d+)/$", website.views.update_issue_likes_dislikes, name="like_issue" + ), re_path( r"^flag_issue/(?P\d+)/$", website.views.flag_issue, name="flag_issue" ), - re_path( r"^like_issue2/(?P\d+)/$", like_issue2, name="like_issue2" ), diff --git a/website/migrations/0081_userprofile_issue_downvoted.py b/website/migrations/0081_userprofile_issue_downvoted.py new file mode 100644 index 000000000..832f532d7 --- /dev/null +++ b/website/migrations/0081_userprofile_issue_downvoted.py @@ -0,0 +1,20 @@ +# Generated by Django 4.2.7 on 2023-11-17 09:00 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("website", "0080_alter_issue_team_members"), + ] + + operations = [ + migrations.AddField( + model_name="userprofile", + name="issue_downvoted", + field=models.ManyToManyField( + blank=True, related_name="downvoted", to="website.issue" + ), + ), + ] diff --git a/website/models.py b/website/models.py index 95d2b281e..055b0a375 100644 --- a/website/models.py +++ b/website/models.py @@ -448,6 +448,7 @@ class UserProfile(models.Model): max_digits=10, decimal_places=2, null=True, blank=True ) issue_upvoted = models.ManyToManyField(Issue, blank=True, related_name="upvoted") + issue_downvoted = models.ManyToManyField(Issue, blank=True, related_name="downvoted") issue_saved = models.ManyToManyField(Issue, blank=True, related_name="saved") issue_flaged = models.ManyToManyField(Issue,blank=True,related_name="flaged") issues_hidden = models.BooleanField(default=False) diff --git a/website/templates/_dislikes.html b/website/templates/_dislikes.html new file mode 100644 index 000000000..1d7f1299e --- /dev/null +++ b/website/templates/_dislikes.html @@ -0,0 +1,37 @@ +{% load gravatar %} + +{% if request.user.is_authenticated %} + + {{ dislikes }} + +{% else %} + +{% endif %} + +{% if dislikers %} + Disliked By +{% endif %} + +{% if dislikers %} + +{% endif %} \ No newline at end of file diff --git a/website/templates/_flags.html b/website/templates/_flags.html index 49ab32d34..62f1a10f2 100644 --- a/website/templates/_flags.html +++ b/website/templates/_flags.html @@ -2,11 +2,11 @@ {% if request.user.is_authenticated %} - Flag {{ flags }} + Flag {{ flags }} {% else %} {% endif %} diff --git a/website/templates/_likes.html b/website/templates/_likes.html index 7f2ea5f08..21a96e52c 100644 --- a/website/templates/_likes.html +++ b/website/templates/_likes.html @@ -10,10 +10,11 @@ {% endif %} -{% if likes %} +{% if likers %} Liked By {% endif %} +{% if likers %} - \ No newline at end of file + +{% endif %} \ No newline at end of file diff --git a/website/templates/issue.html b/website/templates/issue.html index 48e5050e5..d1774b6b6 100644 --- a/website/templates/issue.html +++ b/website/templates/issue.html @@ -85,7 +85,8 @@ .bookmark, .copy-btn, .flag_btn a.flaged-by, - .like_btn a.liked-by { + .like_btn a.liked-by, + .dislike_btn a.disliked-by { vertical-align: top; } @@ -183,8 +184,13 @@