Skip to content

Commit bd4750c

Browse files
committed
Show contributor image
1 parent 07d6d51 commit bd4750c

5 files changed

Lines changed: 33 additions & 0 deletions

File tree

data/contrib_data.py

Lines changed: 5 additions & 0 deletions
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)
Lines changed: 18 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
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):

static/main.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@
55
.students {
66
list-style: none;
77
}
8+
9+
.user-image {
10+
width: 100%;
11+
}

templates/contributors.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<!DOCTYPE html>
2+
{% load staticfiles %}
23
<html lang="en">
34
<head>
45
<!-- Required meta tags -->
@@ -7,13 +8,17 @@
78
<!-- Bootstrap CSS -->
89
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
910
<title>Contributors Data</title>
11+
<link href="{% static "main.css" %}" rel="stylesheet">
1012
</head>
1113
<body>
1214
<h1>Details of all the contributors</h1>
1315
<ul>
1416
{% for contributor in contributors %}
1517
<div class="container">
1618
<div class="row">
19+
<div class="col-sm-6 col-md-4">
20+
<img src="{{ contributor.image_url }}" class="user-image" alt="User Avatar">
21+
</div>
1722
<div class="col-sm-6 col-md-4">
1823
<div class="thumbnail">
1924
<div class="caption">

0 commit comments

Comments
 (0)