adding
This commit is contained in:
16
boatmovers/management/commands/saveranking.py
Normal file
16
boatmovers/management/commands/saveranking.py
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import sys
|
||||||
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
from django.core.management.base import BaseCommand
|
||||||
|
from boatmovers.models import Athlete, Crew, Race, Result
|
||||||
|
|
||||||
|
import pandas as pd
|
||||||
|
|
||||||
|
class Command(BaseCommand):
|
||||||
|
def handle(self, *args, **options):
|
||||||
|
athletes = Athlete.objects.filter(trueskill_exposed__gt=0,
|
||||||
|
dummy=False).order_by('-trueskill_exposed','-birth_year','last_name','first_name')
|
||||||
|
df = pd.DataFrame(athletes.values())
|
||||||
|
filename = "media/boatmovers_"+datetime.now().strftime("%Y-%m-%d")+".csv"
|
||||||
|
df.to_csv(filename)
|
||||||
81
boatmovers/templates/boatmovers_compare.html
Normal file
81
boatmovers/templates/boatmovers_compare.html
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
{% extends "boatmovers_base.html" %}
|
||||||
|
{% block main %}
|
||||||
|
<form action="" method="post">{% csrf_token %}
|
||||||
|
{{ form.as_table }}
|
||||||
|
<input type="submit" value="Compare" />
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<table width="100%" class="listtable shortpadded">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>
|
||||||
|
#
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Name
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Club
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Gender
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Rank 1
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Rank 2
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Positions Climbed
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Score 1
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Score 2
|
||||||
|
</th>
|
||||||
|
<th>
|
||||||
|
Score Increase
|
||||||
|
</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for index, row in df.iterrows %}
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
{{ forloop.counter }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ row.Name }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ row.club }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ row.gender }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ row.Rank1 }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ row.Rank2 }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ row.PositionsClimbed }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ row.Score1|floatformat:2 }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ row.Score2|floatformat:2 }}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{{ row.ScoreIncrease|floatformat:2 }}
|
||||||
|
</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user