Skip to content

Commit

Permalink
WIP refacto content.html et content_online.html
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud-D committed Dec 27, 2022
1 parent 4d8e28a commit 5a1f5d3
Show file tree
Hide file tree
Showing 4 changed files with 135 additions and 132 deletions.
79 changes: 79 additions & 0 deletions templates/tutorialv2/includes/comments.part.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{% load captureas %}
{% load set %}
{% load i18n %}
{% load pluralize_fr %}

<h3 class="comments-title" id="comments">
{% if content.get_note_count > 0 %}
<span itemprop="commentCount">
{{ content.get_note_count }}
</span>
{% trans "commentaire" %}{{ content.get_note_count|pluralize_fr }}
{% else %}
{% trans "Aucun commentaire" %}
{% endif %}
</h3>

{% include "misc/paginator.html" with position="top" topic=content is_online=True anchor="comments" %}

{% set perms.tutorialv2.change_contentreaction as is_staff %}

{% for message in reactions %}

{% captureas edit_link %}
{% url "content:update-reaction" %}?message={{ message.pk }}&amp;pk={{ content.pk }}
{% endcaptureas %}

{% captureas cite_link %}
{% url "content:add-reaction" %}?cite={{ message.pk }}&amp;pk={{ content.pk }}
{% endcaptureas %}

{% captureas karma_link %}
{% url "api:content:reaction-karma" message.pk %}
{% endcaptureas %}

{% captureas alerts_solve_link %}
{% url "content:resolve-reaction" %}
{% endcaptureas %}
{% captureas alert_link %}
{% url "content:alert-reaction" message.pk %}
{% endcaptureas %}
{% captureas hide_link %}
{% url "content:hide-reaction" message.pk%}
{% endcaptureas %}

{% captureas show_link %}
{% url "content:show-reaction" message.pk %}
{% endcaptureas %}

{% if forloop.first and page_obj.number > 1 %}
{% set True as is_repeated_message %}
{% else %}
{% set False as is_repeated_message %}
{% endif %}

{% if user == message.author or is_staff %}
{% set True as can_view_history %}
{% else %}
{% set False as can_view_history %}
{% endif %}

{% include "misc/message.part.html" with perms_change=is_staff topic=object %}
{% endfor %}


{% include "misc/paginator.html" with position="bottom" topic=content is_online=True anchor="comments" %}



{% captureas form_action %}
{% url 'content:add-reaction' %}?pk={{ content.pk }}
{% endcaptureas %}

{% if object.last_note %}
{% captureas last_note_pk %}
{{ object.last_note.pk }}
{% endcaptureas %}
{% endif %}

{% include "misc/message_form.html" with member=user topic=content is_antispam=is_antispam %}
104 changes: 53 additions & 51 deletions templates/tutorialv2/includes/editorialization.part.html
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
{% load i18n %}
{% load crispy_forms_tags %}

<h3>Éditorialisation</h3>
<ul>
<li>
<a href="#edit-tags" class="open-modal ico-after gear blue">
{% trans "Modifier les tags" %}
</a>
{% crispy form_edit_tags %}
</li>

{% if is_staff %}
<div class="mobile-menu-bloc mobile-all-links mobile-show-ico" data-title="Éditorialisation">
<h3>Éditorialisation</h3>
<ul>
<li>
<a href="#edit-goals" class="open-modal ico-after gear blue">
{% trans "Modifier les objectifs" %}
<a href="#edit-tags" class="open-modal ico-after gear blue">
{% trans "Modifier les tags" %}
</a>
{% crispy form_edit_goals %}
{% crispy form_edit_tags %}
</li>
{% endif %}

{% if is_staff and not content.is_opinion %}
<li>
<a href="#add-suggestion" class="open-modal ico-after more blue">
{% trans "Ajouter une suggestion" %}
</a>
{% crispy formAddSuggestion %}
</li>
<li>
<a href="#manage-suggestion" class="open-modal ico-after gear blue">
{% trans "Gérer les suggestions" %}
</a>
<form action="{% url "content:remove-suggestion" content.pk %}" method="post" class="modal modal-large" id="manage-suggestion" data-modal-close="Fermer">
<table class="fullwidth">
<thead>
<th>{% trans "Contenus suggérés" %}</th>
<th width="15%">{% trans "Actions" %}</th>
</thead>
<tbody>
{% for content_suggestion in content_suggestions %}
<tr>
<td>{{content_suggestion.suggestion.title}}</td>
<td>
<button type="submit" data-value="{{ content_suggestion.pk }}" name="pk_suggestion" value="{{ content_suggestion.pk }}" class="modal-inner">
{% trans "Supprimer" %}
</button>
</td>
</tr>
{% empty %}
<tr><td colspan="2">Aucune suggestion de contenu.</td></tr>
{% endfor %}
</tbody>
</table>
{% csrf_token %}
</form>
</li>
{% endif %}
</ul>
{% if is_staff %}
<li>
<a href="#edit-goals" class="open-modal ico-after gear blue">
{% trans "Modifier les objectifs" %}
</a>
{% crispy form_edit_goals %}
</li>
{% endif %}

