Skip to content

Commit

Permalink
WIP Partage par lien
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud-D committed Feb 24, 2024
1 parent 726ada0 commit 9ce0191
Show file tree
Hide file tree
Showing 13 changed files with 1,078 additions and 0 deletions.
63 changes: 63 additions & 0 deletions templates/tutorialv2/includes/shared_content_child.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{% load emarkdown %}
{% load i18n %}
{% load times %}
{% load target_tree %}

{% if not hide_title %}
<h2 id="{{ child.position_in_parent }}-{{ child.slug }}">
<a href="{{ child.get_relative_url }}">
{{ child.title }}
</a>
</h2>
{% endif %}
{% if child.text %}
{# child is an extract #}
{% if child.get_text.strip|length == 0 %}
<p class="ico-after warning">
{% trans "Cette section est actuellement vide." %}
</p>
{% else %}
<div class="extract-wrapper">
{{ child.get_text|emarkdown }}
</div>
{% endif %}
{% else %}
{# child is a container #}

{% if child.has_extracts %}
<ol>
{% for extract in child.children %}
<li>
<a href="{{ extract.container.get_relative_url }}#{{ extract.position_in_parent }}-{{ extract.slug }}">{{ extract.title }}</a>
</li>
{% endfor %}
</ol>
{% elif child.has_sub_containers %}
<ol class="summary-part">
{% for subchild in child.children %}
<li>
<h3>
<a
href="{{ subchild.get_relative_url }}"

>{{ subchild.title }}</a>
</h3>
<ol class="summary-part">
{% for extract in subchild.children %}
<li>
<h4>
<a href="{{ extract.container.get_relative_url }}#{{ extract.position_in_parent }}-{{ extract.slug }}">{{ extract.title }}</a>
</h4>
</li>
{% endfor %}
</ol>
</li>
{% endfor %}
</ol>
{% endif %}
{% endif %}


{% if not child.has_sub_containers %}
</li>
{% endif %}
106 changes: 106 additions & 0 deletions templates/tutorialv2/view/list_shareable_links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{% extends "tutorialv2/base.html" %}
{% load i18n %}

{% block content %}

<h1>{% blocktrans %} Liens de partage pour « {{ content }} » {% endblocktrans %}</h1>

<p>{% trans "Diffusez votre contenu en partageant un simple lien accessible sans incription sur le site." %}</p>

<p>{% trans "Les liens de partages offrent les fonctionnalités suivantes :" %}</p>

{% blocktrans %}
<ul>
<li>partage de la dernière bêta ou du dernier brouillon ;</li>
<li>validité temporaire ou permanente ;</li>
<li>désactivation et réactivation à volonté.</li>
</ul>
{% endblocktrans %}

<a href="#create-shareable-link" class="open-modal">
{% trans "Créer un lien de partage" %}
</a>

<form
action="{% url 'content:create-shareable-link' content.pk %}"
method="post"
id="create-shareable-link"
class="modal modal-flex">
{% csrf_token %}
{{ create_form.as_p }}
<button type="submit" class="btn-submit">{% trans "Créer" %}</button>
</form>



<h2>{% trans "Liens actifs" %}</h2>

<p>
{% blocktrans %}
Les personnes disposant d'un lien actif peuvent l'utiliser pour lire le contenu.
Il est possible de désactiver un lien temporairement pour en interdire son usage, et le réactiver plus tard.
{% endblocktrans %}
</p>

{% if not active_links_and_forms %}

<p>{% trans "Vous n'avez pas de liens de partage actifs." %}</p>

{% else %}

<ul>
{% for link, edit_form in active_links_and_forms reversed %}
{% include 'tutorialv2/view/list_shareable_links.part.html' with link=link edit_form=edit_form content=content section="active" %}
{% endfor %}
</ul>

{% endif %}


<h2>{% trans "Liens expirés" %}</h2>

<p>
{% blocktrans %}
Un lien de partage expiré ne permet pas de lire le contenu.
Si un lien est expiré, vous pouvez modifier sa date d'expiration pour qu'il fonctionne de nouveau.
{% endblocktrans %}
</p>

{% if not expired_links_and_forms %}

<p>{% trans "Vous n'avez pas de liens de partage expirés." %}</p>

{% else %}

<ul>
{% for link, edit_form in expired_links_and_forms reversed %}
{% include 'tutorialv2/view/list_shareable_links.part.html' with link=link edit_form=edit_form content=content section="expired" %}
{% endfor %}
</ul>

{% endif %}

<h2>{% trans "Liens inactifs" %}</h2>

<p>
{% blocktrans %}
Un lien de partage inactif ne permet pas de lire le contenu.
Vous pouvez le réactiver quand vous le souhaitez pour autoriser de nouveau son usage.
{% endblocktrans %}
</p>

{% if not inactive_links_and_forms %}

<p>{% trans "Vous n'avez pas de liens de partage inactifs." %}</p>

{% else %}

<ul>
{% for link, edit_form in inactive_links_and_forms reversed %}
{% include 'tutorialv2/view/list_shareable_links.part.html' with link=link edit_form=edit_form content=content section="inactive" %}
{% endfor %}
</ul>

{% endif %}

{% endblock %}
76 changes: 76 additions & 0 deletions templates/tutorialv2/view/list_shareable_links.part.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{% load i18n %}

<li class="shareable-link">
<h3>{{ link.description }}</h3>
<input value="{{ link.full_url }}" />
<p>
{% if link.type == "DRAFT" %}
{% trans "Lien vers <em>le dernier brouillon</em>" %}
{% elif link.type == "BETA" %}
{% trans "Lien vers <em>la dernière bêta</em>" %}
{% else %}
{% trans "Lien de <em>type inconnu</em>" %}
{% endif %}
</p>
<p>
<p>
{% if link.expiration and link.expired %}
{% blocktrans with date=link.expiration %}
Lien <em>expiré</em> depuis le {{ date }}
{% endblocktrans %}
{% elif link.expiration and not link.expired %}
{% blocktrans with date=link.expiration %}
Valide <em>jusqu'au {{ date }}</em>
{% endblocktrans %}
{% else %}
{% trans "Valide <em>indéfiniment</em>" %}
{% endif %}
</p>
</p>
<a href="#edit-shareable-link-{{ link.id }}" class="open-modal">
{% trans "Modifier" %}
</a>

<form
action="{% url 'content:edit-shareable-link' link.id %}"
method="post"
id="edit-shareable-link-{{ link.id }}"
class="modal modal-flex">
{% csrf_token %}
{{ edit_form.as_p }}
<button type="submit" class="btn-submit">{% trans "Modifier" %}</button>
</form>


<a href="#delete-shareable-link-{{ link.id }}" class="open-modal">
{% trans "Supprimer" %}
</a>

<form
action="{% url 'content:delete-shareable-link' link.id %}"
method="post"
id="delete-shareable-link-{{ link.id }}"
class="modal modal-flex">
{% csrf_token %}
<p>
{% blocktrans %}
<b>Attention, ce lien sera supprimé définitivement.</b>
Vous ne pourrez pas le récupérer.
Si vous souhaitez réutiliser ce lien plus tard, désactivez-le.
{% endblocktrans %}
</p>
<button type="submit" class="btn-submit">{% trans "Supprimer" %}</button>
</form>

{% if section == "active" or section == "expired" %}
<form action="{% url 'content:deactivate-shareable-link' link.id %}" method="post">
{% csrf_token %}
<button type="submit" class="btn-cancel">{% trans "Désactiver" %}</button>
</form>
{% else %}
<form action="{% url 'content:reactivate-shareable-link' link.id %}" method="post">
{% csrf_token %}
<button type="submit" class="btn-submit">{% trans "Réactiver" %}</button>
</form>
{% endif %}
</li>
98 changes: 98 additions & 0 deletions templates/tutorialv2/view/shared_container.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
{% extends "tutorialv2/base.html" %}
{% load set %}
{% load thumbnail %}
{% load emarkdown %}
{% load i18n %}
{% load times %}
{% load feminize %}
{% load pluralize_fr %}

{% block title %}
{{ container.title }} - {{ content.title }}
{% endblock %}



{% block breadcrumb %}

{% if container.parent.parent %}
<li>
<a href="{{ container.parent.parent.get_absolute_url }}">{{ container.parent.parent.title }}</a>
</li>
{% endif %}

{% if container.parent %}
<li>
<a href="{{ container.parent.get_absolute_url }}">{{ container.parent.title }}</a>
</li>
{% endif %}

<li>{{ container.title }}</li>

{% endblock %}


{% block headline %}

{% if content.licence %}
<p class="license">{{ content.licence }}</p>
{% endif %}

<h1>{{ container.title }}</h1>

{% include 'tutorialv2/includes/tags_authors.part.html' with publishablecontent=content online=False %}

{% endblock %}


{% block content %}

{% include "tutorialv2/includes/chapter_pager.part.html" with position="top" %}

{% if container.introduction and container.get_introduction %}
{{ container.get_introduction|emarkdown:is_js }}
{% endif %}

{% if container.has_extracts %}
<ul>
{% for extract in container.children %}
<li>
<a href="#{{ extract.position_in_parent }}-{{ extract.slug }}">
{{ extract.title }}
</a>
</li>
{% endfor %}
</ul>
{% endif %}

{% for child in container.children %}
{% include "tutorialv2/includes/shared_content_child.html" with child=child %}
{% empty %}
{% if not container.is_chapter %}
<div class="ico-after warning">
<p>
{{ "Ce"|feminize:container.get_level_as_string }} {{ container.get_level_as_string|lower }} {% trans " est actuellement vide." %}
</p>
</div>
{% endif %}
{% endfor %}

<hr />

{% if container.conclusion and container.get_conclusion %}
{{ container.get_conclusion|emarkdown }}
{% endif %}

{% include "tutorialv2/includes/chapter_pager.part.html" with position="bottom" %}

{% if content.is_beta and container.has_extracts %}
{% include "tutorialv2/includes/warn_typo.part.html" with content=content %}
{% endif %}
{% endblock %}


{% block sidebar_blocks %}

{% include "tutorialv2/includes/summary.part.html" with current_container=container %}

{% endblock %}
Loading

0 comments on commit 9ce0191

Please sign in to comment.