pontoon icon indicating copy to clipboard operation
pontoon copied to clipboard

Add banner for project managers, give priority to roles within locale

Open flodolo opened this issue 1 year ago • 1 comments

This adds a banner for users defined as "Project Manager" within a project. To reduce the space for confusion, I changed the tooltip of MNGR from "Manager" to "Team Manager".

This also makes the priority of roles consistent between front-end and back-end:

  • If a user as a role within the locale (translator, manager), we use that for the banner.
  • If a user is set as PM, we use that even if the user is an Admin.

Finally, this adds CSS variables for users, instead of reusing the ones for translation status.

Fixes #3418

flodolo avatar Oct 21 '24 14:10 flodolo

Deleted the previous comment because I realize I was testing the same code 🤦🏼

Follow-up on conversation, I tested with with debug_sql():, if I did it correctly:

  • 1 translation comment: new code 6 db calls, previous 5.
  • 1 source comment: 10 db calls, previous 6.

flodolo avatar Oct 21 '24 15:10 flodolo

The second commit fixes #3425

flodolo avatar Oct 25 '24 07:10 flodolo

~My previous version of the code was running without issues, with the last commit (review comments) I see a weird error when I load the first time?~

EDIT: (solved) The suggest code returns a ProjectQuerySet that can't be serialized as JSON

f'Object of type {o.__class__.__name__} '
[server] TypeError: Object of type ProjectQuerySet is not JSON serializable
[server] [ERROR:django.server] 2024-10-25 13:34:52,066 "GET /user-data/ HTTP/1.1" 500 22414

~I also tried to move project to the caller code, but that seems to be more complicated than I expected? Does that require a migration?~

EDIT: removed the diff, because after putting some logging, I realize I was completely off.

flodolo avatar Oct 25 '24 13:10 flodolo

@flodolo Could you please take it for a spin on stage?

In addition to addressing the review comments, I've also fix the color for the MNGR status, which was broken and simplified the logic behind it.

mathjazz avatar Nov 04 '24 21:11 mathjazz

(I'm testing locally because it's easier to mess with projects and users)

Another inconsistency: new user that is not set up as PM for the project, but it's part of project_managers. When commenting (front-end) it shows up as ADMIN, after commenting it shows up as NEW.

flodolo avatar Nov 05 '24 07:11 flodolo

Yeah, we have inconsistent definitions of user statuses between: https://github.com/mozilla/pontoon/blob/da0c8ec105289c5d31ddfc9e46ed7773438c0b05/pontoon/base/views.py#L860 (used when adding a comment)

https://github.com/mozilla/pontoon/blob/da0c8ec105289c5d31ddfc9e46ed7773438c0b05/pontoon/base/models/user.py#L197 (used everywhere else)

mathjazz avatar Nov 05 '24 08:11 mathjazz

Stage updated with the new code.

mathjazz avatar Nov 05 '24 10:11 mathjazz

This works great for me locally. Thanks for taking over, so much larger than I expected

flodolo avatar Nov 05 '24 10:11 flodolo

Could you please also take a look at the code? I can't flag you for a review, since you're the author of the PR.

mathjazz avatar Nov 05 '24 10:11 mathjazz

Could you please also take a look at the code? I can't flag you for a review, since you're the author of the PR.

I should have called out that I did review the various commits 👍🏼

flodolo avatar Nov 05 '24 10:11 flodolo