-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jv/add comments likes #144
base: main
Are you sure you want to change the base?
Conversation
{ | ||
"error_status": True, | ||
"success_status": False, | ||
"exception": e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revealing the exception data can be a security threat - Better to not disclose exception data
response.JsonResponse | ||
""" | ||
try: | ||
comment = request.query_params.get("comment") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are expecting a query parameter, have you defined a URL to accept the delete_comment request? Django works on a model-template view basis so you will need to create a view for deleting comments in the views.py and add a URL path for it as well.
@@ -123,3 +123,183 @@ def fetch_data(self) -> response.JsonResponse: | |||
return docs | |||
|
|||
raise DataFetchingError("There Are No Posts In The Database At This Moment") | |||
|
|||
|
|||
class Likes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To receive the likes, a URL will need to be created along with a view. This will refer to the endpoint that accepts the like and performs the database functionality - It will also update the UI with an increment in the Like Number on the screen.
) | ||
|
||
def delete_all_data(self) -> None: | ||
"""Delete all likes from db |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functionality should only be with the admin - Deleting the data should not be used by any ordinary developer
@@ -12,7 +12,7 @@ | |||
InvalidAdminIDError, | |||
) | |||
|
|||
from . import Paginate, Music_Data, User_Data, Admin_Auth, Admin_Token_Auth | |||
from . import Paginate, Music_Data, User_Data, Admin_Auth, Admin_Token_Auth, Comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These dot imports are from the init file - It does not seem like you have added a class so it can be imported
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -123,3 +123,183 @@ def fetch_data(self) -> response.JsonResponse: | |||
return docs | |||
|
|||
raise DataFetchingError("There Are No Posts In The Database At This Moment") | |||
|
|||
|
|||
class Likes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can also add a Dislike option with the same functionality and use flags to decipher which one you are dealing with to prevent code repetition
raise DataFetchingError("There Are No Likes In The Database At This Moment") | ||
|
||
|
||
class Comments: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar to the likes - To receive the comments, a URL will need to be created along with a view. This will refer to the endpoint that accepts the comment and performs the database functionality - It will also update the UI with the comment for the client
f"Comment: \n{comment}\ndoes not exists." | ||
) | ||
|
||
def delete_all_data(self) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This functionality should be restricted to the admin only
""" | ||
self.db.remove() | ||
|
||
def fetch_data(self) -> response.JsonResponse: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another function can be created to fetch comments for a specific post as well
} | ||
self.db.insert_one(data) | ||
|
||
def delete_data(self, comment: str) -> None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the "comment" field represents the comment ID then where is the comment being stored and if not then the ID is not used or present.
@@ -123,3 +123,183 @@ def fetch_data(self) -> response.JsonResponse: | |||
return docs | |||
|
|||
raise DataFetchingError("There Are No Posts In The Database At This Moment") | |||
|
|||
|
|||
class Likes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, If you check the user profile, it has a list for contact_us query IDs. Similarly, you should create a list for likes and comments so that we can see which posts a user has liked and commented. This will make user analysis and function handling easier.
None | ||
""" | ||
|
||
data = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe include a comment ID? I can only see a comment field - no ID has been created or stored. Prefix the ID with 'ct'
For example:
ct_153g2e3u0238e0uj
That is an example of the comment ID and like IDs can also be similar
Description
Added likes and comments models. Implemented tests and added func for admins to delete comment.
References
Fixes # (issue)
Type of change
How Has This Been Tested?
Test Configuration:
Checklist: