{% macro news_moderation_alert(news, user, alpineState = None) %} {# An alert to display on top of unpublished news, with actions to either publish or delete them. The current state of the alert is accessible through the given `alpineState` variable. This state is a `AlertState`, as defined in `moderation-alert-index.ts` This comes in three flavours : - You can pass the `News` object itself to the macro. In this case, if `request.user` can publish news, it will perform an additional db query to know if it is a recurring event. - You can also give only the news id. In this case, a server request will be issued to know if it is a recurring event. - Finally, you can pass the name of an alpine variable, which value is the id. In this case, a server request will be issued to know if it is a recurring event. Example with full `News` object : ```jinja
{% trans trimmed %} This news isn't published and is visible only by its author and the communication admins. {% endtrans %}
{% trans trimmed %} It will stay hidden for other users until it has been published. {% endtrans %}
{% if user.has_perm("com.moderate_news") %} {# This is an additional query for each non-moderated news, but it will be executed only for admin users, and only one time (if they do their job and moderated news as soon as they see them), so it's still reasonable #}