Allow site-level control of how Resources ordered within an Allocation #335
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
See #334
This modifies the methods get_resources_as_string() and get_parent_resource() of the Allocation class, specifically it modifies how those routines order the resources attached to the allocation for display, etc.
The modifications cause both of these methods to order the resources by
the value of the setting ALLOCATION_RESOURCE_ORDERING. This should be a
list ref of arguments to pass to the Django QuerySet order_by() method. The
default value is [ '-is_allocatable', 'name' ], which means that Resources
which are allocatable (is_allocatable==Yes) will come before non-allocatable
resources, and among Resources of the same allocatability, the Resources will
be ordered by name.
This should result in get_parent_resource returning the same resource as
before (as it previously used the default 'name' ordering from Resource and
then filtered/selected only allocatable Resources when the Allocation was
associated with more than one Resource); except in the abnormal case wherein
an Allocation has more than one Resource and none are allocatable (the old
behavior returned None, which could result in various issues; the new behavior
is to return one of the non-allocatable Resources).
The result of get_resources_as_string may change, as previously it only
ordered by '-is_allocatable', so the ordering of allocatable resources is
presumably up to the database backend (???). The new behavior is consistent
with get_parent_resource(), i.e. the Resource returned by get_parent_resource()
will now always be the first Resource listed in get_resources_as_string().
Added documentation for ALLOCATION_RESOURCE_ORDERING under config page.