ContriHUB / ContriHUB-24

ContriHub is an event under Avishkar-24 where we are expecting to get more and more people involved in Open Source activities.
https://sac.mnnit.ac.in/contrihub
MIT License
4 stars 24 forks source link

upvote/downvote #27 #59

Closed DuP-491 closed 3 years ago

DuP-491 commented 3 years ago

fixes #27

Implemented upvote/downvote feature using ajax and bootstrap toast

ankitsangwan1999 commented 3 years ago

Checking

ankitsangwan1999 commented 3 years ago

Important:- In projects/admin.py file, Update the IssueAdmin class as follows. This ensures upvotes/downvotes count shown in admin panel for each issue.

class IssueAdmin(admin.ModelAdmin):
    list_display = ('id', 'title', 'number', 'project', 'mentor', 'level', 'points', 'state', 'get_upvotes_cnt', 'get_downvotes_cnt')

    @display(ordering='issue__upvotes', description='Count of Upvotes')
    def get_upvotes_cnt(self, obj):
        return obj.upvotes.all().count()

    @display(ordering='issue__downvotes', description='Count of Downvotes')
    def get_downvotes_cnt(self, obj):
        return obj.downvotes.all().count()
ankitsangwan1999 commented 3 years ago

Announcement in index.html file are messed up. Fix them Also.

ankitsangwan1999 commented 3 years ago

PROBLEM:

When I am Upvoting and Downvoting an issue the count is not updated instantly for that issue. Instead, this info is updated for the first issue always.

NOTE:- You have used a separate HTML file for defining Upvoted/Downvoted successfully message. Instead what you are required to do is use Django-messages to set the toast message from the backend itself, And instead of using this separate HTML file for upvote/downvote toast only, write a common login for showing whatever message is there in django-messages as toast. This will be done in a js file which you can include in the scripts.html file.

Q: Why do you need to do this? Ans: Because if we want to show other toast messages in the front-end or want to change the toast message for upvotes/downvotes in views.py only. Also, We will not be required to create separate HTML files for each toast message we will add in the future.

ankitsangwan1999 commented 3 years ago

If the deadline of the Issue is crossed. Don't worry we will still consider your commit. But try to fix it by today

ankitsangwan1999 commented 3 years ago

The model fields you added are fine to work with. :+1:

DuP-491 commented 3 years ago

@ankitsangwan1999 added linebreak after button update admin panel code as intended fixed announcement in index html about issue updation I added unique id for issue displayed and accordingly updated them individually

apologies for making so many errors

ankitsangwan1999 commented 3 years ago

Checking

ankitsangwan1999 commented 3 years ago

Hey @DuP-491, Closing this PR here, I have updated some of your partial progress in the main branch already. You will get 20 points as per the updated level of this issue. You may finish the un-implemented part by requesting the new issue that we will create.