Skip to content
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

Feature/BE-38: Bidding System #371

Merged
merged 11 commits into from
Dec 24, 2022
Merged

Feature/BE-38: Bidding System #371

merged 11 commits into from
Dec 24, 2022

Conversation

BElifb
Copy link
Contributor

@BElifb BElifb commented Dec 22, 2022

  • Created Bid model and updated ArtItem and User models accordingly.

  • Created 2 endpoints with 5 APIs in total.
    image

  • Added new_bid_flag to user, that will be set to true when one of user's art items gets bid on, and it will be set to false when user visits their own profile (after being sent as true).

  • Possible sale status for art item are;

    •     NOTFORSALE = 'NS', _('Not For Sale')
      
    •  FORSALE = 'FS', _('For Sale')
      
    •  SOLD = 'SO', _('Sold')
      
  • Possible responses for a bid are;

    •     REJECTED = 'RE', _('Rejected')
      
    •  ACCEPTED = 'AC', _('Accepted')
      
    •  NORESPONSE = 'NR', _('No Response')
      
  • Created detailed swagger documentation for APIs. :8000/api/v1/swagger/schema/

  • Tested through Postman, Admin site and swagger.

@BElifb BElifb added Effort: Medium Priority: Medium This issue should be handled, if there isn't any high priority issue Status: In Progress The issue is being handled. Coding The issue is related with coding Team: Backend issues related to backend labels Dec 22, 2022
@BElifb BElifb self-assigned this Dec 22, 2022
@BElifb
Copy link
Contributor Author

BElifb commented Dec 22, 2022

  • Created a model called NewBids, that stores new bids that each user has received.
  • Created a signal so that a single instance of NewBids model is created whenever a user account is created via /auth/register/ API.
  • Everytime an art item of a user receives a bid. That art item is added to NewBids of the user.
  • When a user visits their own profile, all of the art items in NewBids are returned and NewBids is set to null for that user.
  • I updated the /users/profile/me/ api so that it returns the art items that have received new bids. Swagger documentation is also updated. Here's a preview:
    image
  • I was thinking for the frontend, when a user visits their profile we could check for newbids, and if there exist any we could add a pop-up of all art items that have received offers with links.
  • Also updated profile serializer so that it returns the necessary information for all of the art items.

@BElifb BElifb marked this pull request as ready for review December 22, 2022 15:42
@BElifb BElifb added Status: Review Needed A review is needed for this issue and removed Status: In Progress The issue is being handled. labels Dec 22, 2022
@BElifb BElifb mentioned this pull request Dec 22, 2022
4 tasks
@BElifb BElifb linked an issue Dec 22, 2022 that may be closed by this pull request
4 tasks
@KarahanS
Copy link
Contributor

  • I got the following warning when I run the code:

    WARNINGS:
    api.NewBids.new_bids: (fields.W340) null has no effect on ManyToManyField

    Removed null = True from new_bids, it's resolved.

  • When we click on the artitems/bids/{id} endpoint on Swagger, artitems/{artitemid}/bids/ is also opened as you stated earlier. I found out the problem: They had the same operation IDs (generated by Swagger automatically): artitemds_bids_update. I fixed that part by manually setting the operation_id to artitems_bids_response for artitems/bids/{id} endpoint. (URL is still the same)

Btw, 403 error message for artitems/{artitemid}/bids/ made me feel sad :(

@KarahanS
Copy link
Contributor

KarahanS commented Dec 23, 2022

I realize you required authentication even for GET requests - which means, guest users won't be able to see the bids on the art items. Did you do it that way intentionally? @BElifb

@KarahanS
Copy link
Contributor

  • As ArtItemSerializer now returns sale_status, minimum_price, bought_by fields, updated documentation of art item related APIs in Swagger.
  • bought_by field was only returning the id of the user for ArtItemSerializer. When an art item is displayed, frontend may want to display the username of the buyer - to avoid a redundant call to profile API, I updated that field to return some information about the buyer as follows (using CommentUserSerializer):
"bought_by": {
        "id": 2,
        "username": "use1r2222d22222222222",
        "profile_path": "avatar/default.png"
    }

Tested the APIs with Postman, everything seems ok. Thanks for the efforts. Approved. (We may update GET requests not to require authentication for them, it's up to you)

@BElifb
Copy link
Contributor Author

BElifb commented Dec 24, 2022

I realize you required authentication even for GET requests - which means, guest users won't be able to see the bids on the art items. Did you do it that way intentionally? @BElifb

Yes, after our discussions about bidding system in the meetings, we landed on max bid not being visible to users. So only the owner of the art item will be able to see all the bids on item. Other than that owner and the buyer can reach a specific bid via id.

@BElifb
Copy link
Contributor Author

BElifb commented Dec 24, 2022

Btw, 403 error message for artitems/{artitemid}/bids/ made me feel sad :(

Sorry 😈

@KarahanS Thank you for the review and updates. I am merging the PR.

@BElifb BElifb merged commit 83a9576 into master Dec 24, 2022
@BElifb BElifb deleted the feature/BE-38 branch December 24, 2022 15:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Coding The issue is related with coding Effort: Medium Priority: Medium This issue should be handled, if there isn't any high priority issue Status: Review Needed A review is needed for this issue Team: Backend issues related to backend
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BE-38: Bidding System
2 participants