python-gsoc / python-blogs

Python Software Foundation GSoC Blog Platform. This system was used until 2024 but is no longer maintained.
http://python-gsoc.org/
GNU Affero General Public License v3.0
41 stars 60 forks source link

GSoC 2019 - Hide admin only fields #50

Closed botanicvelious closed 5 years ago

botanicvelious commented 5 years ago

This task is to not allow non super user users when adding a blog post article to not be able to change the following.

ghost commented 5 years ago

@botanicvelious I'd like to work on this one. :)

botanicvelious commented 5 years ago

go for it

ghost commented 5 years ago

https://github.com/ntkomata/python-blogs @botanicvelious I tried to add certain fields to readonly_fields when the user is student, but it threw an error saying "unknown fields". just run the server, and log in (i made "admin" a student), and change or create a new article and you'll see the error.

botanicvelious commented 5 years ago

Try get_fields, see if you can find what they are,

https://docs.djangoproject.com/en/2.1/ref/models/meta/

Options.get_fields(include_parents=True, include_hidden=False)[source]¶

Could be that you arent accessing the correct field

ghost commented 5 years ago

@botanicvelious just checked the fields. Turns out there are 3 sets of fields from ArticleAdmin, ArticleForm and the Article model, which seems complicated and messy. Maybe I should make some changes to permissions instead of form fields. :)

botanicvelious commented 5 years ago

So long as the student cant change those fields however you go about it is fine by me! 👍