django-js-routes
django-js-routes copied to clipboard
Group routes
Hi +1 for this package, While exposing the routes is a good thing, Is there a way one can group the routes exposed and show only some on some certain scenarios?
Imagine when you are not authenticated, and have a dashboard route, I won't want to expose this. How about we have @ellmetha let me know your thoughts on this, or rather if this package handles it in another way. Else I can send a PR for this.
JS_ROUTES_INCLUSION_LIST = [
{
'guest': ['home', 'about', 'privacy_policy' .... ]
},
{
'auth': ['home', 'about', 'privacy_policy', 'dashboard.index', 'dashboard.posts' .... ]
},
]
With this, a logic can be put on our front-ends as -
{% if user.is_authenticated %}
{% js_routes group='auth' %}
{% else %}
{% js_routes group='guest' %}
{% endif %}
I think it makes a lot of sense. Perhaps we would need a JS_ROUTES_INCLUSION_LISTS setting for this though (since we would have many lists):
JS_ROUTES_INCLUSION_LISTS = {
'guest': ['home', 'about', 'privacy_policy' .... ],
'auth': ['home', 'about', 'privacy_policy', 'dashboard.index', 'dashboard.posts' .... ],
}
I think it makes a lot of sense. Perhaps we would need a
JS_ROUTES_INCLUSION_LISTSsetting for this though (since we would have many lists):JS_ROUTES_INCLUSION_LISTS = { 'guest': ['home', 'about', 'privacy_policy' .... ], 'auth': ['home', 'about', 'privacy_policy', 'dashboard.index', 'dashboard.posts' .... ], }
Yes @ellmetha. Is this in the pipeline?
Yes @ellmetha. Is this in the pipeline?
For now it's not as I don't have much time to allocate to this project. That being said, I will be happy to review any PRs regarding this! 😃
I think this would be a very good feature to have, as it really removes some of the security concerns one could have otherwise. Are you working on a PR for this @muarachmann?