adamdoty / homebaker

A baked-goods, birthday-treat, tracking app I made for my wife.
3 stars 0 forks source link

coupon redemption #44

Closed adamdoty closed 1 year ago

adamdoty commented 1 year ago

coupon redemption for treat in the catalogue and coupon redemption for treat not in the catalogue complete

bbelderbos commented 1 year ago

@adamdoty code seems good but I am hitting a few bugs testing it out with 2 users (baker / non baker):

When I request a treat I get this (btw the button says "redeem coupon" but I don't see any coupon in this form):

Screenshot 2022-10-05 at 12 52 42 Screenshot 2022-10-05 at 12 52 49

In the debugger I see this:

Screenshot 2022-10-05 at 12 53 51
bbelderbos commented 1 year ago

When I try to add or edit a coupon in the admin I also get a crash:

Screenshot 2022-10-05 at 12 54 29 Screenshot 2022-10-05 at 12 55 25

Changing that line to if self.treat and self.treat.is_recipient_request: would fix it but I am not sure if self.treat should be None at this point (symptom vs cause)

With that change I do see records being updated:

Screenshot 2022-10-05 at 12 58 56

Lastly the coupon page links to the treat:

Screenshot 2022-10-05 at 12 57 45

Clicking edit treat on the treat page as a non-baker redirects me to login - good, but you can also add an if in the template to hide the edit links when not a baker:

image

Btw another TODO: would be to also prevent bakers from editing each other's treats. But let's not go there yet. Let's first focus on fixing the issues with redemption. Great work so far, let me know if you need help as you go with this ...

adamdoty commented 1 year ago
  1. Request a Treat Form - labeled as "Redeem Coupon"
  1. 1st Django error message image - Yes this was a bug with fix in progress.

    • Right now it is presenting the error because the treat doesn't exist, but we are trying to assign a treat to the coupon.
  2. Coupon add/edit issue

    • So the error is occuring because in the coupon we are checking whether or not the coupon's treat is a recipient request, but since the treat is None type, it can't.
    • To me the logic here is that the baker can assign a coupon without a treat, user selected, because treat selection is on the recipient, UNLESS the baker knows the treat. Absent user case
    • Not sure how to approach this, lets discuss.
  3. Treat page for a treat request

    • I think I would like to hide this from recipient users completely
  4. Treat page for a recipient user

    • Remove all links, notes
  5. I would like to use the slugs in the urls - as antonio does in the blog application

    • So buckeyes treat would read localhost:8000/treat/buckeyes

OTHER

bbelderbos commented 1 year ago

Flowchart submitted in PR:

image

= super helpful. Thanks.

adamdoty commented 1 year ago

its also in the readme as an image, but only in the calendar branch currently