mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-09 00:58:16 -06:00
Added alphabetical ordering of bookmarks.
This commit is contained in:
parent
c27cb6f153
commit
759cbc369d
@ -117,10 +117,12 @@ class BookmarkOrderingChoices(ChoiceSet):
|
|||||||
|
|
||||||
ORDERING_NEWEST = '-created'
|
ORDERING_NEWEST = '-created'
|
||||||
ORDERING_OLDEST = 'created'
|
ORDERING_OLDEST = 'created'
|
||||||
|
ORDERING_NAME_AZ = 'name'
|
||||||
|
|
||||||
CHOICES = (
|
CHOICES = (
|
||||||
(ORDERING_NEWEST, _('Newest')),
|
(ORDERING_NEWEST, _('Newest')),
|
||||||
(ORDERING_OLDEST, _('Oldest')),
|
(ORDERING_OLDEST, _('Oldest')),
|
||||||
|
(ORDERING_NAME_AZ, _('Name (A-Z)')),
|
||||||
)
|
)
|
||||||
|
|
||||||
#
|
#
|
||||||
|
@ -381,7 +381,12 @@ class BookmarksWidget(DashboardWidget):
|
|||||||
if request.user.is_anonymous:
|
if request.user.is_anonymous:
|
||||||
bookmarks = list()
|
bookmarks = list()
|
||||||
else:
|
else:
|
||||||
bookmarks = Bookmark.objects.filter(user=request.user).order_by(self.config['order_by'])
|
if self.config['order_by'] == BookmarkOrderingChoices.ORDERING_NAME_AZ:
|
||||||
|
bookmarks = sorted(Bookmark.objects.filter(user=request.user),
|
||||||
|
key=lambda bookmark: bookmark.__str__().lower()
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
bookmarks = Bookmark.objects.filter(user=request.user).order_by(self.config['order_by'])
|
||||||
if object_types := self.config.get('object_types'):
|
if object_types := self.config.get('object_types'):
|
||||||
models = get_models_from_content_types(object_types)
|
models = get_models_from_content_types(object_types)
|
||||||
conent_types = ObjectType.objects.get_for_models(*models).values()
|
conent_types = ObjectType.objects.get_for_models(*models).values()
|
||||||
|
Loading…
Reference in New Issue
Block a user