Repository: mozilla/pontoon

Issue:
Users should have a way to contact existing locale managers
*This issue was created automatically by a [script](https://github.com/mathjazz/bugzilla2github/).*
## [Bug 1516164](https://bugzilla.mozilla.org/show_bug.cgi?id=1516164)
Bug Reporter: @flodolo
CC:   @mathjazz

I don't think there's an easy way for contributors to get in touch with existing managers or translators, even if it's something we suggest to do when they ask for new projects.

There's an INFO tab, but few of them customize it. Maybe we should have a TEAM tab, that lists all managers and translators for a team.

We could also have a "contacts" tab, with a form to get in touch with the team, accessible only to registered users.


Discussion:
Comment Author: @mathjazz

I agree getting in touch with and even identifying team managers and/or translators is tedious: you need to open the Contributors tab and manually check role of each contributor.

I've been thinking about this issue in the past, in slightly broader context: how to make both, team managers and project managers more noticeable. In today's dashboard layout, we could list all managers with their names and avatars in the header section. However, that would require a good deal of space and some design creativity to work well for various manager counts.

Adding a "Contact" tab is a less challenging task. OTOH, users very rarely click on dashboard tabs, so it doesn't solve the problem of managers being not very visible.


At least as the first step, I'd group contributors by role in the Team Contributor tab.

Resolving patch:
diff --git a/pontoon/contributors/utils.py b/pontoon/contributors/utils.py
--- a/pontoon/contributors/utils.py
+++ b/pontoon/contributors/utils.py
@@ -38,7 +38,9 @@ def map_translations_to_events(days, translations):
     return timeline
 
 
-def users_with_translations_counts(start_date=None, query_filters=None, limit=100):
+def users_with_translations_counts(
+    start_date=None, query_filters=None, locale=None, limit=100
+):
     """
     Returns contributors list, sorted by count of their translations. Every user instance has
     the following properties:
@@ -51,6 +53,7 @@ def users_with_translations_counts(start_date=None, query_filters=None, limit=10
     All counts will be returned from start_date to now().
     :param date start_date: start date for translations.
     :param django.db.models.Q query_filters: filters contributors by given query_filters.
+    :param pontoon.base.models.Locale locale: used to determine user locale role.
     :param int limit: limit results to this number.
     """
     # Collect data for faster user stats calculation.
@@ -100,11 +103,11 @@ def users_with_translations_counts(start_date=None, query_filters=None, limit=10
         Prefetch("translators_group__user_set", to_attr="fetched_translators"),
     )
 
-    for locale in locales:
-        for user in locale.managers_group.fetched_managers:
-            managers[user].add(locale.code)
-        for user in locale.translators_group.fetched_translators:
-            translators[user].add(locale.code)
+    for l in locales:
+        for user in l.managers_group.fetched_managers:
+            managers[user].add(l.code)
+        for user in l.translators_group.fetched_translators:
+            translators[user].add(l.code)
 
     # Assign properties to user objects.
     contributors = User.objects.filter(pk__in=user_stats.keys())
@@ -130,6 +133,9 @@ def users_with_translations_counts(start_date=None, query_filters=None, limit=10
         else:
             contributor.user_role = contributor.role(managers, translators)
 
+        if locale:
+            contributor.user_locale_role = contributor.locale_role(locale)
+
     contributors_list = sorted(contributors, key=lambda x: -x.translations_count)
     if limit:
         contributors_list = contributors_list[:limit]
diff --git a/pontoon/contributors/views.py b/pontoon/contributors/views.py
--- a/pontoon/contributors/views.py
+++ b/pontoon/contributors/views.py
@@ -332,7 +332,9 @@ def get_context_data(self, **kwargs):
             start_date = None
 
         context["contributors"] = users_with_translations_counts(
-            start_date, self.contributors_filter(**kwargs) & Q(user__isnull=False)
+            start_date,
+            self.contributors_filter(**kwargs) & Q(user__isnull=False),
+            kwargs.get("locale"),
         )
         context["period"] = period
         return context
diff --git a/pontoon/teams/views.py b/pontoon/teams/views.py
--- a/pontoon/teams/views.py
+++ b/pontoon/teams/views.py
@@ -297,6 +297,20 @@ class LocaleContributorsView(ContributorsMixin, DetailView):
     slug_field = "code"
     slug_url_kwarg = "locale"
 
+    def get_context_data(self, **kwargs):
+        context = super().get_context_data(locale=self.object, **kwargs)
+        contributors = context["contributors"]
+        context["managers"] = [
+            c for c in contributors if c.user_locale_role == "manager"
+        ]
+        context["translators"] = [
+            c for c in contributors if c.user_locale_role == "translator"
+        ]
+        context["regular_contributors"] = [
+            c for c in contributors if c.user_locale_role == "contributor"
+        ]
+        return context
+
     def get_context_object_name(self, obj):
         return "locale"
 


Test patch: