Giter Site home page Giter Site logo

lalogiadepython / django-menu-generator Goto Github PK

View Code? Open in Web Editor NEW
28.0 28.0 18.0 278 KB

A straightforward menu generator for Django

License: MIT License

Python 100.00%
django generator menu menu-generator menu-item menu-navigation menubar no-database python simple

django-menu-generator's People

Contributors

hansegucker avatar juandgc avatar lachmanfrantisek avatar lucaskuzma avatar miltonln avatar natureshadow avatar yamijuan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

django-menu-generator's Issues

Root menu with submenus wrong selected value

The selected value of a root menu is overriden by _process_breadcrums. For example, if the _is_selected function correctly determines that a root menu is selected by accessing a link which contains the root's url, when _process_breadcrums is run, the selected value goes back to False.

As a workaround for this issue you can use:
{% if item.selected or item.url in request.path %} active {% endif %}

related_urls match too much

The new related_urls feature matches too much, i.e. in the middle of a string.

Giving /car as related URL will not only match /car/1, but also /drinks/categories/carbonated. Using a trailing / would help a bit, but that would mean that /person is not matched under all circumstances.

Feature request: Select menu item if a related URL is opened

If you use submenus in a Django application, they are mostly collapsed if no menu item is selected. Calling a menu item from this submenu will take much longer than if it's already open (marked as selected).

Example with no selected submenu item and collapsed submenus:
grafik

Example with selected submenu item and opened submenu:
grafik

If you are directly on the page with the URL set in the menu config, the correct submenu item is selected and you can easily switch between other submenu items in the same submenu. But often you have a submenu item which is called "Persons" and shows a person list, for example. But what happens if you open a edit or details page for one person? The URL changes, so the submenu item is no longer selected, but you actually want that it's still selected.

Therefore my idea is adding an option to define a list of related URLs for every menu item. If one of these URLs is opened, the menu item will be marked then as selected, too.

Thank you for reading this slightly longer text! I would be happy to get some feedback on this idea and whether an implementation of this idea would be a benefit for this project accepted by you.

Notice: The screenshots are taken from AlekSIS, the free school information system.

Feature Request: menu item decorator

Sometimes it is important to decorate a menu item with a different visual element. It is a way to indicate to the user that something need to be done through the given menu element.

For instance, a badge should be put on a menu item to indicate a necessary action to be taken by the user. But in the current implementation there is no easy way to do so. It is necessary to evaluate the menu item element in order to decorate it properly.

So, during rendering, it should be only a matter of evaluating a single menu item element in order to decide, on a template, how to decorate this menu item.

Issue with menu in apps when AppConfig is referenced in INSTALLED_APPS

The get_menu_from_apps function is looking for sub classes « menus ». Therefore, when following the recommandations for django 2.0+ which are to put the AppConfig class path in the INSTALLED_APPS instead of the main app class (cf https://docs.djangoproject.com/en/2.0/ref/applications/), the function does not find the MENUS dictionaries.

Ex:
The following works:
INSTALLED_APPS = [
# local apps
‘account',

The following does not work:
INSTALLED_APPS = [
# local apps
‘account.apps.AccountConfig’,

If first validator fails, the rest shouldn't be evaluated

Currently I have a menu where I use the is_authenticated validation of menu_generator so I don't to ask that again in my own validator, but due the fact all validators are evaluated, an anonymous user reaches my validator and fails. Here is and example:

MENUS = {
    "NAV_MENU_LEFT": [
        {
            "name": _("Users"),
            "url": "/",
            "icon_class": "fal fa-user",
            "validators": [
                "menu_generator.validators.is_authenticated",
                ("users.validators.has_user_type", "superuser"),
            ],
        }
    ]
}

Allow merging menus with same name

If several apps declare a menu item with the same name, and the item has a submenu, it would be good to merge the two menus together into one. That way, apps cann add menu entries to existing submenues.

It would also be possible to enable or disable merging with an additional attribute.

validators

the validators are not validating with an "and" operator .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.