anipiano / anipianolist

"ok guys we need to make the myanimelist of all piano arrangements" – fruit 2022
MIT License
0 stars 2 forks source link

request.get_username #4

Open aidswidjaja opened 1 year ago

aidswidjaja commented 1 year ago

get_username() fetches usernames which have been invalidated. See top-right corner

image

Low priority and zero impact on services, but good first issue.

vrii14 commented 1 year ago

Hi, I would like to work on this. What exactly is expected to be done for this? Should it not fetch username if it is invalid?

aidswidjaja commented 1 year ago

Hi @vrii14! Essentially, we use the Django get_username() method in the form of its Jinja templating equivalent {{ user.get_username}}. https://docs.djangoproject.com/en/dev/ref/contrib/auth/#django.contrib.auth.models.User.get_username. We extend the default User model with custom validation.

get_username is called to fetch the currently logged-in user's username and display it in the top-right button as shown in the screenshot in the original issue description (I call this the Magic Button internally).

Ideally, the expected behaviour is that it fetches the currently used validated username. An invalid form submission should not result in the invalidated username being submitted - which is what occurs when checking in Django /admin/. However, for some weird reason, the get_username method returns the invalidated username on my local dev server, at least on that page.

I am not sure if this is an (albeit low priority) bug in the method or my own misapplication of it's attributes. Logic may need to be implemented to work around this.

WajahatKanju commented 1 year ago

I have fix it. Please checkout Pull Request #7