summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2017-05-04 17:21:24 +0200
committeremkael <emkael@tlen.pl>2017-05-09 02:51:09 +0200
commit01fd749e24fd6fe1a0099ec4477307ed9c25dce3 (patch)
treec63ba168598fd75a0cd0299c27c7bc206682a98b
parentbe579d2034f168e332bd203ffeb45b3eea42a3ea (diff)
Fixes for single-segment rounds
-rw-r--r--ausbutler/interface.py9
-rw-r--r--template/macros.html14
-rw-r--r--template/segment.html7
-rw-r--r--template/table.html8
4 files changed, 28 insertions, 10 deletions
diff --git a/ausbutler/interface.py b/ausbutler/interface.py
index d793bc9..052d910 100644
--- a/ausbutler/interface.py
+++ b/ausbutler/interface.py
@@ -62,14 +62,17 @@ class Interface(object):
aus_b.corrected_score = old_norm[2] if old_norm is not None else aus_b.score
aus_b.board_count = row[2]
self.session.add(aus_b)
- column_name = re.compile(r'^seg(\d+)_(\d+)$')
+ column_name = re.compile(r'^seg(\d+)(_(\d+))?$')
for butler in self.session.query(Butler).all():
for column, value in butler.__dict__.iteritems():
column_match = re.match(column_name, column)
if column_match:
if value is not None:
round_no = int(column_match.group(1), base=10)
- segm_no = int(column_match.group(2))
+ if Constants.segmentsperround > 1:
+ segm_no = int(column_match.group(3))
+ else:
+ segm_no = 1
if round_no < Constants.rnd or (
round_no == Constants.rnd and segm_no <= Constants.segm):
aus_b = AusButler()
@@ -193,6 +196,7 @@ class Interface(object):
'logoh': Constants.logoh,
'round_no': round_no,
'segment_no': segment_no,
+ 'per_round': Constants.segmentsperround,
'results': results,
'boards': range(
first_board,
@@ -273,6 +277,7 @@ class Interface(object):
'percent_threshold': Constants.minbutler,
'segments': segments,
'segment_limit': self.config['segments_in_table_limit'],
+ 'per_round': Constants.segmentsperround,
'above_threshold': above_threshold,
'below_threshold': below_threshold,
'date': datetime.now().strftime('%Y-%m-%d'),
diff --git a/template/macros.html b/template/macros.html
index 619ad2e..09cd7ea 100644
--- a/template/macros.html
+++ b/template/macros.html
@@ -18,7 +18,11 @@
{% if 'label' in segment %}
{{segment['label']}}
{% else %}
- {{segment['round']}}-{{segment['segment']}}
+ {% if per_round > 1 %}
+ {{segment['round']}}-{{segment['segment']}}
+ {% else %}
+ {{segment['round']}}
+ {% endif %}
{% endif %}
</a>
{% endfor %}
@@ -30,7 +34,7 @@
</tr>
{% endmacro %}
-{% macro table_header(segments, segment_limit, prefix) %}
+{% macro table_header(segments, segment_limit, prefix, per_round) %}
<tr>
<td class="bdcc12">{{"HEADER_PLACE"|translate}}</td>
<td class="bdcc2">&nbsp;</td>
@@ -47,7 +51,11 @@
{% if 'label' in segment %}
{{segment['label']}}
{% else %}
- {{segment['round']}}-{{segment['segment']}}
+ {% if per_round > 1 %}
+ {{segment['round']}}-{{segment['segment']}}
+ {% else %}
+ {{segment['round']}}
+ {% endif %}
{% endif %}
</a>
</td>
diff --git a/template/segment.html b/template/segment.html
index a481dcf..2401e3e 100644
--- a/template/segment.html
+++ b/template/segment.html
@@ -22,7 +22,12 @@
</tr>
{{ separator(3) }}
<tr>
- <td class="bdnt12" colspan="3">{{"BUTLER_ROUND"|translate}}{{round_no}} {{"SEGMENT"|translate}}{{segment_no}}</td>
+ <td class="bdnt12" colspan="3">
+ {{"BUTLER_ROUND"|translate}}{{round_no}}
+ {% if per_round > 1 %}
+ {{"SEGMENT"|translate}}{{segment_no}}
+ {% endif %}
+ </td>
</tr>
{{ separator(3) }}
<tr valign="top">
diff --git a/template/table.html b/template/table.html
index 4b29c79..8dceb2a 100644
--- a/template/table.html
+++ b/template/table.html
@@ -31,9 +31,9 @@
</tr>
{{ separator(segment_limit+5) }}
{% if segments|length > segment_limit %}
- {{ previous_rounds(segments, segment_limit, prefix) }}
+ {{ previous_rounds(segments, segment_limit, prefix, per_round) }}
{% endif %}
- {{ table_header(segments, segment_limit, prefix) }}
+ {{ table_header(segments, segment_limit, prefix, per_round) }}
{% for player in above_threshold %}
{{ table_player(player, segment_limit) }}
{% endfor %}
@@ -49,9 +49,9 @@
</tr>
{{ separator(segment_limit+5) }}
{% if segments|length > segment_limit %}
- {{ previous_rounds(segments, segment_limit, prefix) }}
+ {{ previous_rounds(segments, segment_limit, prefix, per_round) }}
{% endif %}
- {{ table_header(segments, segment_limit, prefix) }}
+ {{ table_header(segments, segment_limit, prefix, per_round) }}
{% for player in below_threshold %}
{{ table_player(player, segment_limit) }}
{% endfor %}