adamdoty / homebaker

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

extend user model / table with profile model / table #35

Closed bbelderbos closed 2 years ago

bbelderbos commented 2 years ago

I recommend option 2 https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html#onetoone

Need is to be able to signify a baker over a regular user to lock down coupon and treat views to "for bakers only" (for that we can use the django.contrib.auth.decorators.user_passes_test decorator later on.

adamdoty commented 2 years ago

When a not baker user tries to access a restricted view, they are served the login page without explanation. I would like to add a message stating "restricted access" or possibly an error, but I'm not sure where I would add that since the user is being redirected by the decorator?

bbelderbos commented 2 years ago

You can use Django's messages framework by using messages.error() - but yeah how to do that with an existing decorator? Maybe wrap a new decorator around it? That's what my Google / SO search suggests too: https://stackoverflow.com/a/24423890

adamdoty commented 2 years ago

From the search link, it seems, take the functionality of login and add the messaging feature. I'll give it a shot.

bbelderbos commented 2 years ago

Hope it does not overcomplicate it, maybe we can look at this together on our next call ...