Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions data/contrib_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
18 changes: 18 additions & 0 deletions data/migrations/0005_contributor_image_url.py
Original file line number Diff line number Diff line change
@@ -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=''),
),
]
1 change: 1 addition & 0 deletions data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
4 changes: 4 additions & 0 deletions static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
.students {
list-style: none;
}

.user-image {
width: 100%;
}
5 changes: 5 additions & 0 deletions templates/contributors.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<!DOCTYPE html>
{% load staticfiles %}
<html lang="en">
<head>
<!-- Required meta tags -->
Expand All @@ -7,13 +8,17 @@
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Contributors Data</title>
<link href="{% static "main.css" %}" rel="stylesheet">
</head>
<body>
<h1>Details of all the contributors</h1>
<ul>
{% for contributor in contributors %}
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-4">
<img src="{{ contributor.image_url }}" class="user-image" alt="User Avatar">
</div>
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<div class="caption">
Expand Down