{% if is_staff and not content.is_opinion %}
<li>
<a href="#add-suggestion" class="open-modal ico-after more blue">
{% trans "Ajouter une suggestion" %}
</a>
{% crispy formAddSuggestion %}
</li>
<li>
<a href="#manage-suggestion" class="open-modal ico-after gear blue">
{% trans "Gérer les suggestions" %}
</a>
<form action="{% url "content:remove-suggestion" content.pk %}" method="post" class="modal modal-large" id="manage-suggestion" data-modal-close="Fermer">
<table class="fullwidth">
<thead>
<th>{% trans "Contenus suggérés" %}</th>
<th width="15%">{% trans "Actions" %}</th>
</thead>
<tbody>
{% for content_suggestion in content_suggestions %}
<tr>
<td>{{content_suggestion.suggestion.title}}</td>
<td>
<button type="submit" data-value="{{ content_suggestion.pk }}" name="pk_suggestion" value="{{ content_suggestion.pk }}" class="modal-inner">
{% trans "Supprimer" %}
</button>
</td>
</tr>
{% empty %}
<tr><td colspan="2">Aucune suggestion de contenu.</td></tr>
{% endfor %}
</tbody>
</table>
{% csrf_token %}
</form>
</li>
{% endif %}
</ul>
</div>
4 changes: 1 addition & 3 deletions templates/tutorialv2/view/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -743,9 +743,7 @@ <h3>{{ content.is_opinion|yesno:_("Modération,Validation") }}</h3>
{% endif %}

{% if is_staff or can_edit %}
<div class="mobile-menu-bloc mobile-all-links mobile-show-ico" data-title="Éditorialisation">
{% include "tutorialv2/includes/editorialization.part.html" %}
</div>
{% include "tutorialv2/includes/editorialization.part.html" %}
{% endif %}

{% if can_edit and not content.is_opinion %}
Expand Down
80 changes: 2 additions & 78 deletions templates/tutorialv2/view/content_online.html
Original file line number Diff line number Diff line change
Expand Up @@ -348,88 +348,12 @@ <h3>{% blocktrans %}Admin<span class="wide">istration</span>{% endblocktrans %}<
</div>
{% endif %}
{% if is_staff or is_author %}
<div class="mobile-menu-bloc mobile-all-links mobile-show-ico" data-title="Éditorialisation">
{% include "tutorialv2/includes/editorialization.part.html" %}
</div>
{% include "tutorialv2/includes/editorialization.part.html" %}
{% endif %}
{% include "misc/social_buttons.part.html" with link=content.get_absolute_url_online text=content.title %}
{% endblock %}

{% block content_after %}
{% include "tutorialv2/includes/content_suggestion.part.html" with content=content content_suggestions=content_suggestions_random %}
<h3 class="comments-title" id="comments">
{% if content.get_note_count > 0 %}
<span itemprop="commentCount">
{{ content.get_note_count }}
</span>
{% trans "commentaire" %}{{ content.get_note_count|pluralize_fr }}
{% else %}
{% trans "Aucun commentaire" %}
{% endif %}
</h3>


{% include "misc/paginator.html" with position="top" topic=content is_online=True anchor="comments" %}

{% set perms.tutorialv2.change_contentreaction as is_staff %}

{% for message in reactions %}

{% captureas edit_link %}
{% url "content:update-reaction" %}?message={{ message.pk }}&amp;pk={{ content.pk }}
{% endcaptureas %}

{% captureas cite_link %}
{% url "content:add-reaction" %}?cite={{ message.pk }}&amp;pk={{ content.pk }}
{% endcaptureas %}

{% captureas karma_link %}
{% url "api:content:reaction-karma" message.pk %}
{% endcaptureas %}

{% captureas alerts_solve_link %}
{% url "content:resolve-reaction" %}
{% endcaptureas %}
{% captureas alert_link %}
{% url "content:alert-reaction" message.pk %}
{% endcaptureas %}
{% captureas hide_link %}
{% url "content:hide-reaction" message.pk%}
{% endcaptureas %}

{% captureas show_link %}
{% url "content:show-reaction" message.pk %}
{% endcaptureas %}

{% if forloop.first and page_obj.number > 1 %}
{% set True as is_repeated_message %}
{% else %}
{% set False as is_repeated_message %}
{% endif %}

{% if user == message.author or is_staff %}
{% set True as can_view_history %}
{% else %}
{% set False as can_view_history %}
{% endif %}

{% include "misc/message.part.html" with perms_change=is_staff topic=object %}
{% endfor %}


{% include "misc/paginator.html" with position="bottom" topic=content is_online=True anchor="comments" %}



{% captureas form_action %}
{% url 'content:add-reaction' %}?pk={{ content.pk }}
{% endcaptureas %}

{% if object.last_note %}
{% captureas last_note_pk %}
{{ object.last_note.pk }}
{% endcaptureas %}
{% endif %}

{% include "misc/message_form.html" with member=user topic=content is_antispam=is_antispam %}
{% include "tutorialv2/includes/comments.part.html" with content=content reactions=reactions %}
{% endblock %}

0 comments on commit 5a1f5d3

Please sign in to comment.