Skip to content

Commit

Permalink
gamification/: Redesign the webpage
Browse files Browse the repository at this point in the history
The redesigned webpages provides a enhanced
UI/UX design to web-page with additional
functionality of searching the contributors.

Closes coala#260
  • Loading branch information
KVGarg committed Aug 6, 2019
1 parent 5735101 commit a8df35a
Show file tree
Hide file tree
Showing 5 changed files with 258 additions and 54 deletions.
4 changes: 2 additions & 2 deletions community/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from gci.feeds import LatestTasksFeed as gci_tasks_rss
from ci_build.view_log import BuildLogsView
from data.views import ContributorsListView
from gamification.views import index as gamification_index
from gamification.views import GamificationResults
from meta_review.views import ContributorsMetaReview
from inactive_issues.inactive_issues_scraper import inactive_issues_json
from openhub.views import index as openhub_index
Expand Down Expand Up @@ -193,7 +193,7 @@ def get_organization():
distill_file='static/unassigned-issues.json',
),
distill_url(
r'gamification/$', gamification_index,
r'gamification/$', GamificationResults.as_view(),
name='community-gamification',
distill_func=get_index,
distill_file='gamification/index.html',
Expand Down
2 changes: 1 addition & 1 deletion gamification/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ def test_view_uses_correct_template(self):
def test_all_contributors_on_template(self):
resp = self.client.get(reverse('community-gamification'))
self.assertEqual(resp.status_code, 200)
self.assertTrue(len(resp.context['participants']) == 10)
self.assertTrue(len(resp.context['gamification_results']) == 10)
16 changes: 10 additions & 6 deletions gamification/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
from django.shortcuts import render
from django.views.generic import TemplateView

from community.views import get_header_and_footer
from gamification.models import Participant


def index(request):
Participant.objects.filter(username__startswith='testuser').delete()
participants = Participant.objects.all()
args = {'participants': participants}
return render(request, 'gamification.html', args)
class GamificationResults(TemplateView):
template_name = 'gamification.html'

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context = get_header_and_footer(context)
context['gamification_results'] = Participant.objects.all()
return context
104 changes: 104 additions & 0 deletions static/css/gamification.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
.bottom-center {
position: absolute;
width: 100px;
bottom: 2%;
left: 50%;
transform: translate(-50%, -50%);
}

.gamifier-details {
max-width: 79%;
display: flex;
}

.gamifier-details-part-1,
.gamifier-details-part-2,
.gamifier-details-part-3 {
max-width: 44%;
max-height: 80%;
padding: 10px 5px;
}

.gamifier-card {
width: 100%;
min-height: 380px;
}

.gamifier-image {
width: 20%;
}

.gamifier-image img{
width: 90%;
margin-right: 0;
margin-left: 1%;
min-width: 100px;

}

.github-icon {
color: white;
background-color: black;
border-radius: 100px;
}

.gitlab-icon {
color: #e33834;
border-radius: 100px;
}

.filter-btn {
width: 107px;
margin-top: 3%;
margin-left: 3%;
}

.filter-btn .btn {
text-transform: none;
border-radius: 100px;
box-shadow: 0 0 25px 2px black;
}

.social-icons {
font-size: 1.5em;
}

@media only screen and (max-width: 890px){

.gamifier-card {
max-width: 100%;
width: auto;
margin: 10px;
}

.gamifier-details {
max-width: 100%;
padding: 0 10px;
}

.gamifier-image {
margin: auto;
width: 35%;
}

.bottom-center {
bottom: 2%;
}

@media only screen and (max-width: 526px){

.gamifier-details-part-3 {
display: none;
}

.gamifier-details-part-1,
.gamifier-details-part-2 {
max-width: 50%;
}

.gamifier-image {
width: 50%;
}

}
}
186 changes: 141 additions & 45 deletions templates/gamification.html
Original file line number Diff line number Diff line change
@@ -1,50 +1,146 @@
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- 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>Newcomers Data</title>
</head>
<body>
<h1>The gamification leaderboard</h1>
<p>Note: All the datetime is in UTC</p>
<hr>
<ul>
{% for participant in participants %}
<div class="container">
<div class="row">
<div class="col-sm-6 col-md-4">
<div class="thumbnail">
<div class="caption">
<p>Username: {{ participant.username }}</p>
<p><a href="//github.com/{{ participant.username }}">
GitHub Profile</a></p>
<p><a href="//gitlab.com/{{ participant.username }}">
GitLab Profile</a></p>
<p><a href="//www.openhub.net/accounts/{{ participant.username }}">OpenHub Profile</a></p>
<p>Score: {{ participant.score }}</p>
<p>Level: {{ participant.level.name }}</p>
<p>Activities Performed:
{% for activity in participant.activities.all %}
<p>{{ forloop.counter }}. {{ activity.name }}, performed_at:
{{ activity.performed_at }} updated_at: {{ activity.updated_at }}
</p>
{% endfor %}{# for activity in participant.activities.all #}
<p>Badges Earned:
{% for badge in participant.badges.all %}
<p>{{ forloop.counter }}.{{ badge.name }}</p>
{% endfor %}{# for badge in participant.badges.all #}
</p>
{% extends 'base.html' %}
{% load staticfiles %}
{% block title %}
Community | Gamification Leaderboard
{% endblock %}

{% block add_css_files %}
<link rel="stylesheet" href="{% static 'css/contributors.css' %}">
<link rel="stylesheet" href="{% static 'css/meta-reviewers.css' %}">
<link rel="stylesheet" href="{% static 'css/gamification.css' %}">
{% endblock %}

{% block add_js_files %}
<script src="{% static 'js/contributors.js' %}"></script>
{% endblock %}

{% block main-content %}

<div class="web-page-details apply-flex center-content">
<h3 style="padding-right: 15px">~</h3>
<h3 class="page-name">
Contributors Gamification Leaderboard
</h3>
<h3 style="padding-left: 15px">~</h3>
</div>

<div class="apply-flex center-content">
<p class="container web-page-description">
The leaderboard is based upon the gamification system which automates the
recognition of activities performed by community contributors. Based on activities
performed, various parameters are calculated.
</p>
</div>

<div class="contributors-section apply-flex center-content">
<div class="form-fields">
<form>
<div class="input-field apply-flex center-content search-field">
<i class="fa fa-search social-icons"></i>
<input id="search" type="search" autocomplete="off" placeholder="Search by username or name" required>
<i class="fa fa-close social-icons"></i>
</div>
</form>
<div class="search-results">
<table>
<thead>
<tr>
<th>Search Results</th>
</tr>
</thead>
<tbody class="search-results-tbody large-font">
<tr>
<td>
No results found!
</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>

<div class="contributors-cards column-flex">
{% for contributor in gamification_results %}
<div class="contributor-card meta-reviewer gamifier-card apply-flex" login="{{ contributor.username }}">
<div class="contributor-image meta-reviewer-image gamifier-image">
<img src="//github.com/{{ contributor.username }}.png/?size=400"
alt="user-image">
<div class="bottom-center large-font bold-text social-links">
<a href="//github.com/{{ contributor.username }}" target="_blank">
<i class="fa fa-github github-icon social-icons" aria-hidden="true"></i>
</a>
<a href="//gitlab.com/{{ contributor.username }}" target="_blank">
<i class="fa fa-gitlab social-icons gitlab-icon" aria-hidden="true"></i>
</a>
<a href="//www.openhub.net/accounts/{{ contributor.username }}" target="_blank" class="social-icons">OH</a>
</div>
</div>
<div class="gamifier-details">
<div class="gamifier-details-part-1 column-flex">
<div class="column-flex large-font gray-font-color">
<span>
<b>Username:</b>
{{ contributor.username }}
</span>
<span>
<b>Score:</b>
{{ contributor.score }}
</span>
<span>
<b>Level:</b>
{{ contributor.level.name }}
</span>
<div>
{% if contributor.badges.all %}
<b>Badges Earned:</b>
<div class="column-flex">
{% for badge in contributor.badges.all %}
<span>
<b>-></b>
{{ badge.name }}
</span>
{% endfor %}{# for badge in contributor.badges.all #}
</div>
{% else %}{# if contributor.badges.all #}
<span>
<b>No badges earned!<i class="fa fa-frown-o"></i></b>
</span>
{% endif %}{# if contributor.badges.all #}
</div>
<div class="column-flex">
<b>Some Activities permormed:</b>
{% for activity in contributor.activities.all|slice:":2" %}
<span>
<b>{{ forloop.counter }}.</b> {{ activity.name }}, on {{ activity.performed_at }}
</span>
{% endfor %}{# for activity in contributor.activities.all|slice:":2" #}
</div>
</div>
</div>

{% if contributor.activities.all|slice:"2:6" %}
<div class="gamifier-details-part-2 column-flex large-font gray-font-color">
{% for activity in contributor.activities.all|slice:"2:6" %}
<span>
<b>{{ forloop.counter|add:2 }}.</b> {{ activity.name }}, on {{ activity.performed_at }}
</span>
{% endfor %}{# for activity in contributor.activities.all|slice:"2:6" #}
</div>
{% endif %}{# if contributor.activities.all|slice:"2:6" #}

{% if contributor.activities.all|slice:"6:10" %}
<div class="gamifier-details-part-3 column-flex large-font gray-font-color">
{% for activity in contributor.activities.all|slice:"6:10" %}
<span>
<b>{{ forloop.counter|add:6 }}.</b> {{ activity.name }}, on: {{ activity.performed_at }}
</span>
{% endfor %}{# for activity in contributor.activities.all|slice:"6:10" #}
</div>
{% endif %}{# if contributor.activities.all|slice:"6:10" #}
</div>
<hr>
{% endfor %}{# for participant in participants #}
</ul>
</body>
</html>
</div>
{% endfor %}{# for contributor in gamification_results #}
</div>

{% endblock %}

0 comments on commit a8df35a

Please sign in to comment.