Skip to content

Commit

Permalink
Permet de gérer les auteurs directement depuis la liste des auteurs (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Arnaud-D authored Mar 3, 2024
1 parent bcd5efa commit 57a4c11
Show file tree
Hide file tree
Showing 8 changed files with 112 additions and 83 deletions.
59 changes: 52 additions & 7 deletions assets/scss/components/_members.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,50 @@
.deletable {
display: flex;
align-items: center;
border: $length-1 solid $grey-100;
margin-bottom: $length-4;
}

.delete-button {
display: block;
position: relative;

margin: 0;

width: $length-24;
height: $length-32 + $length-4;

transition: background-color .1s ease-in-out;

&:hover {
background-color: $grey-100;

&:after {
@include sprite-position($cross);
}
}

&::after {
content: " ";
display: block;

position: absolute;

top: 50%;
left: 50%;
margin-top: calc(-1 * $length-16 / 2);
margin-left: calc(-1 * $length-16 / 2);

width: $length-16;
height: $length-16;

background-repeat: no-repeat;

@include sprite;
@include sprite-position($cross-blue);
}
}

.member-item {
display: inline-flex;
align-items: center;
Expand All @@ -23,10 +70,10 @@
}

span {
padding: 0 $length-8;
padding: 0 $length-4;

&:only-child {
padding: 0;
padding-left: 0;
}
}

Expand Down Expand Up @@ -67,11 +114,11 @@

.members {
display: flex;
align-items: center;

.authors-label {
display: inline-block;
margin-right: $length-4;
margin: $length-8 $length-8 0 0;
flex-shrink: 0;
}

ul {
Expand All @@ -84,11 +131,9 @@
padding: 0;

li {
margin: 0;
margin: 0 $length-10 $length-4 0;

.member-item {
margin: 0 $length-8 0 0;
padding: $length-1;
padding-left: $length-4;
}
}
Expand Down
6 changes: 4 additions & 2 deletions doc/source/front-end/elements-specifiques-au-site.rst
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ Les membres et listes de membres
Afficher un membre
------------------

Pour afficher un membre, utilisez le gabari ``misc/member_item.part.html``. Il dispose de plusieurs arguments :
Pour afficher un membre, utilisez le gabarit ``misc/member_item.part.html``. Il dispose de plusieurs arguments :

- ``member`` : le membre à afficher (ce peut être un ``Profile`` ou un ``User``, peu importe) ;
- ``inline`` : si ``True``, l'élément sera stylisé pour une intégration au cœur d'un texte ;
Expand All @@ -376,7 +376,9 @@ Pour afficher un membre, utilisez le gabari ``misc/member_item.part.html``. Il d
- ``info`` : si renseigné, le texte donné sera affiché après le pseudonyme du membre, afin de donner un détail sur ce
dernier (ce texte sera entre parenthèses, sauf si le mode “pleine largeur” est actif — voir plus bas) ;
- ``fullwidth`` : si ``True``, active le support du mode pleine largeur (ce qui concrètement écrit le texte de
``info`` sans parenthèses).
``info`` sans parenthèses) ;
- ``deletable`` : Si ``True``, active le formulaire permettant de retirer le membre de la liste des auteurs et
autrices d'une publication.

Ce qui peut donner ceci par exemple.

Expand Down
21 changes: 20 additions & 1 deletion templates/misc/member_item.part.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{% load profile %}
{% load i18n %}
{% load captureas %}

{% with profile=member|profile %}
{% captureas username %}{{ profile.user.username }}{% endcaptureas %}
{% if deletable %}<div class="deletable">{% endif %}
{% spaceless %}
<a href="{{ profile.get_absolute_url }}"
class="member-item{% if inline %} is-inline{% endif %}{% if link %} is-link{% endif %}"
Expand All @@ -16,13 +19,29 @@
<img src="{% avatar_url profile %}" alt="" class="avatar" itemprop="image" aria-hidden="true" />
{% endif %}

<span itemprop="name">{{ profile.user.username }}</span>
<span itemprop="name">{{ username }}</span>

{% if info %}
<span class="info">
{% if fullwidth %}{{ info }}{% else %}({{ info }}){% endif %}
</span>
{% endif %}
</a>

{% if deletable %}
{% captureas button_text %}{% blocktrans %}Retirer {{ username }} des auteurs et autrices{% endblocktrans %}{% endcaptureas %}
<a href="#remove-author-{{ profile.pk }}" class="open-modal delete-button" title="{{ button_text }}">
<span class="visuallyhidden">{{ button_text }}</span>
</a>
{% url "content:remove-author" content.pk as remove_author_url %}
<form action="{{ remove_author_url }}" method="post" class="modal modal-flex" id="remove-author-{{ profile.pk }}"
data-modal-title="Retirer un auteur ou une autrice"
data-modal-close="Non, annuler">
<p>Voulez-vous retirer <em>{{ username }}</em> de la liste des auteurs et autrices ?<br /><strong>Cette action est irréversible</strong>.</p>
<button class="btn btn-submit" value="{{ username }}" name="username" type="submit">Oui, retirer</button>
{% csrf_token %}
</form>
{% endif %}
{% endspaceless %}
{% if deletable %}</div>{% endif %}
{% endwith %}
58 changes: 33 additions & 25 deletions templates/tutorialv2/includes/headline/authors.part.html
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
{% load i18n %}
{% load pluralize_fr %}
{% load displayable_authors %}
{% load captureas %}

<div class="members">
<span class="authors-label">
{% trans "Auteur" %}{{ db_content|displayable_authors:online_mode|pluralize }} :
</span>
<ul>
{% for member in db_content|displayable_authors:online_mode %}
<li>
{% include "misc/member_item.part.html" with avatar=True %}
</li>
{% endfor %}
{% with authors=db_content|displayable_authors:online_mode %}
<div class="members">
<span class="authors-label">
{% trans "Par" %}
</span>
<ul>
{% if authors.count == 1 %}
<li>
{% include "misc/member_item.part.html" with member=authors.first author=True avatar=True deletable=False %}
</li>
{% else %}
{% for author in authors %}
<li>
{% include "misc/member_item.part.html" with member=author author=True avatar=True deletable=edit_authors %}
</li>
{% endfor %}
{% endif %}

{% if add_author %}
<li>
<a href="#add-author-content" class="btn btn-add open-modal ico-after more blue">
{% trans "Ajouter un auteur" %}
</a>
<form action="{% url "content:add-author" content.pk %}" method="post" class="modal modal-flex" id="add-author-content">
{% csrf_token %}
<input type="text" name="username" placeholder="Pseudo de l’utilisateur à ajouter" data-autocomplete="{ 'type': 'single' }">
<button type="submit" name="add_author" class="btn btn-submit">
{% trans "Confirmer" %}
</button>
</form>
</li>
{% endif %}
</ul>
{% if edit_authors %}
<li>
<a href="#add-author" class="btn btn-add open-modal ico-after more blue">
{% trans "Ajouter" %}
</a>
{% url "content:add-author" content.pk as add_author_url %}
<form action="{{ add_author_url }}" method="post" class="modal modal-flex" id="add-author">
{% csrf_token %}
<input type="text" name="username" placeholder="Pseudo du membre à ajouter" data-autocomplete="{ 'type': 'single' }">
<button type="submit" name="add_author" class="btn btn-submit">{% trans "Confirmer" %}</button>
</form>
</li>
{% endif %}
</ul>
</div>
{% endwith %}
2 changes: 1 addition & 1 deletion templates/tutorialv2/includes/headline/header.part.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h2 class="subtitle">

<aside class="meta">
<div class="meta-column">
{% include "tutorialv2/includes/headline/authors.part.html" with db_content=db_content content=content add_author=display_config.draft_actions.show_author_management online_mode=display_config.online_config.enable_authors_online_mode %}
{% include "tutorialv2/includes/headline/authors.part.html" with db_content=db_content edit_authors=display_config.draft_actions.show_authors_management online_mode=display_config.online_config.enable_authors_online_mode %}
{% include "tutorialv2/includes/headline/contributions.part.html" %}
{% include "tutorialv2/includes/headline/categories.part.html" %}
{% include "tutorialv2/includes/headline/goals.part.html" with goals=publishablecontent.goals.all %}
Expand Down
42 changes: 0 additions & 42 deletions templates/tutorialv2/includes/sidebar/authors_management.part.html

This file was deleted.

4 changes: 0 additions & 4 deletions templates/tutorialv2/view/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -184,10 +184,6 @@
</li>
{% endif %}

{% if display_config.draft_actions.show_authors_management %}
{% include "tutorialv2/includes/sidebar/authors_management.part.html" %}
{% endif %}

{% if display_config.draft_actions.show_contributors_management %}
{% include "tutorialv2/includes/sidebar/contributors_management.part.html" %}
{% endif %}
Expand Down
3 changes: 2 additions & 1 deletion zds/tutorialv2/views/authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ def form_valid(self, form):

if not current_user: # if the removed author is not current user
messages.success(
self.request, _("Vous avez enlevé {} de la liste des auteurs de {}.").format(authors_list, _type[0])
self.request,
_("Vous avez enlevé {} de la liste des auteurs et autrices de {}.").format(authors_list, _type[0]),
)
self.success_url = self.object.get_absolute_url()
else: # if current user is leaving the content's redaction, redirect him to a more suitable page
Expand Down

0 comments on commit 57a4c11

Please sign in to comment.