Repository: apluslms/a-plus

Issue:
Remove the user profile avatar icons from the student group menus
The user profile avatar icon was removed from the user profile page in #590. Now the profile icon needs to be removed from the student group menus that include it.

We decided to remove the avatar in order to remove the dependency on the external service gravatar.com and Wordpress accounts.


Discussion:
The course participant page (for teachers) also shows the user profile avatar. The avatar should be removed from there as well.

Resolving patch:
diff --git a/course/renders.py b/course/renders.py
--- a/course/renders.py
+++ b/course/renders.py
@@ -1,18 +1,12 @@
 from django.template import loader
 
 
-def render_avatars(profiles):
-    template = loader.get_template("course/_avatars.html")
-    return template.render({ 'profiles': profiles })
-
-
 def group_info_context(group, profile):
     if not group:
         return { 'id': None }
     return {
         'id': group.id,
-        'collaborators': group.collaborator_names(profile),
-        'avatars': render_avatars(group.members.all()),
+        'collaborators': group.collaborator_names(profile)
     }
 
 
diff --git a/course/templatetags/course.py b/course/templatetags/course.py
--- a/course/templatetags/course.py
+++ b/course/templatetags/course.py
@@ -128,11 +128,6 @@ def names(profiles):
     return ", ".join(p.user.get_full_name() for p in profiles)
 
 
-@register.inclusion_tag('course/_avatars.html')
-def avatars(profiles):
-    return { 'profiles': profiles }
-
-
 @register.inclusion_tag("course/_profiles.html")
 def profiles(
         profiles: Union[UserProfile, List[UserProfile], models.QuerySet[UserProfile]],
diff --git a/userprofile/models.py b/userprofile/models.py
--- a/userprofile/models.py
+++ b/userprofile/models.py
@@ -1,4 +1,3 @@
-import hashlib
 from typing import Any, Optional, TYPE_CHECKING
 
 from aplus_auth.payload import Permission
@@ -112,14 +111,6 @@ def api_token(self):
         token, _created = Token.objects.get_or_create(user=self.user)
         return token.key
 
-    @cached_property
-    def avatar_url(self):
-        """
-        URL address for gravatar image based on the user email.
-        """
-        hash_key = hashlib.md5(self.user.email.encode('utf-8')).hexdigest()
-        return "http://www.gravatar.com/avatar/" + hash_key + "?d=identicon"
-
     @cached_property
     def shortname(self):
         """


Test patch:
diff --git a/userprofile/tests.py b/userprofile/tests.py
--- a/userprofile/tests.py
+++ b/userprofile/tests.py
@@ -137,24 +137,6 @@ def test_userprofile_unicode_string(self):
         self.assertEqual("teacher (Tedious Teacher, teacher@aplus.com)", str(self.teacher_profile))
         self.assertEqual("superuser (Super User, superuser@aplus.com)", str(self.superuser_profile))
 
-    def test_userprofile_gravatar_url(self):
-        self.assertEqual(
-            "http://www.gravatar.com/avatar/36eb57f675f34b81bd859c525cb2b676?d=identicon",
-            self.student_profile.avatar_url
-        )
-        self.assertEqual(
-            "http://www.gravatar.com/avatar/e2321e37326539393fbae72b7558df8e?d=identicon",
-            self.grader_profile.avatar_url
-        )
-        self.assertEqual(
-            "http://www.gravatar.com/avatar/1bfe4ecc42454c9c1dc02bf93073a414?d=identicon",
-            self.teacher_profile.avatar_url
-        )
-        self.assertEqual(
-            "http://www.gravatar.com/avatar/f35e575136edbfb920643d10560e8814?d=identicon",
-            self.superuser_profile.avatar_url
-        )
-
     def test_userprofile_shortname(self):
         self.assertEqual("Superb S.", self.student_profile.shortname)
         self.assertEqual("Grumpy G.", self.grader_profile.shortname)