cuducos / django-public-admin

🔓 A public and read-only version of the Django Admin
MIT License
64 stars 5 forks source link

Hide recent changes to anonymous user #20

Closed jhrdt closed 4 years ago

jhrdt commented 4 years ago

DummyUser is a AnonymousUser, so hiding the recent changes will only affect users that are not logged-in. Admin will work as usual.

This solution is Django friendly due to the fact that no code is replace, but rather extented in a Django-way.

jhrdt commented 4 years ago

Die PR is related to #19 .

cuducos commented 4 years ago

Hi @jhrdt, many thanks for your contribution.

I do agree with your proposed change, but with one minor comment: o hiding the recent changes will only affect users that are not logged-in. This makes little sense in the context of this project as every user will be using the admin without login. This is the whole purpose of this package.

Code-wise it means we don't if not request.user.is_anonymous in the template bit, because this template will be only used with public_admin Django app, which does not allow logged-in users. Would you mind changing that?

jhrdt commented 4 years ago

Hej,

I can do that, but you are aware that this change (your proposed change) will remove the recent changes from /admin public_admin is placed on top in the settings order, so this index.html template will be loaded in /admin.

cuducos commented 4 years ago

Yes, that’s a great point.

Thus, maybe, we could review other templates in this package to make all them “compatible” with both the native admin and this public admin. What do you think?

jhrdt commented 4 years ago

Hi,

then we should keep if not request.user.is_anonymous in the template. This will hide it in the public admin (accessing as dummyuser who is anonymous) and keep the /admin intact.

Shall we revert to e97aee6ec363666fb88d476cd0c5cf24ff7a5845?

We could apply a similar logic to the base.html.

cuducos commented 4 years ago

Yep, sorry if I wasn't clear! Let's go step by step:

then we should keep if not request.user.is_anonymous in the template. This will hide it in the public admin (accessing as dummyuser who is anonymous) and keep the /admin intact.

Yes, you have a great point so let's keep it.

Shall we revert to e97aee6?

Yes, but also feel free to rebase and push with -f to organize the branch as you wish : )

We could apply a similar logic to the base.html.

Yes, that was my point, so the template files offered in this package are all following the same principle.

Also, we can review the docs on these template files to clarify what the new scenario is: that is to say, be clear that the templates here should not change the default behavior of the native admin ; )

jhrdt commented 4 years ago

I reverted the changes and applied the same logic to base.html .

anapaulagomes commented 3 years ago

Hi @jhrdt! Thanks to your contribution now our page is much cleaner and less confusing for the users. Thank you :) http://www.dadosabertosdefeira.com.br/painel/