-
Notifications
You must be signed in to change notification settings - Fork 55
Possibility to create items only staff can see #22
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution! I like this idea. Can you please make a few minor changes to the MenuItem filtering to keep it in line with existing functionality?
setup.py
Outdated
@@ -4,7 +4,7 @@ | |||
from fnmatch import fnmatchcase | |||
from setuptools import setup, find_packages | |||
|
|||
version = '0.1.10' | |||
version = '0.1.10.1' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please revise this to be 0.1.11?
menu/templatetags/menubuilder.py
Outdated
@@ -92,7 +92,15 @@ def get_items(menu_name, current_path, user): | |||
if not menu: | |||
return [] | |||
|
|||
for i in MenuItem.objects.filter(menu=menu).order_by('order'): | |||
if (str(user) == 'AnonymousUser' or str(user) == 'None'): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you look at line #74, there are some checks for user type - ie anonymous or logged-in. Can you please add to those for is_staff, and build it into the cache key? Lastly, you can go back to a single MenuItem.objects()
query and build in the is_staff filtering on line #114 (see menuitems.append
when conditions are met).
This keeps your change in line with the previous structure of this file. It also means all similar checks occur in a similar manner.
Appreciate that you like the idea. |
Good afternoon, I would like to extend the model to add more fields to the menu, is there a way to do it? i want to create the icon field and the permissions field, i'm sorry beforehand i know this is not the place for the question but i'm a little lost |
@elkinlrc There is no supported way to do this at present. It would likely be easy to fork the project and make this change yourself. |
With this changes it is possible to create items only visible to the staff group.
I would need this in my own django project.
Would be nice to see it in your master branch.