{# Data groups on the library pages. Import `with context`: both macros read `several_groups`, `data_groups`, `group_names` and `may_move_groups`, which `api/library.py:_groups` puts on every library page. Nothing here appears on an instance with one group, so a library that never uses groups looks exactly as it always did. #} {# Which group a row is in, as a badge. Only when there is a choice to see. #} {% macro group_chip(row) -%} {%- if several_groups -%} {{ group_names.get(row.data_group_id or 'default', '') }} {%- endif -%} {%- endmacro %} {# The group a new record goes into, or the one an existing record is in. A new record may go into any group this person can use: it is theirs, and choosing where it lives is choosing which providers may read it. Moving one that exists is `data.manage`, because that changes what a provider has already been able to see. Every slot is emitted even when one is empty, so a field row lines up by construction. #} {% macro group_field(row=None, chosen="") -%} {%- if several_groups -%} {%- set current = (row.data_group_id if row else chosen) or "default" -%}
{%- if not row -%} {{ t("Only models whose connection is in this group can read it.") }} {%- elif may_move_groups -%} {{ t("Moving it hands it to the other group's models, and takes it away from this group's.") }} {%- else -%} {{ t("Only models whose connection is in this group can read it. Moving records between groups needs the permission to manage your own data groups.") }} {%- endif -%}