Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

leaderboard widget #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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
7 changes: 4 additions & 3 deletions dashboard/citizengrid/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@ def generate_secret_key(key_file):
('admin', 'admin@localhost'),
)

EMAIL_HOST = 'automail.cc.ic.ac.uk'
EMAIL_PORT = 25
EMAIL_USE_SSL = True
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'localhost'
EMAIL_PORT = '1025'
EMAIL_USE_TLS = False
DEFAULT_FROM_EMAIL = 'Poonam Yadav <[email protected]>'
DEFAULT_INDEX_TABLESPACE = ' '
DEFAULT_TABLESPACE = ''
Expand Down
25 changes: 22 additions & 3 deletions dashboard/citizengrid/templates/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "base.html" %}

{% load leaderboard %}
{% block container-content %}

<div class="cg-header">
Expand All @@ -12,15 +12,34 @@ <h2>Register, deploy and host your volunteer computing applications</h2>

<div class="container" style="padding-top: 25px;">
<h4>CitizenGrid is a platform for application builders to host and promote their volunteer computing applications and
for users to discover these applications.</h4>
<span id="show-leaderboard">for users</span> to discover these applications.</h4>
{% if user.is_authenticated %}
<a class="btn btn-primary" href="/accounts/logout/?next=/">Sign Out</a>
{% else %}
<h4>To set up a new application or donate your spare computing power, sign up to CitizenGrid now!</h4>
<a class="btn btn-success" href="/accounts/register/">Sign Up</a>
{% endif %}
{% endif %}


</div>
<div class="container">
{% leaderboard_widget "leaderboard-home" %}
</div>

<script>
! function() {
$(document).ready(function() {
$("#leaderboard-widget").hide();
$("#show-leaderboard").click(function() {
$("#leaderboard-widget").toggle();

})

})


}()
</script>
{% endblock %}


40 changes: 40 additions & 0 deletions dashboard/citizengrid/templates/widgets/leaderboard.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

<div id="leaderboard-widget" class="panel panel-primary {{ klass }}">
<div class="panel-heading">
<h2 class="panel-title">Leaderboard</h2>
</div>
<div class="panel-body">
<div id="leaderboard-list">
<!-- -->
<table class="table table-striped">
<thead class="bg-primary">
<tr>
<th>User</th>
<th>Runs</th>
<th>Application</th>


</tr>
</thead>
{% for stat in stats %}
<tbody>
<tr>
<td>{{ stat.user }}</td>
<td>{{ stat.run_count}}</td>
<td>{{ stat.application }}</td>


</tr>
</tbody>
{% endfor %}
</table>
</div>
</div>
</div>
<style>
.leaderboard-home {

margin-top: 20px;

}
</style>
18 changes: 18 additions & 0 deletions dashboard/citizengrid/templatetags/leaderboard.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
from django import template
from citizengrid.models import UsersApplications, UserInfo
import logging


logger = logging.getLogger("django")
register = template.Library()
logger.debug("leaderboard")

@register.inclusion_tag("widgets/leaderboard.html")
def leaderboard_widget(klass):
""" widget to display user stats
usage {% leaderboard_widget "some-class" %}
some-class will be added to the classes on the container div
"""
stats = UsersApplications.objects.order_by("-run_count")
ctx = {"hi":"there","stats":stats,"klass":klass}
return ctx