Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a simple_tag for views to render a list of values #960

Merged
merged 3 commits into from
May 17, 2024

Conversation

MyPyDavid
Copy link
Member

@MyPyDavid MyPyDavid commented Apr 5, 2024

This tag should return a readable string from a list of Values in a View template.
The default keyword arguments for this simple tag are separator sep = ',' and the second to last separator sep_last = ', and'.
The name of the tag is currently render_custom_inline_list.

For example for a list of possible values (like in a optionset) A, B, C, D it should return:

A, B, C, and D
A, B, and C
A and B
A

In the View for example:

<p> Im Projekt entstehen Daten
{% for dataset in datasets %}
    {% if forloop.last and not forloop.first %}und {% endif %}
    im Bereich <i>{{ dataset.value }}</i> durch
    {% get_set_values dataset 'project/dataset/creation_methods' as texts %}
    {% render_custom_inline_list values=texts sep=';' sep_last='und' %}
{% endfor %}
</p>

Co-authored-by: @jwindeck

Description

Related issue: #ISSUE_NUMBER

Motivation and Context

How has this been tested?

Screenshots (if appropriate)

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Documentation content changes
  • Other (please describe):

Checklist

  • I have read the contributor guide.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@MyPyDavid MyPyDavid self-assigned this Apr 5, 2024
@MyPyDavid MyPyDavid changed the base branch from main to dev-2.2.0 April 5, 2024 15:22
@Zack-83
Copy link
Member

Zack-83 commented Apr 12, 2024

addresses #964

rdmo/views/templatetags/view_tags.py Outdated Show resolved Hide resolved
rdmo/views/templatetags/view_tags.py Outdated Show resolved Hide resolved
rdmo/views/templatetags/view_tags.py Outdated Show resolved Hide resolved
@MyPyDavid MyPyDavid added this to the RDMO 2.2.0 milestone May 17, 2024
@MyPyDavid
Copy link
Member Author

thanks, looks much better with the separator_two

@jochenklar jochenklar merged commit c6a09a7 into dev-2.2.0 May 17, 2024
17 checks passed
@jochenklar jochenklar deleted the feat-views-template-tags branch May 17, 2024 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants