Skip to content

Commit

Permalink
Display contributor image
Browse files Browse the repository at this point in the history
This enhancement commit displays the contributor image
along with the information on the [community website](http://community.coala.io/contributors/).

Closes coala#139 and Closes coala#141
  • Loading branch information
KVGarg committed Feb 12, 2019
1 parent 07d6d51 commit 7cd0ac3
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
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

0 comments on commit 7cd0ac3

Please sign in to comment.