#4112 Include the avatar in the author list and fix a missing import
Merged 5 years ago by pingou. Opened 5 years ago by pingou.

@@ -41,7 +41,7 @@ 

  

  import pagure  # noqa: E402

  import pagure.lib.query  # noqa: E402

- from pagure.exceptions import PagureEvException  # noqa: E402

+ from pagure.exceptions import PagureException, PagureEvException  # noqa: E402

  

  SERVER = None

  SESSION = None

file modified
+2
@@ -3608,6 +3608,8 @@ 

      """

      Our own implementation since fas doesn't support this nicely yet.

      """

+     if not email:

+         return

      if dns:  # pragma: no cover

          # This makes an extra DNS SRV query, which can slow down our webapps.

          # It is necessary for libravatar federation, though.

file modified
+7 -3
@@ -968,12 +968,16 @@ 

  

      # Generate a list of contributors ordered by how many commits they

      # authored. The list consists of tuples with number of commits and people

-     # with that number of commits. Each contributor is represented by a name

-     # and e-mail address.

+     # with that number of commits. Each contributor is represented by a tuple

+     # of name, e-mail address and avatar url.

      out_stats = collections.defaultdict(list)

      for authors, val in stats.items():

          authors_email.add(authors[1])

-         out_stats[val].append(authors)

+         out_authors = list(authors)

+         out_authors.append(

+             pagure.lib.query.avatar_url_from_email(authors[1], size=32)

+         )

+         out_stats[val].append(tuple(out_authors))

      out_list = [

          (key, out_stats[key]) for key in sorted(out_stats, reverse=True)

      ]

@@ -81,6 +81,7 @@ 

        entry = data.results[1][key][1][entry];

        html += '  <a class="list-group-item" href="'

          + view_commits_url.replace('---', entry[1]) + '">'

+         + '<img class="avatar circle" src="' + entry[2] + '"/> '

          + entry[0]

          + '<div class="pull-xs-right">' + cnt + ' commits</div>'

          + '</a>\n';

file modified
+3 -4
@@ -3421,12 +3421,11 @@ 

          _log.debug("No ARCHIVE_FOLDER specified in the configuration")

          flask.abort(

              404,

-             "This pagure instance isn't configured to support this feature")

+             "This pagure instance isn't configured to support this feature",

+         )

      if not os.path.exists(archive_folder):

          _log.debug("No ARCHIVE_FOLDER could not be found on disk")

-         flask.abort(

-             500,

-             "Incorrect configuration, please contact your admin")

+         flask.abort(500, "Incorrect configuration, please contact your admin")

  

      extensions = ["tar.gz", "tar", "zip"]

      if extension not in extensions:

@@ -2146,15 +2146,37 @@ 

          js_data2 = json.loads(output.get_data(as_text=True))

          self.assertTrue(js_data2['results'][3] > 1509110062)

          js_data2['results'][3] = 1509110062

-         self.assertDictEqual(

-             js_data2,

-             {'results': [

-                 2,

-                 [[2, [['Alice Author', 'alice@authors.tld']]]],

-                 1,

-                 1509110062

+         self.assertTrue(

+             js_data2 in [

+                 {

+                     'results': [

+                         2,

+                         [[2, [[

+                             'Alice Author',

+                             'alice@authors.tld',

+                             'https://seccdn.libravatar.org/avatar/'

+                             '96c52c78570ffc4cfefcdadf5f8e77aeebcb11e07225df11bbf2fce381cdb8bd'

+                             '?s=32&d=retro'

+                         ]]]],

+                         1,

+                         1509110062

+                     ]

+                 },

+                 {

+                     'results': [

+                         2,

+                         [[2, [[

+                             'Alice Author',

+                             'alice@authors.tld',

+                             'https://seccdn.libravatar.org/avatar/'

+                             '96c52c78570ffc4cfefcdadf5f8e77aeebcb11e07225df11bbf2fce381cdb8bd'

+                             '?d=retro&s=32'

+                         ]]]],

+                         1,

+                         1509110062

+                     ]

+                 }

              ]

-             }

          )

  

      def test_get_stats_commits_trend_no_token(self):

file modified
+53 -5
@@ -64,7 +64,23 @@ 

          self.assertEqual(num_commits, 1)

          self.assertEqual(num_authors, 1)

          self.assertEqual(last_time, '2018-01-01 00:00')

-         self.assertEqual(authors, [(1, [('Alice', 'alice@example.com')])])

+         self.assertIn(

+             authors,

+             [

+                 [(1, [(

+                 'Alice', 'alice@example.com',

+                 'https://seccdn.libravatar.org/avatar/'

+                 'ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976'

+                 '?s=32&d=retro'

+                 )])],

+                 [(1, [(

+                 'Alice', 'alice@example.com',

+                 'https://seccdn.libravatar.org/avatar/'

+                 'ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976'

+                 '?d=retro&s=32'

+                 )])]

+             ]

+         )

  

      def test_rename_user_and_merge(self):

          self.commits = [
@@ -81,7 +97,23 @@ 

          self.assertEqual(num_commits, 2)

          self.assertEqual(num_authors, 1)

          self.assertEqual(last_time, '2018-01-01 00:00')

-         self.assertEqual(authors, [(2, [('Alice', 'alice@example.com')])])

+         self.assertIn(

+             authors,

+             [

+                 [(2, [(

+                 'Alice', 'alice@example.com',

+                 'https://seccdn.libravatar.org/avatar/'

+                 'ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976'

+                 '?s=32&d=retro'

+                 )])],

+                 [(2, [(

+                 'Alice', 'alice@example.com',

+                 'https://seccdn.libravatar.org/avatar/'

+                 'ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976'

+                 '?d=retro&s=32'

+                 )])]

+             ]

+         )

  

      def test_preserve_unknown_author(self):

          self.commits = [
@@ -95,7 +127,23 @@ 

          self.assertEqual(num_commits, 1)

          self.assertEqual(num_authors, 1)

          self.assertEqual(last_time, '2018-01-01 00:00')

-         self.assertEqual(authors, [(1, [('Alice', 'alice@example.com')])])

+         self.assertIn(

+             authors,

+             [

+                 [(1, [(

+                 'Alice', 'alice@example.com',

+                 'https://seccdn.libravatar.org/avatar/'

+                 'ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976'

+                 '?s=32&d=retro'

+                 )])],

+                 [(1, [(

+                 'Alice', 'alice@example.com',

+                 'https://seccdn.libravatar.org/avatar/'

+                 'ff8d9819fc0e12bf0d24892e45987e249a28dce836a85cad60e28eaaa8c6d976'

+                 '?d=retro&s=32'

+                 )])]

+             ]

+         )

  

      def test_handle_empty_email(self):

          self.commits = [
@@ -112,8 +160,8 @@ 

          self.assertEqual(num_commits, 3)

          self.assertEqual(num_authors, 2)

          self.assertEqual(last_time, '2018-01-01 00:00')

-         self.assertEqual(authors, [(2, [('Alice', None)]),

-                                    (1, [('Bob', '')])])

+         self.assertEqual(authors, [(2, [('Alice', None, None)]),

+                                    (1, [('Bob', '', None)])])

  

  

  class TestGitolitePostCompileOnly(object):