Skip to content

Commit 6c1e53d

Browse files
committed
Show contributor image
1 parent 2a5d9bd commit 6c1e53d

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

data/contrib_data.py

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ def import_data(contributor):
3232
try:
3333
contributor['issues_opened'] = contributor.pop('issues')
3434
contributor['num_commits'] = contributor.pop('contributions')
35+
contributor['image_url'] = get_image_url(login)
3536
contributor.pop('teams')
3637
c, create = Contributor.objects.get_or_create(
3738
**contributor
@@ -45,3 +46,7 @@ def import_data(contributor):
4546
logger.error(
4647
'Something went wrong saving this contributor %s: %s'
4748
% (login, ex))
49+
50+
51+
def get_image_url(username):
52+
return 'https://avatars1.githubusercontent.com/{}'.format(username)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Generated by Django 2.1.5 on 2019-02-04 18:57
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
8+
dependencies = [
9+
('data', '0004_auto_20180809_2229'),
10+
]
11+
12+
operations = [
13+
migrations.AddField(
14+
model_name='contributor',
15+
name='image_url',
16+
field=models.ImageField(default=None, null=True, upload_to=''),
17+
),
18+
]

data/models.py

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Contributor(models.Model):
1515
num_commits = models.IntegerField(default=None, null=True)
1616
reviews = models.IntegerField(default=None, null=True)
1717
issues_opened = models.IntegerField(default=None, null=True)
18+
image_url = models.ImageField(default=None, null=True)
1819
teams = models.ManyToManyField(Team)
1920

2021
def __str__(self):

templates/contributors.html

+8
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,21 @@
77
<!-- Bootstrap CSS -->
88
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
99
<title>Contributors Data</title>
10+
<style>
11+
.user-image {
12+
width: 100%;
13+
}
14+
</style>
1015
</head>
1116
<body>
1217
<h1>Details of all the contributors</h1>
1318
<ul>
1419
{% for contributor in contributors %}
1520
<div class="container">
1621
<div class="row">
22+
<div class="col-sm-6 col-md-4">
23+
<img src={{contributor.image_url}} class="user-image" alt="User Avatar">
24+
</div>
1725
<div class="col-sm-6 col-md-4">
1826
<div class="thumbnail">
1927
<div class="caption">

0 commit comments

Comments
 (0)