byceps/byceps

View on GitHub
byceps/blueprints/site/board/templates/site/board/_posting_view_actions.html

Summary

Maintainability
Test Coverage
{%- from 'macros/icons.html' import render_icon %}


{%- set is_initial_topic_posting = posting.is_initial_topic_posting() %}

{%- set user_may_reply = (not topic.locked and has_current_user_permission('board_posting.create')) %}
{%- set user_may_update = (may_topic_be_updated_by_current_user(topic) if is_initial_topic_posting else may_posting_be_updated_by_current_user(posting)) %}
{%- set user_may_hide = has_current_user_permission('board.hide') %}

      {%- if user_may_reply or user_may_update or user_may_hide %}
      <div class="user-comment-actions">
        <div class="dropdown">
          <button class="dropdown-toggle" title="{{ _('Actions') }}">{{ render_icon('user-comment') }} {{ render_icon('chevron-down') }}</button>
          <ol class="dropdown-menu dropdown-menu--right">
            {%- if user_may_reply %}
            <li><a class="dropdown-item" href="{{ url_for('.posting_create_form', topic_id=topic.id, quote=posting.id) }}" title="{{ _('Cite this post') }}">{{ render_icon('quote') }} {{ _('Cite post') }}</a></li>
            {%- endif %}

            {%- if user_may_update %}
              {%- if is_initial_topic_posting %}
            <li><a class="dropdown-item" href="{{ url_for('.topic_update_form', topic_id=topic.id) }}" title="{{ _('Edit this topic') }}">{{ render_icon('edit') }} {{ _('Edit topic') }}</a></li>
              {%- else %}
            <li><a class="dropdown-item" href="{{ url_for('.posting_update_form', posting_id=posting.id) }}" title="{{ _('Edit this post') }}">{{ render_icon('edit') }} {{ _('Edit post') }}</a></li>
              {%- endif %}
            {%- endif %}

            {%- if user_may_hide %}
            <li><a class="dropdown-item" href="{{ url_for('.posting_moderate_form', posting_id=posting.id) }}" title="{{ _('Moderate this post') }}">{{ render_icon('moderate') }} {{ _('Moderate') }}</a></li>
            {%- endif %}
          </ol>
        </div>
      </div>
      {%- endif %}