{#
  Embeds a organization within the sidebar of a page.

  organization    - The organization dict.

  {% snippet 'snippets/organization, organization=group_dict %}

  #}
{% set organization = organization or group%}
{% set url = h.url_for(organization.type + '.read', id=organization.name, ) %}
{% set dataset_type = h.default_package_type() %}

{% block info %}
  <section id="organization-info" class="module module-narrow module-shallow">
    <div class="module context-info">
      <div class="module-content">
        {% block inner %}
          <div class="image-container">
          {% block image %}
            <div class="image">
              <a href="{{ url }}">
                <img src="{{ organization.image_display_url or h.url_for_static('/base/images/placeholder-organization.svg') }}" width="200" alt="{{ organization.name }}" />
              </a>
            </div>
          {% endblock %}
          <div class="heading-container">
          {% block heading %}
          <span class="heading">{{ organization.title or organization.name }}
            {% if organization.state == 'deleted' %}
              [{{ _('Deleted') }}]
            {% endif %}
          </span>
          {% endblock %}
          {% block description %}
          {% if organization.description %}
            <p class="description">
              {{ h.markdown_extract(organization.description, 180) }}
            </p>
            <p class="read-more">
              {% link_for _('read more'), named_route=organization.type ~ '.about', id=organization.name %}
            </p>
          {% else %}
            <p class="empty">{{ h.humanize_entity_type('organization', organization.type, 'no description') or _('There is no description for this organization') }}</p>
          {% endif %}
          {% endblock %}
          </div>
        </div>
        {% if show_nums %}
          {% block nums %}
          {% set num_followers = h.follow_count('group', organization.id) %}
          <div class="nums">
            <dl>
              <dt>{{ _('Followers') }}</dt>
              <dd>{{ h.SI_number_span(num_followers) }}</dd>
            </dl>
            <dl>
              <dt>{{ h.humanize_entity_type('package', dataset_type, 'facet label') or _('Datasets') }}</dt>
              <dd>{{ h.SI_number_span(organization.package_count) }}</dd>
            </dl>
            <dl>
              <dt>{{ _('Members') }}</dt>
              <dd>{{ h.member_count(organization.id) }}</dd>
            </dl>
          </div>
          {% endblock %}
          {% block follow %}
          {% if current_user.is_authenticated %}
            {% if error_message %}
              <div class="alert alert-danger">{{ error_message }}</div>
            {% elif am_following %}
              <a class="btn btn-danger" hx-post="{{ h.url_for('organization.unfollow', id=organization.id) }}" hx-target="#organization-info"><i class="fa-solid fa-circle-minus"></i> Unfollow</a>
            {% else %}
              <a class="btn btn-success" hx-post="{{ h.url_for('organization.follow', id=organization.id) }}" hx-target="#organization-info"><i class="fa-solid fa-circle-plus"></i> Follow</a>
            {% endif %}
          {% endif %}
          {% endblock %}
        {% endif %}
        {% endblock %}
      </div>
    </div>
  </section>
  {% endblock %}
