From a01cc0af37a12529cb6ad2f88eb8af5a41169aed Mon Sep 17 00:00:00 2001 From: KVGarg Date: Tue, 5 Feb 2019 00:54:55 +0530 Subject: [PATCH] Display contributor image This enhancement commit displays the contributor image along with the information on the [community website](http://community.coala.io/contributors/). Closes #139, Closes #141 --- data/contrib_data.py | 5 +++++ data/migrations/0005_contributor_image_url.py | 18 ++++++++++++++++++ data/models.py | 1 + static/main.css | 4 ++++ templates/contributors.html | 5 +++++ 5 files changed, 33 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/static/main.css b/static/main.css index d2f410e3..f6857e9c 100644 --- a/static/main.css +++ b/static/main.css @@ -5,3 +5,7 @@ .students { list-style: none; } + +.user-image { + width: 100%; +} diff --git a/templates/contributors.html b/templates/contributors.html index 32abe1a6..99ed8645 100644 --- a/templates/contributors.html +++ b/templates/contributors.html @@ -1,4 +1,5 @@ +{% load staticfiles %} @@ -7,6 +8,7 @@ Contributors Data +

Details of all the contributors

@@ -14,6 +16,9 @@

Details of all the contributors

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