emencia / django-blog-lotus

A weblog application with Django.
https://django-blog-lotus.readthedocs.io/
MIT License
5 stars 1 forks source link

Admin mode URL argument is not adopted by links #26

Closed sveetch closed 2 years ago

sveetch commented 2 years ago

Links in a page viewed with admin enabled (?admin=1) do not include it so you can look for a list with admin mode but some detail links may lead to 404 since the admin mode is not passed and so the detail will not find object with default queryset.

And also, we should think about another argument name than "admin" which can troubling, maybe something like "preview" ?

sveetch commented 2 years ago

For automatically passing admin mode URL argument to every URLs we could just use a basic template tag which have access to the context (!=request) so it can know about the enable admin mode and just add ?admin=1 as a following string in the href (no other URL arg usage is planned so it's safe to do).

However we will have to append this tag in the end of every href attribute.

sveetch commented 2 years ago

Also another template tag (which would read current template context) that we could add in the header to create a button to toggle admin mode. Or at least a button to disable admin mode so admin can easily switch to see the site as viewed from non admin users.

sveetch commented 2 years ago

Also add link in sandbox header to reach the admin and ease demonstration.

sveetch commented 2 years ago

Done in 0.5.0-pre.4 with a refactoring to use session instead of URL args, also renamed this to "preview mode" instead of previously named "admin mode".