-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Refactor punctuation/records common code
- Templates moves to subfolder
- Loading branch information
Showing
35 changed files
with
308 additions
and
372 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
from django.conf import settings | ||
from django.utils.translation import ugettext as _ | ||
|
||
|
||
def get_init_config(): | ||
return { | ||
'RECORDS': { | ||
'POLE': {'label': _('Pole'), 'filter': {'qualifying__exact': 1}}, | ||
'FIRST-ROW': {'label': _('First row'), 'filter': {'qualifying__gte': 1, 'qualifying__lte': 2}}, | ||
'COMEBACK-TO-TEN': {'label': _('Comeback to 10 firsts'), 'filter': {'qualifying__gte': 11, | ||
'finish__gte': 1, | ||
'finish__lte': 10}}, | ||
'WIN': {'label': _('Win'), 'filter': {'finish__exact': 1}}, | ||
'POLE-WIN': {'code': 'POLE-WIN', 'label': _('Pole and Win'), 'filter': {'qualifying__exact': 1, | ||
'finish__exact': 1}}, | ||
'POLE-WIN-FL': {'label': _('Pole, Win, Fastest lap'), 'filter': {'qualifying__exact': 1, | ||
'finish__exact': 1, | ||
'fastest_lap': True}}, | ||
'FASTEST': {'label': _('Fastest lap'), 'filter': {'fastest_lap': True}}, | ||
'FIRST-TWO': {'label': _('Finish 1st or 2nd'), 'filter': {'finish__gte': 1, 'finish__lte': 2}, | ||
'doubles': True}, | ||
'PODIUM': {'label': _('Podium'), 'filter': {'finish__gte': 1, 'finish__lte': 3}, 'doubles': True}, | ||
'OUT': {'label': _('OUT'), 'filter': {'retired': True}, 'doubles': True}, | ||
'CHECKERED-FLAG': {'label': _('Checkered Flag'), 'filter': {'retired': False}, 'doubles': True}, | ||
'TOP5': {'label': _('Top 5'), 'filter': {'finish__gte': 1, 'finish__lte': 5}, 'doubles': True}, | ||
'TOP10': {'code': 'TOP10', 'label': _('Top 10'), 'filter': {'finish__gte': 1, 'finish__lte': 10}, | ||
'doubles': True}, | ||
}, | ||
'PUNCTUATION': { | ||
'F1-25': {'type': 'full', 'finish': [25, 18, 15, 12, 10, 8, 6, 4, 2, 1], 'fastest_lap': 0, | ||
'label': 'F1 (25p 1st)'}, | ||
'F1-10+8': {'type': 'full', 'finish': [10, 8, 6, 4, 3, 2, 1], 'fastest_lap': 0, | ||
'label': 'F1 (10p 1st, 8p 2nd)'}, | ||
'F1-10+6': {'type': 'full', 'finish': [10, 6, 4, 3, 2, 1], 'fastest_lap': 0, | ||
'label': 'F1 (10p 1st, 6p 2nd)'}, | ||
'MotoGP': {'type': 'full', 'finish': [25, 20, 16, 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], 'fastest_lap': 0, | ||
'label': 'Moto GP'}, | ||
'MotoGP-92': {'type': 'full', 'finish': [20, 15, 12, 10, 8, 6, 4, 3, 2, 1], 'fastest_lap': 0, | ||
'label': 'Moto GP (only 1992)'}, | ||
'MotoGP-88-91': {'code': 'MotoGP-88-91', 'type': 'full', | ||
'finish': [20, 17, 15, 13, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1], 'fastest_lap': 0, | ||
'label': 'Moto GP (1988-91)'}, | ||
'MotoGP-77-87': {'type': 'full', 'finish': [15, 12, 10, 8, 6, 6, 5, 3, 2, 1], 'fastest_lap': 0, | ||
'label': 'Moto GP (1977-87)'}, | ||
} | ||
} | ||
|
||
|
||
def get_settings_config(): | ||
config_key = 'DR27_CONFIG' | ||
config = {} | ||
if hasattr(settings, config_key): | ||
config.update(getattr(settings, config_key)) | ||
return config | ||
|
||
|
||
def get_config(param, key=None): | ||
config = {} | ||
init_config = get_init_config().get(param) | ||
if init_config: | ||
config.update(init_config) | ||
settings_config = get_settings_config().get(param) | ||
if settings_config: | ||
config.update(settings_config) | ||
if key: | ||
return config.get(key, None) | ||
return config |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,13 @@ | ||
from django.conf import settings | ||
from .config import get_config | ||
|
||
DRIVER27_PUNCTUATION = [ | ||
{ | ||
'code': 'F1-25', | ||
'type': 'full', | ||
'finish': [25,18,15,12,10,8,6,4,2,1], | ||
'fastest_lap': 0, | ||
'label': 'F1 (25p 1st)' | ||
}, | ||
{ | ||
'code': 'F1-10+8', | ||
'type': 'full', | ||
'finish': [10, 8, 6, 4, 3, 2, 1], | ||
'fastest_lap': 0, | ||
'label': 'F1 (10p 1st, 8p 2nd)' | ||
}, | ||
{ | ||
'code': 'F1-10+6', | ||
'type': 'full', | ||
'finish': [10, 6, 4, 3, 2, 1], | ||
'fastest_lap': 0, | ||
'label': 'F1 (10p 1st, 6p 2nd)' | ||
}, | ||
{ | ||
'code': 'MotoGP', | ||
'type': 'full', | ||
'finish': [25,20,16,13,11,10,9,8,7,6,5,4,3,2,1], | ||
'fastest_lap': 0, | ||
'label': 'Moto GP' | ||
}, | ||
{ | ||
'code': 'MotoGP-92', | ||
'type': 'full', | ||
'finish': [20,15,12,10,8,6,4,3,2,1], | ||
'fastest_lap': 0, | ||
'label': 'Moto GP (only 1992)' | ||
}, | ||
{ | ||
'code': 'MotoGP-88-91', | ||
'type': 'full', | ||
'finish': [20,17,15,13,11,10,9,8,7,6,5,4,3,2,1], | ||
'fastest_lap': 0, | ||
'label': 'Moto GP (1988-91)' | ||
}, | ||
{ | ||
'code': 'MotoGP-77-87', | ||
'type': 'full', | ||
'finish': [15,12,10,8,6,6,5,3,2,1], | ||
'fastest_lap': 0, | ||
'label': 'Moto GP (1977-87)' | ||
} | ||
] | ||
|
||
DRIVER27_PUNCTUATION_EXTEND = getattr(settings, 'DRIVER27_PUNCTUATION', None) | ||
if DRIVER27_PUNCTUATION_EXTEND: | ||
DRIVER27_PUNCTUATION.extend(DRIVER27_PUNCTUATION_EXTEND) | ||
def get_punctuation_config(punctuation_code=None): | ||
config = get_config('PUNCTUATION', key=punctuation_code) | ||
return config | ||
|
||
|
||
def get_punctuation_label_dict(): | ||
config = get_punctuation_config() | ||
if config: | ||
return [(punctuation_dict.get('label'), index) for index, punctuation_dict in config.items()] | ||
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from .config import get_config | ||
|
||
|
||
def get_record_config(record_code=None): | ||
config = get_config('RECORDS', key=record_code) | ||
return config | ||
|
||
|
||
def get_record_label_dict(): | ||
config = get_record_config() | ||
if config: | ||
return [(record_dict.get('label'), index) for index, record_dict in config.items()] | ||
return None |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
76 changes: 38 additions & 38 deletions
76
.../templates/driver27/competition-view.html → ...river27/competition/competition-view.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
{% extends 'driver27/base.html' %} | ||
{% load bootstrap3 champion_filter i18n %} | ||
|
||
{% block dr27_menu %} | ||
{{ block.super }} | ||
<li class="nav-item"> | ||
<a class="nav-link" href="{% url 'competition-view' competition.slug %}">{{ competition }}</a> | ||
</li> | ||
{% endblock %} | ||
|
||
{% block dr27_content %} | ||
{{ block.super }} | ||
<table class="table table-condensed table-striped table-hover"> | ||
<tr> | ||
<th class="col-md-2">{% trans 'Season' %}</th> | ||
<th class="col-md-4">{% trans 'Driver leader' %}</th> | ||
<th class="col-md-6">{% trans 'Team leader' %}</th> | ||
</tr> | ||
{% for season in competition.seasons.all %} | ||
<tr> | ||
<td> | ||
<a href="{% url 'season-view' competition.slug season.year %}"> | ||
{{ season }} | ||
</a> | ||
</td> | ||
<td> | ||
{{ season.pk | champion_filter | safe}} | ||
{{ season.leader.0 }} {{ season.leader.1 }} ({{ season.leader.2 }}) | ||
</td> | ||
<td> | ||
{{ season.team_leader.0 }} {{ season.team_leader.1 }} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
|
||
|
||
{% endblock %} | ||
{% extends 'driver27/base.html' %} | ||
{% load bootstrap3 champion_filter i18n %} | ||
|
||
{% block dr27_menu %} | ||
{{ block.super }} | ||
<li class="nav-item"> | ||
<a class="nav-link" href="{% url 'competition-view' competition.slug %}">{{ competition }}</a> | ||
</li> | ||
{% endblock %} | ||
|
||
{% block dr27_content %} | ||
{{ block.super }} | ||
<table class="table table-condensed table-striped table-hover"> | ||
<tr> | ||
<th class="col-md-2">{% trans 'Season' %}</th> | ||
<th class="col-md-4">{% trans 'Driver leader' %}</th> | ||
<th class="col-md-6">{% trans 'Team leader' %}</th> | ||
</tr> | ||
{% for season in competition.seasons.all %} | ||
<tr> | ||
<td> | ||
<a href="{% url 'season-view' competition.slug season.year %}"> | ||
{{ season }} | ||
</a> | ||
</td> | ||
<td> | ||
{{ season.pk | champion_filter | safe}} | ||
{{ season.leader.0 }} {{ season.leader.1 }} ({{ season.leader.2 }}) | ||
</td> | ||
<td> | ||
{{ season.team_leader.0 }} {{ season.team_leader.1 }} | ||
</td> | ||
</tr> | ||
{% endfor %} | ||
</table> | ||
|
||
|
||
{% endblock %} |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.