-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajoute des champs DCMI aux pages des contenus - Rends le site compati…
…ble avec Zotero (#4392) * Ajoute des champs DCMI aux pages des contenus (#4261) * Corrige le commit précédent pour les champs DCMI (#4392) * Corrige le commit précédent pour les champs DCMI (#4392) * Corrige le commit précédent pour les champs DCMI (#4392) * Remplace les guillemets simples par des guillemets doubles * Ajoute la documentation du tag 'joinby' * N'affiche que les auteurs de la version courante * Corrige une variable dans le template
- Loading branch information
Showing
4 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# coding: utf-8 | ||
|
||
from django import template | ||
from django.utils.translation import ugettext_lazy as _ | ||
|
||
register = template.Library() | ||
|
||
|
||
@register.simple_tag | ||
def joinby(values, separator=', ', same_final_separator=False): | ||
""" | ||
Returns a human readable list (of type string) of values separated | ||
by a string definable with 'separator' (commas default, excepted | ||
the last preceded by "et") from an iterable. | ||
Set 'same_final_separator' to True to make the last also preceded | ||
by the same separator. | ||
""" | ||
if not values: | ||
return '' | ||
if len(values) == 1: | ||
return str(values[0]) | ||
if same_final_separator: | ||
final_sep = separator | ||
else: | ||
final_sep = _(' et ') | ||
return separator.join(map(str, values[:len(values) - 1])) + ( | ||
final_sep + str(values.last()) | ||
) |