Skip to content

Commit

Permalink
[Fixes #12847] Stop using Gravatar service for the default gravar (#1…
Browse files Browse the repository at this point in the history
…2849)

* disable gravatar provider

* fix hardcoded avatar urls in permspec tests

* fix hardcoded avatar urls in permspec tests (2)
  • Loading branch information
giohappy authored Jan 27, 2025
1 parent 58b43b0 commit 5eaad8a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 28 deletions.
31 changes: 16 additions & 15 deletions geonode/base/api/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
from django.contrib.auth import get_user_model

from owslib.etree import etree
from avatar.templatetags.avatar_tags import avatar_url

from rest_framework.test import APITestCase
from rest_framework.renderers import JSONRenderer
Expand Down Expand Up @@ -1030,13 +1031,13 @@ def test_perms_resources(self):
"username": bobby.username,
"first_name": bobby.first_name,
"last_name": bobby.last_name,
"avatar": "https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"permissions": "owner",
"is_staff": False,
"is_superuser": False,
},
{
"avatar": "https://www.gravatar.com/avatar/7a68c67c8d409ff07e42aa5d5ab7b765/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"first_name": "admin",
"id": 1,
"last_name": "",
Expand Down Expand Up @@ -1111,7 +1112,7 @@ def test_perms_resources(self):
"username": bobby.username,
"first_name": bobby.first_name,
"last_name": bobby.last_name,
"avatar": "https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"permissions": "owner",
"is_staff": False,
"is_superuser": False,
Expand All @@ -1121,13 +1122,13 @@ def test_perms_resources(self):
"username": norman.username,
"first_name": norman.first_name,
"last_name": norman.last_name,
"avatar": "https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"permissions": "edit",
"is_staff": False,
"is_superuser": False,
},
{
"avatar": "https://www.gravatar.com/avatar/7a68c67c8d409ff07e42aa5d5ab7b765/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"first_name": "admin",
"id": 1,
"last_name": "",
Expand Down Expand Up @@ -1160,13 +1161,13 @@ def test_perms_resources(self):
"username": bobby.username,
"first_name": bobby.first_name,
"last_name": bobby.last_name,
"avatar": "https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"permissions": "owner",
"is_staff": False,
"is_superuser": False,
},
{
"avatar": "https://www.gravatar.com/avatar/7a68c67c8d409ff07e42aa5d5ab7b765/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"first_name": "admin",
"id": 1,
"last_name": "",
Expand Down Expand Up @@ -1223,13 +1224,13 @@ def test_perms_resources(self):
"username": bobby.username,
"first_name": bobby.first_name,
"last_name": bobby.last_name,
"avatar": "https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"permissions": "owner",
"is_staff": False,
"is_superuser": False,
},
{
"avatar": "https://www.gravatar.com/avatar/7a68c67c8d409ff07e42aa5d5ab7b765/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"first_name": "admin",
"id": 1,
"last_name": "",
Expand Down Expand Up @@ -2156,7 +2157,7 @@ def test_manager_can_edit_map(self):
"username": "bobby",
"first_name": "bobby",
"last_name": "",
"avatar": "https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"permissions": "manage",
"is_superuser": False,
"is_staff": False,
Expand All @@ -2166,7 +2167,7 @@ def test_manager_can_edit_map(self):
"username": "admin",
"first_name": "admin",
"last_name": "",
"avatar": "https://www.gravatar.com/avatar/7a68c67c8d409ff07e42aa5d5ab7b765/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"permissions": "owner",
"is_superuser": True,
"is_staff": True,
Expand Down Expand Up @@ -2197,7 +2198,7 @@ def test_manager_can_edit_map(self):
"username": "bobby",
"first_name": "bobby",
"last_name": "",
"avatar": "https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"permissions": "manage",
"is_staff": False,
"is_superuser": False,
Expand All @@ -2207,7 +2208,7 @@ def test_manager_can_edit_map(self):
"username": "admin",
"first_name": "admin",
"last_name": "",
"avatar": "https://www.gravatar.com/avatar/7a68c67c8d409ff07e42aa5d5ab7b765/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"permissions": "owner",
"is_staff": True,
"is_superuser": True,
Expand Down Expand Up @@ -2236,7 +2237,7 @@ def test_manager_can_edit_map(self):
"username": "bobby",
"first_name": "bobby",
"last_name": "",
"avatar": "https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"permissions": "manage",
"is_staff": False,
"is_superuser": False,
Expand All @@ -2246,7 +2247,7 @@ def test_manager_can_edit_map(self):
"username": "admin",
"first_name": "admin",
"last_name": "",
"avatar": "https://www.gravatar.com/avatar/7a68c67c8d409ff07e42aa5d5ab7b765/?s=240",
"avatar": build_absolute_uri(avatar_url(bobby)),
"permissions": "owner",
"is_staff": True,
"is_superuser": True,
Expand Down
2 changes: 1 addition & 1 deletion geonode/people/templates/people/profile_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h2 class="page-title">{{ profile.name_long }}</h2>
</div>

<div class="col-xs-3 col-md-2 profile-image">
{% autoescape off %}{% avatar profile 240 %}{% endautoescape %}
{% autoescape off %}{% avatar profile %}{% endautoescape %}
</div>

<div class="col-xs-9 col-md-7 profile-details">
Expand Down
2 changes: 1 addition & 1 deletion geonode/people/templates/people/profile_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h2 class="page-title">{% trans "Edit Profile for" %} {{ profile.username }}</h2
</div>

<div class="col-xs-3 col-md-2 profile-image">
{% autoescape off %}{% avatar profile.username 240 %}{% endautoescape %}
{% autoescape off %}{% avatar profile.username %}{% endautoescape %}
{% if user == profile %}
<p><a class="btn btn-primary btn-block" href="{% url 'avatar:change' %}">{% trans "Change your avatar" %}</a></p>
{% endif %}
Expand Down
21 changes: 11 additions & 10 deletions geonode/security/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

from requests.auth import HTTPBasicAuth
from tastypie.test import ResourceTestCaseMixin
from avatar.templatetags.avatar_tags import avatar_url

from django.db.models import Q
from django.urls import reverse
Expand All @@ -48,7 +49,7 @@
from geonode.documents.models import Document
from geonode.compat import ensure_string
from geonode.upload.models import ResourceHandlerInfo
from geonode.utils import check_ogc_backend
from geonode.utils import check_ogc_backend, build_absolute_uri
from geonode.tests.utils import check_dataset
from geonode.decorators import on_ogc_backend
from geonode.resource.manager import resource_manager
Expand Down Expand Up @@ -1363,13 +1364,13 @@ def test_perm_spec_conversion(self):
"username": standard_user.username,
"first_name": standard_user.first_name,
"last_name": standard_user.last_name,
"avatar": "https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e/?s=240",
"avatar": build_absolute_uri(avatar_url(standard_user)),
"permissions": "owner",
"is_staff": False,
"is_superuser": False,
},
{
"avatar": "https://www.gravatar.com/avatar/7a68c67c8d409ff07e42aa5d5ab7b765/?s=240",
"avatar": build_absolute_uri(avatar_url(standard_user)),
"first_name": "admin",
"id": 1,
"last_name": "",
Expand Down Expand Up @@ -1416,13 +1417,13 @@ def test_perm_spec_conversion(self):
"username": standard_user.username,
"first_name": standard_user.first_name,
"last_name": standard_user.last_name,
"avatar": "https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e/?s=240",
"avatar": build_absolute_uri(avatar_url(standard_user)),
"permissions": "owner",
"is_staff": False,
"is_superuser": False,
},
{
"avatar": "https://www.gravatar.com/avatar/7a68c67c8d409ff07e42aa5d5ab7b765/?s=240",
"avatar": build_absolute_uri(avatar_url(standard_user)),
"first_name": "admin",
"id": 1,
"last_name": "",
Expand Down Expand Up @@ -1486,7 +1487,7 @@ def test_perm_spec_conversion(self):
"username": standard_user.username,
"first_name": standard_user.first_name,
"last_name": standard_user.last_name,
"avatar": "https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e/?s=240",
"avatar": build_absolute_uri(avatar_url(standard_user)),
"permissions": "view",
}
]
Expand Down Expand Up @@ -1566,13 +1567,13 @@ def test_perm_spec_conversion(self):
"username": standard_user.username,
"first_name": standard_user.first_name,
"last_name": standard_user.last_name,
"avatar": "https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e/?s=240",
"avatar": build_absolute_uri(avatar_url(standard_user)),
"permissions": "download",
"is_staff": False,
"is_superuser": False,
},
{
"avatar": "https://www.gravatar.com/avatar/7a68c67c8d409ff07e42aa5d5ab7b765/?s=240",
"avatar": build_absolute_uri(avatar_url(standard_user)),
"first_name": "admin",
"id": 1,
"last_name": "",
Expand Down Expand Up @@ -1625,13 +1626,13 @@ def test_perm_spec_conversion(self):
"username": standard_user.username,
"first_name": standard_user.first_name,
"last_name": standard_user.last_name,
"avatar": "https://www.gravatar.com/avatar/d41d8cd98f00b204e9800998ecf8427e/?s=240",
"avatar": build_absolute_uri(avatar_url(standard_user)),
"permissions": "view",
"is_staff": False,
"is_superuser": False,
},
{
"avatar": "https://www.gravatar.com/avatar/7a68c67c8d409ff07e42aa5d5ab7b765/?s=240",
"avatar": build_absolute_uri(avatar_url(standard_user)),
"first_name": "admin",
"id": 1,
"last_name": "",
Expand Down
1 change: 0 additions & 1 deletion geonode/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -1360,7 +1360,6 @@
AVATAR_PROVIDERS = (
(
"avatar.providers.PrimaryAvatarProvider",
"avatar.providers.GravatarAvatarProvider",
"avatar.providers.DefaultAvatarProvider",
)
if os.getenv("AVATAR_PROVIDERS") is None
Expand Down
1 change: 1 addition & 0 deletions geonode/templates/avatar/avatar_tag.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<img src="{{ url }}" {% for key, value in kwargs.items %}{{key}}="{{value}}" {% endfor %}/>

0 comments on commit 5eaad8a

Please sign in to comment.