forked from 42CTF/website
Compare commits
No commits in common. "0f64c7579c0bf4493a7014c793fe504fd1cc6475" and "02331beff4a1b51df5d78df48486732218c682f0" have entirely different histories.
0f64c7579c
...
02331beff4
|
@ -1,29 +0,0 @@
|
||||||
{% extends 'base.html' %}
|
|
||||||
{% load i18n %}
|
|
||||||
{% block content %}
|
|
||||||
<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 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"
|
app_name = "scoreboard"
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('', views.scoreboard, name='main'),
|
path('', views.scoreboard, name='scoreboard'),
|
||||||
path('campus/<str:campus>', views.campus, name='campus'),
|
path('campus/<str:campus>', views.campus, name='campus')
|
||||||
path('network/', views.network, name='network')
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from accounts.models import UserProfileInfo, Campus
|
from accounts.models import UserProfileInfo
|
||||||
|
|
||||||
def scoreboard(request):
|
def scoreboard(request):
|
||||||
scores = UserProfileInfo.objects.filter(score__gt=0).select_related().order_by('-score', 'last_submission_date', 'user__username')
|
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)
|
scores_p = paginator.get_page(page)
|
||||||
return render(request, 'scoreboard/scoreboard.html', {'scores':scores_p})
|
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.
|
# Create your views here.
|
||||||
|
|
|
@ -60,26 +60,20 @@
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="nav-item dropdown">
|
<li class="nav-item">
|
||||||
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
<a class="nav-link" href="{% url 'scoreboard:scoreboard' %}">{% translate "Scoreboard" %}</a>
|
||||||
{% 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>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="{% url 'events:events' %}">{% translate "Events" %}</a>
|
<a class="nav-link" href="{% url 'events:events' %}">{% translate "Events" %}</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item dropdown">
|
<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">
|
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
{% trans "Resources" %}
|
Resources
|
||||||
</a>
|
</a>
|
||||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
<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:about' %}">About</a>
|
||||||
<a class="dropdown-item" href="{% url 'resources:howToStart' %}">{% trans "How To Start" %}</a>
|
<a class="dropdown-item" href="{% url 'resources:howToStart' %}">How To Start</a>
|
||||||
<a class="dropdown-item" href="{% url 'resources:contribute' %}">{% trans "Contribute" %}</a>
|
<a class="dropdown-item" href="{% url 'resources:contribute' %}">Contribute</a>
|
||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in New Issue