{% import "macros.html" as macros %}
<div class="sidebar-box js-group-settings" data-object-id="{{group.id}}" data-model-name="Group">
  <h2>
    {% if request.user.is_authenticated and request.user.is_administrator() %}
      {% trans %}Group settings{% endtrans %}
    {% else %}
      {% trans %}Group info{% endtrans %}
    {% endif %}
  </h2>

  <div class="row">
    <img class="js-group-logo"
      {% if group.logo_url %}
        src="{{ group.logo_url }}"
      {% else %}
        style="display:none"
      {% endif %}
    />
  </div>

  <div class="js-description">
    {% if group.description %}
      {{ group.description.html }}
    {% endif %}
  </div>

  <div class="row">
    {{ macros.group_join_button(
        group_id = group.id,
        acceptance_level = user_acceptance_level,
        membership_level = user_membership_level
      )
    }}
  </div>

  {% if request.user.is_authenticated and request.user.is_administrator() %}
  <div class="controls">
    <div class="row">
      <a class="js-edit-description-btn"
      >{% trans %}edit description{% endtrans %}</a>
      {% if group.logo_url %}
        <span class="js-logo-control">|</span>
        <a class="js-change-logo-btn js-logo-control"
        >{% trans %}change logo{% endtrans %}</a>
        <span class="js-logo-control">|</span>
        <a class="js-delete-logo-btn js-logo-control">{% trans %}delete logo{% endtrans %}</a>
      {% else %}
        <span class="js-logo-control">|</span>
        <a class="js-change-logo-btn js-logo-control"
        >{% trans %}add logo{% endtrans %}</a>
      {% endif %}
    </div>

    {% if group_email_moderation_enabled %}
    <div class="row with-checkbox">
      <input type="checkbox"
        id="moderate-email"
        class="js-moderate-email-toggle"
        {% if group.moderate_email %}checked="checked"{% endif %}
        data-toggle-url="{{ url('toggle_group_profile_property') }}"
      />
      <label for="moderate-email">
        {% trans %}moderate emailed content{% endtrans %}
      </label>
    </div>
    {% endif %}

    <div class="row">
      <label for="group-openness-selector">
        {% trans %}How users join this group?{% endtrans %}
      </label>
      <select
        id="group-openness-selector"
        class="js-group-openness-selector"
        data-url="{{ url('set_group_openness') }}"
      >
        {% for choice in group_openness_choices %}
        <option
          {% if choice[0] == group.openness %}
          selected="selected"
          {% endif %}
          value="{{choice[0]}}"
        >{{ choice[1] }}</option>
        {% endfor %}
      </select>
    </div>

    <div class="row with-checkbox">
      <input
        type="checkbox"
        id="read-only-access-toggle"
        class="js-read-only-access-toggle"
        {% if group.read_only %}checked="checked"{% endif %}
        data-toggle-url="{{ url('toggle_group_profile_property') }}"
      />
      <label for="read-only-access-toggle">
        {% trans %}Read only access{% endtrans %}
      </label>
    </div>

    <div class="row with-checkbox">
      <input
        type="checkbox"
        id="can-post-questions-toggle"
        class="js-can-post-questions-toggle"
        {% if group.can_post_questions %}checked="checked"{% endif %}
        data-toggle-url="{{ url('toggle_group_profile_property') }}"
      />
      <label for="can-post-questions-toggle">
        {% trans %}Can post questions{% endtrans %}
      </label>
    </div>

    <div class="row with-checkbox">
      <input
        type="checkbox"
        id="can-post-answers-toggle"
        class="js-can-post-answers-toggle"
        {% if group.can_post_answers %}checked="checked"{% endif %}
        data-toggle-url="{{ url('toggle_group_profile_property') }}"
      />
      <label for="can-post-answers-toggle">
        {% trans %}Can post answers{% endtrans %}
      </label>
    </div>

    <div class="row with-checkbox">
      <input
        type="checkbox"
        id="can-post-comments-toggle"
        class="js-can-post-comments-toggle"
        {% if group.can_post_comments %}checked="checked"{% endif %}
        data-toggle-url="{{ url('toggle_group_profile_property') }}"
      />
      <label for="can-post-comments-toggle">
        {% trans %}Can post comments{% endtrans %}
      </label>
    </div>

    {% if settings.ATTACHMENT_UPLOADS_ENABLED %}
      <div class="row with-checkbox">
        <input
          type="checkbox"
          id="can-upload-attachments-toggle"
          class="js-can-upload-attachments-toggle"
          {% if group.can_upload_attachments %}checked="checked"{% endif %}
          data-toggle-url="{{ url('toggle_group_profile_property') }}"
        />
        <label for="can-upload-attachments-toggle">
          {% trans %}Can upload file attachments{% endtrans %}
        </label>
      </div>
    {% endif %}

    {% if settings.IMAGE_UPLOADS_ENABLED %}
      <div class="row with-checkbox">
        <input
          type="checkbox"
          id="can-upload-images-toggle"
          class="js-can-upload-images-toggle"
          {% if group.can_upload_images %}checked="checked"{% endif %}
          data-toggle-url="{{ url('toggle_group_profile_property') }}"
        />
        <label for="can-upload-images-toggle">
          {% trans %}Can upload images{% endtrans %}
        </label>
      </div>
    {% endif %}

    <div class="row">
      <a
        id="preapproved-emails"
        class="js-preapproved-emails"
        data-object-id="{{group.group_ptr_id}}"
        data-model-name="Group"
        data-property-name="preapproved_emails"
        data-url="{{ url('edit_object_property_text') }}"
        data-editor-heading="{% trans %}List of preapproved email addresses{% endtrans %}"
        data-help-text="{% trans %}Users with these email adderesses will be added to the group automatically.{% endtrans %}"
      >{% trans %}edit preapproved emails{% endtrans %}</a>
    </div>

    <div class="row">
      <a
        id="preapproved-email-domains"
        class="js-preapproved-email-domains"
        data-object-id="{{group.group_ptr_id}}"
        data-model-name="Group"
        data-property-name="preapproved_email_domains"
        data-url="{{ url('edit_object_property_text') }}"
        data-editor-heading="{% trans %}List of preapproved email domain names{% endtrans %}"
        data-help-text="{% trans %}Users whose email adderesses belong to these domains will be added to the group automatically.{% endtrans %}"
      >{% trans %}edit preapproved email domains{% endtrans %}</a>
    </div>

  </div>
  {% endif %}
</div>
