From 97fdf02e65c9620a404b3bb6b63d9f859518a122 Mon Sep 17 00:00:00 2001 From: KVGarg Date: Tue, 5 Feb 2019 00:54:55 +0530 Subject: [PATCH] Show contributor image --- data/contrib_data.py | 5 +++++ data/migrations/0005_contributor_image_url.py | 18 ++++++++++++++++++ data/models.py | 1 + templates/contributors.html | 8 ++++++++ 4 files changed, 32 insertions(+) create mode 100644 data/migrations/0005_contributor_image_url.py diff --git a/data/contrib_data.py b/data/contrib_data.py index aacbab89..cfbefb38 100644 --- a/data/contrib_data.py +++ b/data/contrib_data.py @@ -32,6 +32,7 @@ def import_data(contributor): try: contributor['issues_opened'] = contributor.pop('issues') contributor['num_commits'] = contributor.pop('contributions') + contributor['image_url'] = get_image_url(login) contributor.pop('teams') c, create = Contributor.objects.get_or_create( **contributor @@ -45,3 +46,7 @@ def import_data(contributor): logger.error( 'Something went wrong saving this contributor %s: %s' % (login, ex)) + + +def get_image_url(username): + return 'https://avatars1.githubusercontent.com/{}'.format(username) diff --git a/data/migrations/0005_contributor_image_url.py b/data/migrations/0005_contributor_image_url.py new file mode 100644 index 00000000..1891cb35 --- /dev/null +++ b/data/migrations/0005_contributor_image_url.py @@ -0,0 +1,18 @@ +# Generated by Django 2.1.5 on 2019-02-04 18:57 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('data', '0004_auto_20180809_2229'), + ] + + operations = [ + migrations.AddField( + model_name='contributor', + name='image_url', + field=models.ImageField(default=None, null=True, upload_to=''), + ), + ] diff --git a/data/models.py b/data/models.py index b6ba1a0e..007f066c 100644 --- a/data/models.py +++ b/data/models.py @@ -15,6 +15,7 @@ class Contributor(models.Model): num_commits = models.IntegerField(default=None, null=True) reviews = models.IntegerField(default=None, null=True) issues_opened = models.IntegerField(default=None, null=True) + image_url = models.ImageField(default=None, null=True) teams = models.ManyToManyField(Team) def __str__(self): diff --git a/templates/contributors.html b/templates/contributors.html index 2c994e55..bc86a70b 100644 --- a/templates/contributors.html +++ b/templates/contributors.html @@ -7,6 +7,11 @@ Contributors Data +

Details of all the contributors

@@ -14,6 +19,9 @@

Details of all the contributors

{% for contributor in contributors %}
+
+ User Avatar +