You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+166-2Lines changed: 166 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,8 +18,172 @@ and this project attempts to adhere to [Semantic Versioning](https://semver.org/
18
18
19
19
## [Unreleased]
20
20
21
-
### New Contributors!
21
+
## [0.11.0]
22
+
23
+
### Fixed
24
+
25
+
- Checking whether a `NavItem` or `NavGroup` is active now takes into account the URL scheme and domain name for both the nav item and request.
26
+
27
+
## [0.10.0]
28
+
29
+
### Added
30
+
31
+
- Support for Python 3.13.
32
+
33
+
### Changed
34
+
35
+
- Bumped `django-twc-package` template to v2024.23.
36
+
- Removed `westerveltco/setup-ci-action` from GitHub Actions workflows.
37
+
38
+
## [0.9.0]
39
+
40
+
### Changed
41
+
42
+
- Updated `NavItem.get_active` to allow for using URLs that contain query strings.
43
+
44
+
## [0.8.0]
45
+
46
+
### Changed
47
+
48
+
- Updated `NavItem.url` and `NavItem.get_url` to allow for using a callable. This allows `NavItem.url` to support `django.urls.reverse` or `django.urls.reverse_lazy` primarily, but it can be any callable as long as it returns a string.
49
+
50
+
## [0.7.0]
51
+
52
+
### Added
53
+
54
+
-`NavItem` and `NavGroup` now both have a `get_context_data` that returns the context needed for template rendering.
55
+
-`NavItem` and `NavGroup` now both have a `get_url` method for returning the URL for the item.
56
+
-`NavItem` and `NavGroup` now both have a `get_active` method for returning whether the item is active or not, meaning it's the URL currently being requested.
57
+
-`NavItem` and `NavGroup` now both have a `check_permissions` method for checking whether the item should be rendered for a given request.
58
+
-`NavItem` and `NavGroup` now support using a callable in the list of `permissions`. This callable should take an `HttpRequest` and return a `bool` indicating whether the item should be rendered for a given request.
59
+
- The `Nav` class now has a `get_template` method that returns the template to render. This method takes an optional `template_name` argument, and if not provided is taken from the `get_template_name` method. If overridden, you can return a string as a way to embed a template directly in the `Nav` definition.
60
+
-`NavItem` now has a `get_items` method. This is to aid a future refactor.
61
+
62
+
### Changed
63
+
64
+
- Internals of library have been refactored to slightly simplify it, including `Nav`, `NavGroup`, `NavItem` and the `django_simple_nav` templatetag.
65
+
-`Nav.get_items` now returns a list of `NavGroup` or `NavItem`, instead of a list of `RenderedNavItem`.
66
+
- Check for the existence of a user attached to the `request` object passed in to `django_simple_nav.permissions.check_item_permissions` has been moved to allow for an early return if there is no user. There are instances where the `django.contrib.auth` app can be installed, but no user is attached to the request object. This change will allow this function to correctly be used in those instances.
67
+
- Now using v2024.20 of `django-twc-package`.
68
+
-`NavGroup` is now marked as active if the request path matches it's URL (if set) **or** and of its items' URLs.
69
+
70
+
### Removed
71
+
72
+
- The `extra_context` attribute of `NavItem` and `NavGroup` now only renders the contents of the dictionary to the template context. Previously it did that as well as provided `extra_context` to the context. If this sounds confusing, that's because it kinda is. 😅 This basically just means instead of two places to get the extra context (`extra_context` and the keys provided within the `extra_context` attribute), there is now just one (the keys provided within the `extra_context` attribute).
73
+
-`RenderedNavItem` has been removed and it's functionality refactored into both `NavItem` and `NavGroup`. This should not affect the public API of this library, but I thought it should be noted.
74
+
-`django_simple_nav.permissions` module has been removed and it's functionality refactored into `NavItem`.
75
+
- Dropped support for Django 3.2.
76
+
77
+
### Fixed
78
+
79
+
-`active` boolean for a `NavItem` should now accurately match the request URL, taking into account any potential nesting and a project's `APPEND_SLASH` setting.
80
+
- The permissions check for `NavGroup` has been fixed to apply to the child items as well. Previously, it only checked the top-level permissions on the `NavGroup` instance itself. If the items within the `NavGroup` have permissions defined, they will now be checked and filtered out. If the check ends up filtering all of the items out and the `NavGroup` has no url set, then it will not be rendered.
81
+
82
+
## [0.6.0]
83
+
84
+
### Added
85
+
86
+
- Added two new methods to `Nav`: `get_items` and `get_template_name`. These should allow for further flexibility and customization of rendering the `Nav`.
87
+
88
+
### Changed
89
+
90
+
- Now using v2024.16 of `django-twc-package`.
91
+
92
+
### Fixed
93
+
94
+
- Active nav item matching is now correctly using the `url` property on `RenderedNavItem`.
95
+
96
+
## [0.5.1]
97
+
98
+
### Added
99
+
100
+
- Added the requisite `py.typed` file to the package, so that it plays nicely when type-checking in projects using `django-simple-nav`.
101
+
102
+
## [0.5.0]
103
+
104
+
### Added
105
+
106
+
- An number of examples have been added to a new `example` directory. These examples are intended to demonstrate various ways how to use `django-simple-nav` in a Django project and include basic usage and usage with some popular CSS frameworks.
107
+
108
+
### Changed
109
+
110
+
-`check_item_permission` now takes a `request` argument instead of a `user` argument.
111
+
112
+
### Fixed
113
+
114
+
-`check_item_permission` now explicitly checks if `django.contrib.auth` is installed before attempting to check if a user has a permission. If it is not, it will return `True` by default and log a warning.
115
+
- The `request` object is now passed to `render_to_string` when rendering the navigation template, so that the `request` object is available in the template context. This allows for nesting the `django_simple_nav` template tag within another `django_simple_nav` template tag, and having the `request` object available in the nested template.
116
+
117
+
## [0.4.0]
118
+
119
+
### Added
120
+
121
+
- The `Nav` class now has two new methods: `get_context_data` and `render`. These methods are used to render the navigation to a template. These new methods give greater flexibility for customizing the rendering of the navigation, as they can be overridden when defining a new `Nav`.
122
+
-`Nav.get_context_data` method takes a Django `HttpRequest` object and returns a dictionary of context data that can be used to render the navigation to a template.
123
+
-`Nav.render` method takes a Django `HttpRequest` object and an optional template name and renders the navigation to a template, returning the rendered template as a string.
124
+
125
+
### Removed
126
+
127
+
-`Nav.render_from_request` method has been removed. This was only used within the template tag to render a `Nav` template from an `HttpRequest` object. It has been removed in favor of the new `Nav.get_context_data` and `Nav.render` methods.
128
+
129
+
## [0.3.0]
130
+
131
+
### Added
132
+
133
+
-`NavGroup` and `NavItem` now has a new `extra_context` attribute. This allows for passing additional context to the template when rendering the navigation, either via the extra attribute (`item.foo`) or the `extra_context` attribute itself (`item.extra_context.foo`).
134
+
135
+
### Changed
136
+
137
+
- Now using v2024.13 of `django-twc-package`.
138
+
139
+
### Fixed
140
+
141
+
-`RenderedNavItem.items` property now correctly returns a list of `RenderedNavItem` objects, rather than a list of `NavItem` objects. This fixes a bug where the properties that should be available (e.g. `active`, `url`, etc.) were not available when iterating over the `RenderedNavItem.items` list if the item was a `NavGroup` object with child items.
142
+
143
+
## [0.2.0]
144
+
145
+
### Added
146
+
147
+
- The `django_simple_nav` template tag can now take an instance of a `Nav` class, in addition to a `Nav` dotted path string. This should give greater flexibility for rendering a `Nav`, as it can now be overridden on a per-view/template basis.
148
+
149
+
### Changed
150
+
151
+
- Now using [`django-twc-package`](https://github.com/westerveltco/django-twc-package) template for repository and package structure.
152
+
153
+
## [0.1.0]
154
+
155
+
Initial release! 🎉
156
+
157
+
### Added
158
+
159
+
- A group of navigation classes -- `Nav`, `NavGroup`, and `NavItem` -- that can be used together to build a simple navigation structure.
160
+
-`Nav` is the main container for a navigation structure.
161
+
-`NavGroup` is a container for a group of `NavItem` objects.
162
+
-`NavItem` is a single navigation item.
163
+
- A `django_simple_nav` template tag that renders a `Nav` object to a template. The template tag takes a string represented the dotted path to a `Nav` object and renders it to the template.
164
+
- Navigation item urls can be either a URL string (e.g. `https://example.com/about/` or `/about/`) or a Django URL name (e.g. `about-view`). When rendering out to the template, the template tag will resolve the URL name to the actual URL.
165
+
- Navigation items also can take a list of permissions to control the visibility of the item. The permissions can be user attributes (e.g. `is_staff`, `is_superuser`, etc.) or a specific permission (e.g. `auth.add_user`).
166
+
- Navigation items are marked as `active` if the current request path matches the item's URL. This is can be useful for highlighting the current page in the navigation.
167
+
- A `Nav` object's template can either be set as a class attribute (`template_name`) or passed in as a keyword argument when rendering the template tag. This allows for easy customization of the navigation structure on a per-template or per-view basis.
0 commit comments