-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remplacement de Gravatar par Jdenticon pour les avatars par défaut (#…
…6609) * Remplacement de Gravatar par Jdenticon pour les avatars par défaut * Ajout d'une commande pour la migration de Gravatar à jdenticon * Redéfinition de Profile.get_avatar_url()
- Loading branch information
Showing
19 changed files
with
99 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -165,7 +165,7 @@ div.msg-are-hidden { | |
overflow: hidden; | ||
} | ||
|
||
img { | ||
.avatar { | ||
height: $length-48; | ||
width: $length-48; | ||
|
||
|
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
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,11 @@ | ||
{% load captureas %} | ||
|
||
{# Template used by the templatetag "avatar" defined in zds/utils/templatetags/profile.py #} | ||
|
||
{% captureas alt_text %}Avatar de {{ username }}{% endcaptureas %} | ||
|
||
{% if avatar_url %} | ||
<img src="{{ avatar_url }}" alt="{{ alt_text }}" class="avatar" itemprop="image" aria-hidden="true"> | ||
{% else %} | ||
<canvas width="{{ avatar_size }}" height="{{ avatar_size }}" data-jdenticon-value="{{ username }}" class="avatar">{{ alt_text }}</canvas> | ||
{% endif %} |
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 |
---|---|---|
|
@@ -1049,6 +1049,13 @@ caniuse-lite@^1.0.30001587, caniuse-lite@^1.0.30001591: | |
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001596.tgz#da06b79c3d9c3d9958eb307aa832ac68ead79bee" | ||
integrity sha512-zpkZ+kEr6We7w63ORkoJ2pOfBwBkY/bJrG/UZ90qNb45Isblu8wzDgevEOrRL1r9dWayHjYiiyCMEXPn4DweGQ== | ||
|
||
canvas-renderer@~2.2.0: | ||
version "2.2.1" | ||
resolved "https://registry.yarnpkg.com/canvas-renderer/-/canvas-renderer-2.2.1.tgz#c1d131f78a9799aca8af9679ad0a005052b65550" | ||
integrity sha512-RrBgVL5qCEDIXpJ6NrzyRNoTnXxYarqm/cS/W6ERhUJts5UQtt/XPEosGN3rqUkZ4fjBArlnCbsISJ+KCFnIAg== | ||
dependencies: | ||
"@types/node" "*" | ||
|
||
capture-stack-trace@^1.0.0: | ||
version "1.0.2" | ||
resolved "https://registry.yarnpkg.com/capture-stack-trace/-/capture-stack-trace-1.0.2.tgz#1c43f6b059d4249e7f3f8724f15f048b927d3a8a" | ||
|
@@ -4809,6 +4816,13 @@ isurl@^1.0.0-alpha5: | |
has-to-string-tag-x "^1.2.0" | ||
is-object "^1.0.1" | ||
|
||
[email protected]: | ||
version "3.3.0" | ||
resolved "https://registry.yarnpkg.com/jdenticon/-/jdenticon-3.3.0.tgz#64bae9f9b3cf5c2a210e183648117afe3a89b367" | ||
integrity sha512-DhuBRNRIybGPeAjMjdHbkIfiwZCCmf8ggu7C49jhp6aJ7DYsZfudnvnTY5/1vgUhrGA7JaDAx1WevnpjCPvaGg== | ||
dependencies: | ||
canvas-renderer "~2.2.0" | ||
|
||
[email protected]: | ||
version "0.0.4" | ||
resolved "https://registry.npmjs.org/jpeg-js/-/jpeg-js-0.0.4.tgz" | ||
|
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,29 @@ | ||
from hashlib import md5 | ||
from time import sleep | ||
|
||
import requests | ||
from django.core.management.base import BaseCommand | ||
from django.db.models import Q | ||
|
||
from zds.member.models import Profile | ||
|
||
|
||
class Command(BaseCommand): | ||
help = "Migrate from Gravatar" | ||
|
||
def handle(self, *args, **options): | ||
# We have profiles with either NULL or empty avatar_url field | ||
profiles_without_avatar_url = Profile.objects.filter(Q(avatar_url__isnull=True) | Q(avatar_url="")) | ||
total = profiles_without_avatar_url.count() | ||
i = 1 | ||
for profile in profiles_without_avatar_url.iterator(): | ||
hash = md5(profile.user.email.lower().encode("utf-8")).hexdigest() | ||
gravatar_url = f"https://secure.gravatar.com/avatar/{hash}" | ||
r = requests.get(f"{gravatar_url}?d=404") | ||
if r.status_code == 200: | ||
profile.avatar_url = f"{gravatar_url}?s=200" | ||
profile.save() | ||
self.stdout.write(f"\rProgress: {i}/{total}", ending="") | ||
i += 1 | ||
sleep(1) | ||
self.stdout.write(self.style.SUCCESS("\nSuccessfully migrated from Gravatar!")) |
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