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 Nov 11, 2024
1 parent b089a37 commit 803f279
Show file tree
Hide file tree
Showing 22 changed files with 1,082 additions and 3 deletions.
1 change: 1 addition & 0 deletions assets/scss/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
@import "pages/content-editor";
@import "pages/content-exports";
@import "pages/mass-edit-goals";
@import "pages/shareable-links";

/*-------------------------
11. High pixel ratio (retina)
Expand Down
117 changes: 117 additions & 0 deletions assets/scss/pages/_shareable-links.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
.main .content-wrapper.shareable-link-page {
h2 {
color: $accent-700;
border: 0;
}

.new-link-button {
button {
float: none;
}
}

.list_of_links {
list-style: none;

.shareable-link-frame {
border: 1px solid black;
padding: $length-10;
margin-bottom: $length-20;
background: $true-white;
border: solid $length-1 $grey-200;
border-bottom: solid $length-2 $grey-200;

header {
display: flex;
flex-wrap: wrap;
min-height: $length-24;

.shareable-link-description {
flex-grow: 100;
display: inline-block;
margin: 0 0 $length-6 0;
padding: 0;
}

.shareable-link-actions {
display: flex;
flex-wrap: wrap;

.btn-holder {
min-height: 0;
height: $length-24;
margin: 0 0 $length-6 $length-20;


.btn-grey, .btn-cancel, .btn-submit {
padding: 0 $length-6;
line-height: normal;
height: $length-24;
}

}

.activation_status {
display: flex;
width: min-content;

.btn-grey, .btn-submit, input [type="hidden"], input{
padding: 0 $length-6;
line-height: normal;
height: $length-24;
}

.status_display {
display: inline-block;
margin: auto;
padding: 0;
margin: 0 $length-6 $length-6 0;
}

.status_active {
color:green;
vertical-align: middle;
}

.status_active::before {
content: "";
margin-right: $length-4;
}

.status_inactive {
color:gray;
vertical-align: middle;
}

.status_inactive::before {
content: "";
margin-right: $length-4;
}
}
}
}

section {
.shareable-link-url {
margin: $length-4 0;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}

.shareable-link-info {
display: flex;
flex-wrap: wrap;

.shareable-link-info-line {
margin: 0 $length-20 0 0;

&.shareable-link-has-expired {
color: $red-700;
}
}
}
}
}
}
}
7 changes: 7 additions & 0 deletions templates/tutorialv2/view/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@
{% include "tutorialv2/includes/sidebar/contributors_management.part.html" %}
{% endif %}

{% if display_config.draft_actions.show_shareable_link_management %}
<li>
{% url "content:import" content.pk content.slug as import_url %}
<a href="{% url "content:list-shareable-links" content.pk %}" class="ico-after gear blue">{% trans "Gérer les liens de partage" %}</a>
</li>
{% endif %}

{% endblock %}


Expand Down
115 changes: 115 additions & 0 deletions templates/tutorialv2/view/list_shareable_links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{% extends "tutorialv2/base.html" %}
{% load i18n %}

{% block breadcrumb %}
<li><a href="{{ content.get_absolute_url }}">{{ content.title }}</a></li>
<li>{% trans "Liens de partage" %}</li>
{% endblock %}

{% block content_out %}
<div class="content-wrapper shareable-link-page">
<header>
<h1>{% blocktrans %} Liens de partage pour « {{ content }} » {% endblocktrans %}</h1>
</header>
<section>
<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 %}

<p class="new-link-button btn-holder">
<button href="#create-shareable-link" class="open-modal btn-submit">
{% trans "Nouveau lien de partage" %}
</button>

<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>
</p>


<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 "<em>Vous n'avez pas de liens de partage actifs.</em>" %}</p>

{% else %}

<ul class="list_of_links">
{% 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 "<em>Vous n'avez pas de liens de partage expirés.</em>" %}</p>

{% else %}

<ul class="list_of_links">
{% 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 "<em>Vous n'avez pas de liens de partage inactifs.</em>" %}</p>

{% else %}

<ul class="list_of_links">
{% 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 %}
</section>
</div>
{% endblock %}
96 changes: 96 additions & 0 deletions templates/tutorialv2/view/list_shareable_links.part.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{% load i18n %}

<li class="shareable-link-frame">
<header>
<h3 class="shareable-link-description">{{ link.description }}</h3>

<div class="shareable-link-actions">
{% if section == "active" or section == "expired" %}
<div class="activation_status">
<p class="status_display"><span class="status_active">Actif</span></p>
<form action="{% url 'content:deactivate-shareable-link' link.id %}" method="post">
{% csrf_token %}
<button type="submit" class="btn-grey">{% trans "Désactiver" %}</button>
</form>
</div>
{% else %}
<div class="activation_status">
<p class="status_display"><span class="status_inactive">Inactif</span></p>
<form action="{% url 'content:reactivate-shareable-link' link.id %}" method="post">
{% csrf_token %}
<button type="submit" class="btn-submit">{% trans "Réactiver" %}</button>
</form>
</div>
{% endif %}

<div class="btn-holder">
<button href="#edit-shareable-link-{{ link.id }}" class="open-modal btn-grey">
{% trans "Modifier" %}
</button>

<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>
</div>

<div class="btn-holder">
<button href="#delete-shareable-link-{{ link.id }}" class="open-modal btn-cancel">
{% trans "Supprimer" %}
</button>

<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 %}
<strong>Attention, ce lien sera supprimé définitivement.</strong>
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>
</div>
</div>
</header>

<section>
<div class="shareable-link-url" ><a href="{{ link.full_url }}">{{ link.full_url }}</a></div>
<div class="shareable-link-info">
<p class="shareable-link-info-line">
{% 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>
{% if link.valid_indefinitely %}
<p class="shareable-link-info-line">{% trans "Sans date d'expiration" %}</p>
{% elif link.expired %}
<p class="shareable-link-info-line shareable-link-has-expired">
{% blocktrans with date=link.expiration|date:"DATE_FORMAT" %}
A expiré le {{ date }}
{% endblocktrans %}
</p>
{% else %}
<p class="shareable-link-info-line">
{% blocktrans with date=link.expiration|date:"DATE_FORMAT" %}
Expire le {{ date }}
{% endblocktrans %}
</p>
{% endif %}
</p>
</div>
</section>
</li>
2 changes: 1 addition & 1 deletion zds/settings/abstract_base/django.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = False
USE_L10N = True

# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = False
Expand Down
Loading

0 comments on commit 803f279

Please sign in to comment.