rdmorganiser / rdmorganiser/rdmo
Within Django views, implement conditions with "vectorized" variables
Open
@Zack-83 is already working on this.
Since May 30, 2024.
type:bug
- Dominant language
- Python
- Stars
- 133
- Forks
- 60
- Avg merge
- 3d 14h
- Merged PRs (30d)
- 21
Description
Description / Beschreibung
The Django-language allows defining conditions based on variables's values or on variables being empty.
That does not work for variables which can accept a vector of values.
Expected behaviour / Erwartetes Verhalten
A syntaxe such as {% if var %} or {% if var.is_not.empty %} or {% if var|length > 0 %} should work correctly even if var is allowed to be a collection.
These conditions should be evaluated as False if the variable is empty and as True if the variable has 1,2,3,... components.
Steps to reproduce / Schritte zum Reproduzieren
{% load view_tags %}
{% get_set 'project/dataset/id' as datasets %}
{% get_set 'project/partner/id' as partners %}
{% get_set 'project/funder/id' as funders %}
{% for dataset in datasets %}
{% get_set_value dataset 'project/dataset/preservation/repository_arrangements' as repository_arrangements %}
<p><i>Dataset {{ dataset.value }}:</i>
{% if repository_arrangements %}
Number of arrangements: {{ repository_arrangements|length }}
{% else %}
Empty List
{% endif %}
</p>
<p>{{ repository_arrangements }}</p>
{% endfor %}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.