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 #260
  • Loading branch information
KVGarg committed Jun 15, 2019
1 parent f5e7100 commit 0bde2e1
Show file tree
Hide file tree
Showing 5 changed files with 226 additions and 56 deletions.
4 changes: 2 additions & 2 deletions community/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from twitter.view_twitter import index as twitter_index
from log.view_log import index as log_index
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 @@ -206,7 +206,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)
19 changes: 13 additions & 6 deletions gamification/views.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from django.shortcuts import render
from django.views.generic import TemplateView
from django.db.models import Q

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)
participants = Participant.objects.all().exclude(
Q(username__startswith='testuser'))
context['gamification_results'] = participants
return context
71 changes: 71 additions & 0 deletions static/css/gamification.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
.bottom-center {
position: absolute;
bottom: 2%;
left: 50%;
transform: translate(-50%, -50%);
}

.contributor-details-part-1,
.contributor-details-part-2,
.contributor-details-part-3 {
width: 25%;
max-height: 80%;
overflow: auto;
overflow-wrap: break-word;
}

.contributor-details-part-3 {
padding-left: 5px;
border-left: 1px #37474f solid;
}

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

.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: 0px 0px 25px 2px black;
}

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

@media only screen and (max-width: 1107px){
.contributor-details-part-2 {
width: 29%;
}
.contributor-details-part-3 {
display: none;
}
@media only screen and (max-width: 693px){
.contributor-details-part-1,
.contributor-details-part-2 {
width: 31%;
}

.bottom-center {
bottom: -57%;
}
}
}
186 changes: 139 additions & 47 deletions templates/gamification.html
Original file line number Diff line number Diff line change
@@ -1,50 +1,142 @@
<!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>
</div>
</div>
{% 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>
<script src="{% static 'js/gamification.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">
<img src="//github.com/{{ contributor.username }}.png/?size=210">
<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="contributor-details-part-1 column-flex">
<span class="bold-text large-font">
{{ contributor.username }}
</span>
<div class="column-flex large-font gray-font-color">
<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:":1" %}
<span>
<b>{{ forloop.counter }}.</b> {{ activity.name }}, performed-on: {{ activity.performed_at }}
</span>
{% endfor %}{# for activity in contributor.activities.all|slice:":1" #}
</div>
</div>
<hr>
{% endfor %}{# for participant in participants #}
</ul>
</body>
</html>
</div>
{% if contributor.activities.all|slice:"1:4" %}
<div class="contributor-details-part-2 column-flex large-font gray-font-color">
{% for activity in contributor.activities.all|slice:"1:4" %}
<span>
<b>{{ forloop.counter|add:1 }}.</b> {{ activity.name }}, performed-on: {{ activity.performed_at }}
</span>
{% endfor %}{# for activity in contributor.activities.all|slice:"1:4" #}
</div>
{% endif %}{# if contributor.activities.all|slice:"1:4" #}
{% if contributor.activities.all|slice:"4:7" %}
<div class="contributor-details-part-3 column-flex large-font gray-font-color">
{% for activity in contributor.activities.all|slice:"4:7" %}
<span>
<b>{{ forloop.counter|add:4 }}.</b> {{ activity.name }}, performed-on: {{ activity.performed_at }}
</span>
{% endfor %}{# for activity in contributor.activities.all|slice:"4:7" #}
</div>
{% endif %}{# if contributor.activities.all|slice:"4:7" #}
</div>
{% endfor %}{# for contributor in gamification_results #}
</div>

{% endblock %}

0 comments on commit 0bde2e1

Please sign in to comment.