Open alexwennerberg opened 9 months ago
I noticed the TemplateData is inconsistently populated across handlers. I think context.Context
could help provide the user data, and you can take the context as a parameter to build a baseline TemplateData in the handlers. This would ensure things like the user id, is logged in, is admin is consistently filled out.
There's also some spots where we can avoid duplicated calls to the database asking for the individual fields for the user data.
I have some code working for this locally. I could make a PR if it's okay with @cblgh
the admin link missing was actually intended, but perhaps it wasn't so useful. i just wanted to constrain the admin controls and reminders to one place rather than always having an admin top-hat on
@JamieCrisman can you put up your changes on a branch you host somewhere and link me? reading someone's code and giving it a think over would be a nice intermediate from the almost conflict-oriented PR approach github has imposed on collaboration :)
I've made a branch. I tried to break it up into more bite sized commits. And attempted to explain the changes in the commit message.
First three are the main changes. First two just setting up for the third. Last one is a little side thing I noticed while testing.
https://github.com/cblgh/cerca/compare/main...JamieCrisman:cerca:context
For non-admin users, would it be good to have a link to the admin page (maybe on the about page)? Or is that being held off for some reason? Thought it was interesting to realize there's an admin and moderation log that could be seen and even works on merveilles instance, but is not linked to anywhere.
on e.g. /about, there is no "admin" link in the header, I believe because
IsAdmin
is not populated.With
IsAdmin
andPending
booleans, I wonder if storing a larger 'logged in user metadata' struct rather than getting each field individually may be valuable, and reduce code duplication