mirror of
				https://github.com/ae-utbm/sith.git
				synced 2025-10-31 00:53:08 +00:00 
			
		
		
		
	Rename news moderate to publish
This commit is contained in:
		| @@ -1,6 +1,6 @@ | ||||
| {% macro news_moderation_alert(news, user, alpineState = None) %} | ||||
|     {# An alert to display on top of non moderated news, | ||||
|     with actions to either moderate or delete them. | ||||
|     {# 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. | ||||
| @@ -8,7 +8,7 @@ | ||||
|  | ||||
|     This comes in three flavours : | ||||
|     - You can pass the `News` object itself to the macro. | ||||
|       In this case, if `request.user` can moderate news, | ||||
|       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 | ||||
| @@ -64,16 +64,16 @@ | ||||
|     <template x-if="state === AlertState.PENDING"> | ||||
|       <div class="alert alert-yellow"> | ||||
|         <div class="alert-main"> | ||||
|           <strong>{% trans %}Waiting moderation{% endtrans %}</strong> | ||||
|           <strong>{% trans %}Waiting publication{% endtrans %}</strong> | ||||
|           <p> | ||||
|             {% trans trimmed %} | ||||
|               This news isn't moderated and is visible | ||||
|               This news isn't published and is visible | ||||
|               only by its author and the communication admins. | ||||
|             {% endtrans %} | ||||
|           </p> | ||||
|           <p> | ||||
|             {% trans trimmed %} | ||||
|               It will stay hidden for other users until it has been moderated. | ||||
|               It will stay hidden for other users until it has been published. | ||||
|             {% endtrans %} | ||||
|           </p> | ||||
|           {% if user.has_perm("com.moderate_news") %} | ||||
| @@ -84,7 +84,7 @@ | ||||
|             <div | ||||
|               {% if news is integer or news is string %} | ||||
|                 x-data="{ nbEvents: 0 }" | ||||
|                 x-init="nbEvents = await nbToModerate()" | ||||
|                 x-init="nbEvents = await nbToPublish()" | ||||
|               {% else %} | ||||
|                 x-data="{ nbEvents: {{ news.dates.count() }} }" | ||||
|               {% endif %} | ||||
| @@ -101,8 +101,8 @@ | ||||
|         </div> | ||||
|         {% if user.has_perm("com.moderate_news") %} | ||||
|           <span class="alert-aside" :aria-busy="loading"> | ||||
|             <button class="btn btn-green" @click="moderateNews()" :disabled="loading"> | ||||
|               <i class="fa fa-check"></i> {% trans %}Moderate{% endtrans %} | ||||
|             <button class="btn btn-green" @click="publishNews()" :disabled="loading"> | ||||
|               <i class="fa fa-check"></i> {% trans %}Publish{% endtrans %} | ||||
|             </button> | ||||
|         {% endif %} | ||||
|         {% if user.has_perm("com.delete_news") %} | ||||
| @@ -113,9 +113,9 @@ | ||||
|         {% endif %} | ||||
|       </div> | ||||
|     </template> | ||||
|     <template x-if="state === AlertState.MODERATED"> | ||||
|     <template x-if="state === AlertState.PUBLISHED"> | ||||
|       <div class="alert alert-green"> | ||||
|         {% trans %}News moderated{% endtrans %} | ||||
|         {% trans %}News published{% endtrans %} | ||||
|       </div> | ||||
|     </template> | ||||
|     <template x-if="state === AlertState.DELETED"> | ||||
|   | ||||
| @@ -27,7 +27,7 @@ | ||||
|       </tr> | ||||
|     </thead> | ||||
|     <tbody> | ||||
|       {% for news in weeklies.filter(is_moderated=True) %} | ||||
|       {% for news in weeklies.filter(is_published=True) %} | ||||
|         <tr> | ||||
|           <td>{{ news.title }}</td> | ||||
|           <td>{{ news.summary|markdown }}</td> | ||||
| @@ -47,7 +47,7 @@ | ||||
|           </td> | ||||
|           <td><a href="{{ url('com:news_detail', news_id=news.id) }}">{% trans %}View{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_edit', news_id=news.id) }}">{% trans %}Edit{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_moderate', news_id=news.id) }}?remove">{% trans %}Remove{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_moderate', news_id=news.id) }}?remove">{% trans %}Unpublish{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_delete', news_id=news.id) }}">{% trans %}Delete{% endtrans %}</a> | ||||
|           </td> | ||||
|         </tr> | ||||
| @@ -67,7 +67,7 @@ | ||||
|       </tr> | ||||
|     </thead> | ||||
|     <tbody> | ||||
|       {% for news in weeklies.filter(is_moderated=False) %} | ||||
|       {% for news in weeklies.filter(is_published=False) %} | ||||
|         <tr> | ||||
|           <td>{{ news.title }}</td> | ||||
|           <td>{{ news.summary|markdown }}</td> | ||||
| @@ -86,7 +86,7 @@ | ||||
|           </td> | ||||
|           <td><a href="{{ url('com:news_detail', news_id=news.id) }}">{% trans %}View{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_edit', news_id=news.id) }}">{% trans %}Edit{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_moderate', news_id=news.id) }}">{% trans %}Moderate{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_moderate', news_id=news.id) }}">{% trans %}Publish{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_delete', news_id=news.id) }}">{% trans %}Delete{% endtrans %}</a> | ||||
|           </td> | ||||
|         </tr> | ||||
| @@ -111,7 +111,7 @@ | ||||
|       </tr> | ||||
|     </thead> | ||||
|     <tbody> | ||||
|       {% for news in events.filter(is_moderated=True) %} | ||||
|       {% for news in events.filter(is_published=True) %} | ||||
|         <tr> | ||||
|           <td>{{ news.title }}</td> | ||||
|           <td>{{ news.summary|markdown }}</td> | ||||
| @@ -124,7 +124,7 @@ | ||||
|             {{ news.dates.all()[0].end_date|localtime|time(DATETIME_FORMAT) }}</td> | ||||
|           <td><a href="{{ url('com:news_detail', news_id=news.id) }}">{% trans %}View{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_edit', news_id=news.id) }}">{% trans %}Edit{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_moderate', news_id=news.id) }}?remove">{% trans %}Remove{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_moderate', news_id=news.id) }}?remove">{% trans %}Unpublish{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_delete', news_id=news.id) }}">{% trans %}Delete{% endtrans %}</a> | ||||
|           </td> | ||||
|         </tr> | ||||
| @@ -145,7 +145,7 @@ | ||||
|       </tr> | ||||
|     </thead> | ||||
|     <tbody> | ||||
|       {% for news in events.filter(is_moderated=False) %} | ||||
|       {% for news in events.filter(is_published=False) %} | ||||
|         <tr> | ||||
|           <td>{{ news.title }}</td> | ||||
|           <td>{{ news.summary|markdown }}</td> | ||||
| @@ -157,7 +157,7 @@ | ||||
|             {{ news.dates.all()[0].end_date|localtime|time(DATETIME_FORMAT) }}</td> | ||||
|           <td><a href="{{ url('com:news_detail', news_id=news.id) }}">{% trans %}View{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_edit', news_id=news.id) }}">{% trans %}Edit{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_moderate', news_id=news.id) }}">{% trans %}Moderate{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_moderate', news_id=news.id) }}">{% trans %}Publish{% endtrans %}</a> | ||||
|             <a href="{{ url('com:news_delete', news_id=news.id) }}">{% trans %}Delete{% endtrans %}</a> | ||||
|           </td> | ||||
|         </tr> | ||||
|   | ||||
| @@ -25,7 +25,7 @@ | ||||
|   <p><a href="{{ url('com:news_list') }}">{% trans %}Back to news{% endtrans %}</a></p> | ||||
|   <div x-data="{newsState: AlertState.PENDING}"> | ||||
|  | ||||
|     {% if not news.is_moderated %} | ||||
|     {% if not news.is_published %} | ||||
|       {{ news_moderation_alert(news, user, "newsState") }} | ||||
|     {% endif %} | ||||
|     <article id="news_details" x-show="newsState !== AlertState.DELETED"> | ||||
| @@ -51,7 +51,7 @@ | ||||
|           {% if news.moderator %} | ||||
|             <p>{% trans %}Moderator: {% endtrans %}{{ user_profile_link(news.moderator) }}</p> | ||||
|           {% elif user.is_com_admin %} | ||||
|             <p> <a href="{{ url('com:news_moderate', news_id=news.id) }}">{% trans %}Moderate{% endtrans %}</a></p> | ||||
|             <p> <a href="{{ url('com:news_moderate', news_id=news.id) }}">{% trans %}Publish{% endtrans %}</a></p> | ||||
|           {% endif %} | ||||
|           {% if user.can_edit(news) %} | ||||
|             <p> <a href="{{ url('com:news_edit', news_id=news.id) }}">{% trans %}Edit (will be moderated again){% endtrans %}</a></p> | ||||
|   | ||||
| @@ -80,9 +80,9 @@ | ||||
|     </fieldset> | ||||
|     {% if user.is_root or user.is_com_admin %} | ||||
|       <fieldset> | ||||
|         {{ form.auto_moderate.errors }} | ||||
|         {{ form.auto_moderate }} | ||||
|         {{ form.auto_moderate.label_tag() }} | ||||
|         {{ form.auto_publish.errors }} | ||||
|         {{ form.auto_publish }} | ||||
|         {{ form.auto_publish.label_tag() }} | ||||
|       </fieldset> | ||||
|     {% endif %} | ||||
|     <p><input type="submit" value="{% trans %}Save{% endtrans %}" class="btn btn-blue"/></p> | ||||
|   | ||||
| @@ -57,17 +57,17 @@ | ||||
|                 {% for date in dates_group %} | ||||
|                   <article | ||||
|                     class="news_event" | ||||
|                     {%- if not date.news.is_moderated -%} | ||||
|                     {%- if not date.news.is_published -%} | ||||
|                       x-data="{newsState: AlertState.PENDING}" | ||||
|                     {%- endif -%} | ||||
|                   > | ||||
|                     {% if not date.news.is_moderated %} | ||||
|                       {# if a non moderated news is in the object list, | ||||
|                     {% if not date.news.is_published %} | ||||
|                       {# if a non published news is in the object list, | ||||
|                       the logged user is either an admin or the news author #} | ||||
|                       {{ news_moderation_alert(date.news, user, "newsState") }} | ||||
|                     {% endif %} | ||||
|                     <div | ||||
|                       {% if not date.news.is_moderated -%} | ||||
|                       {% if not date.news.is_published -%} | ||||
|                         x-show="newsState !== AlertState.DELETED" | ||||
|                       {%- endif -%} | ||||
|                     > | ||||
| @@ -120,9 +120,9 @@ | ||||
|                   <template x-for="newsDate in newsList" :key="newsDate.id"> | ||||
|                     <article | ||||
|                       class="news_event" | ||||
|                       x-data="{ newsState: newsDate.news.is_moderated ? AlertState.MODERATED : AlertState.PENDING }" | ||||
|                       x-data="{ newsState: newsDate.news.is_published ? AlertState.PULISHED : AlertState.PENDING }" | ||||
|                     > | ||||
|                       <template x-if="!newsDate.news.is_moderated"> | ||||
|                       <template x-if="!newsDate.news.is_published"> | ||||
|                         {{ news_moderation_alert("newsDate.news.id", user, "newsState") }} | ||||
|                       </template> | ||||
|                       <div x-show="newsState !== AlertState.DELETED"> | ||||
| @@ -183,15 +183,15 @@ | ||||
|         x-data | ||||
|         x-ref="calendar" | ||||
|         @news-moderated.window=" | ||||
|                                 if ($event.target !== $refs.calendar){ | ||||
|                                 // Avoid triggering a refresh with a dispatch | ||||
|                                 // from the calendar itself | ||||
|                                 if ($event.target !== $refs.calendar){ | ||||
|                                 $refs.calendar.refreshEvents($event); | ||||
|                                 } | ||||
|                                " | ||||
|         @calendar-remove="$dispatch('news-moderated', {newsId: $event.detail.id, state: AlertState.PENDING})" | ||||
|         @calendar-delete="$dispatch('news-moderated', {newsId: $event.detail.id, state: AlertState.DELETED})" | ||||
|         @calendar-moderate="$dispatch('news-moderated', {newsId: $event.detail.id, state: AlertState.MODERATED})" | ||||
|         @calendar-remove="$dispatch('news-moderated', {newsId: $event.detail.id, state: AlertState.DELETED})" | ||||
|         @calendar-unpublish="$dispatch('news-moderated', {newsId: $event.detail.id, state: AlertState.PENDING})" | ||||
|         @calendar-publish="$dispatch('news-moderated', {newsId: $event.detail.id, state: AlertState.PUBLISHED})" | ||||
|         locale="{{ get_language() }}" | ||||
|         can_moderate="{{ user.has_perm("com.moderate_news") }}" | ||||
|         can_delete="{{ user.has_perm("com.delete_news") }}" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user