From 5a6e4cececfd4d5228c87eac44bb1867f9301de3 Mon Sep 17 00:00:00 2001 From: Arnaud-D <35631001+Arnaud-D@users.noreply.github.com> Date: Thu, 10 Jun 2021 15:46:04 +0200 Subject: [PATCH] WIP Partage par lien --- assets/scss/main.scss | 1 + assets/scss/pages/_shareable-links.scss | 117 ++++++++++++++ templates/tutorialv2/view/content.html | 7 + .../tutorialv2/view/list_shareable_links.html | 115 ++++++++++++++ .../view/list_shareable_links.part.html | 96 ++++++++++++ zds/settings/abstract_base/django.py | 2 +- .../migrations/0042_shareablelink.py | 40 +++++ zds/tutorialv2/mixins.py | 4 +- zds/tutorialv2/models/__init__.py | 5 + zds/tutorialv2/models/shareable_links.py | 67 ++++++++ .../tests_views/shareable_links/__init__.py | 0 .../tests_createshareablelinkview.py | 47 ++++++ .../tests_deactivateshareablelinkview.py | 48 ++++++ .../tests_deleteshareablelinkview.py | 48 ++++++ .../tests_editshareablelinkview.py | 53 +++++++ .../tests_listshareablelinksview.py | 66 ++++++++ .../tests_reactivateshareablelinkview.py | 48 ++++++ .../tests_sharedcontentview.py | 48 ++++++ zds/tutorialv2/urls/urls_contents.py | 30 ++++ zds/tutorialv2/views/display/config.py | 3 + .../views/display/shared_content.py | 92 +++++++++++ zds/tutorialv2/views/shareable_links.py | 148 ++++++++++++++++++ 22 files changed, 1082 insertions(+), 3 deletions(-) create mode 100644 assets/scss/pages/_shareable-links.scss create mode 100644 templates/tutorialv2/view/list_shareable_links.html create mode 100644 templates/tutorialv2/view/list_shareable_links.part.html create mode 100644 zds/tutorialv2/migrations/0042_shareablelink.py create mode 100644 zds/tutorialv2/models/shareable_links.py create mode 100644 zds/tutorialv2/tests/tests_views/shareable_links/__init__.py create mode 100644 zds/tutorialv2/tests/tests_views/shareable_links/tests_createshareablelinkview.py create mode 100644 zds/tutorialv2/tests/tests_views/shareable_links/tests_deactivateshareablelinkview.py create mode 100644 zds/tutorialv2/tests/tests_views/shareable_links/tests_deleteshareablelinkview.py create mode 100644 zds/tutorialv2/tests/tests_views/shareable_links/tests_editshareablelinkview.py create mode 100644 zds/tutorialv2/tests/tests_views/shareable_links/tests_listshareablelinksview.py create mode 100644 zds/tutorialv2/tests/tests_views/shareable_links/tests_reactivateshareablelinkview.py create mode 100644 zds/tutorialv2/tests/tests_views/shareable_links/tests_sharedcontentview.py create mode 100644 zds/tutorialv2/views/display/shared_content.py create mode 100644 zds/tutorialv2/views/shareable_links.py diff --git a/assets/scss/main.scss b/assets/scss/main.scss index 33ea86bff0..ccb66d2bae 100644 --- a/assets/scss/main.scss +++ b/assets/scss/main.scss @@ -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) diff --git a/assets/scss/pages/_shareable-links.scss b/assets/scss/pages/_shareable-links.scss new file mode 100644 index 0000000000..ac49d3afab --- /dev/null +++ b/assets/scss/pages/_shareable-links.scss @@ -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; + } + } + } + } + } + } +} diff --git a/templates/tutorialv2/view/content.html b/templates/tutorialv2/view/content.html index bb197bdc86..c3e31787ce 100644 --- a/templates/tutorialv2/view/content.html +++ b/templates/tutorialv2/view/content.html @@ -181,6 +181,13 @@ {% include "tutorialv2/includes/sidebar/contributors_management.part.html" %} {% endif %} + {% if display_config.draft_actions.show_shareable_link_management %} +
{% trans "Diffusez votre contenu en partageant un simple lien accessible sans incription sur le site." %}
+ +{% trans "Les liens de partages offrent les fonctionnalités suivantes :" %}
+ + {% blocktrans %} ++ {% 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 %} +
+ + {% if not active_links_and_forms %} + +{% trans "Vous n'avez pas de liens de partage actifs." %}
+ + {% else %} + ++ {% 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 %} +
+ + {% if not expired_links_and_forms %} + +{% trans "Vous n'avez pas de liens de partage expirés." %}
+ + {% else %} + ++ {% 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 %} +
+ + {% if not inactive_links_and_forms %} + +{% trans "Vous n'avez pas de liens de partage inactifs." %}
+ + {% else %} + +