Compare commits
No commits in common. "7cd43ca35f1f4847f1ba26e9b2af6076776c9746" and "e36ca2b146c570196a934769ecc94f50ec9a3cb7" have entirely different histories.
7cd43ca35f
...
e36ca2b146
|
@ -1,30 +0,0 @@
|
|||
{% extends 'base.html' %}
|
||||
{% load i18n %}
|
||||
{% block content %}
|
||||
{% load key_value %}
|
||||
<div class="row">
|
||||
<div class="col-12">
|
||||
<div>
|
||||
<h4>Scoreboard</h4>
|
||||
<table class="table table-dark">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">{% trans "Rank" %}</th>
|
||||
<th scope="col">{% trans "Campus" %}</th>
|
||||
<th scope="col">{% trans "Score" %}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for name, score in scores.items %}
|
||||
<tr>
|
||||
<th scope="row"># {{ forloop.counter0|add:1 }}</th>
|
||||
<th><a class="profile_link {{is_member}}" href="{% url 'scoreboard:campus' campus=name %}"> {{ name }}</a></th>
|
||||
<td>{{ score}}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -4,7 +4,6 @@ from . import views
|
|||
app_name = "scoreboard"
|
||||
|
||||
urlpatterns = [
|
||||
path('', views.scoreboard, name='main'),
|
||||
path('campus/<str:campus>', views.campus, name='campus'),
|
||||
path('network/', views.network, name='network')
|
||||
path('', views.scoreboard, name='scoreboard'),
|
||||
path('campus/<str:campus>', views.campus, name='campus')
|
||||
]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
from django.shortcuts import render
|
||||
from django.core.paginator import Paginator
|
||||
from accounts.models import UserProfileInfo, Campus
|
||||
from accounts.models import UserProfileInfo
|
||||
|
||||
def scoreboard(request):
|
||||
scores = UserProfileInfo.objects.filter(score__gt=0).select_related().order_by('-score', 'last_submission_date', 'user__username')
|
||||
|
@ -16,15 +16,4 @@ def campus(request, campus):
|
|||
scores_p = paginator.get_page(page)
|
||||
return render(request, 'scoreboard/scoreboard.html', {'scores':scores_p})
|
||||
|
||||
def network(request):
|
||||
campuses = Campus.objects.all()
|
||||
scores = {}
|
||||
|
||||
for campus in campuses:
|
||||
users = UserProfileInfo.objects.filter(score__gt=0, campus__name__exact=campus).select_related().order_by('-score', 'last_submission_date', 'user__username')[:10]
|
||||
scores[campus] = sum([u.score for u in users])
|
||||
|
||||
sorted_scores = {k: v for k, v in sorted(scores.items(), key=lambda item: item[1], reverse=True)}
|
||||
return render(request, 'scoreboard/network.html', {'scores':sorted_scores})
|
||||
|
||||
# Create your views here.
|
||||
|
|
|
@ -58,26 +58,20 @@
|
|||
</div>
|
||||
</li>
|
||||
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{% trans "Scoreboard" %}
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<a class="dropdown-item" href="{% url 'scoreboard:main' %}">{% trans "Main" %}</a>
|
||||
<a class="dropdown-item" href="{% url 'scoreboard:network' %}">{% trans "42 Network" %}</a>
|
||||
</div>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'scoreboard:scoreboard' %}">{% translate "Scoreboard" %}</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="{% url 'events:events' %}">{% translate "Events" %}</a>
|
||||
</li>
|
||||
<li class="nav-item dropdown">
|
||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
{% trans "Resources" %}
|
||||
Resources
|
||||
</a>
|
||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<a class="dropdown-item" href="{% url 'resources:about' %}">{% trans "About"%}</a>
|
||||
<a class="dropdown-item" href="{% url 'resources:howToStart' %}">{% trans "How To Start" %}</a>
|
||||
<a class="dropdown-item" href="{% url 'resources:contribute' %}">{% trans "Contribute" %}</a>
|
||||
<a class="dropdown-item" href="{% url 'resources:about' %}">About</a>
|
||||
<a class="dropdown-item" href="{% url 'resources:howToStart' %}">How To Start</a>
|
||||
<a class="dropdown-item" href="{% url 'resources:contribute' %}">Contribute</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue