Commit db66dcab authored by Hermann Krumrey's avatar Hermann Krumrey

Merge branch 'develop' into 'master'

Develop

See merge request namibsun/python/bundesliga-tippspiel!8
parents ee000abf 9ad3fcce
V 0.16.2:
- Improved the design of the website
V 0.16.1:
- Fixed email reminders
V 0.16.0:
......
......@@ -125,6 +125,55 @@ class Match(ModelMixin, db.Model):
Indicates whether or not the match has finished yet
"""
@property
def minute_display(self) -> str:
"""
This generates a string for displaying the current match minute.
Sadly, since OpenligaDB does not provide information on the current
minute, this can only offer an approcimation.
:return: A formatted string displaying the current match minute
"""
delta = (datetime.utcnow() - self.kickoff_datetime).total_seconds()
delta = int(delta / 60)
print(delta)
if self.finished:
return "Ende"
elif 0 <= delta <= 44:
return "{}.".format(delta + 1)
elif 45 <= delta < 47: # buffer for ET
return "45."
elif 47 <= delta <= 64:
return "HZ"
elif 65 <= delta <= 109:
return "{}.".format(delta - 65 + 1 + 45)
elif delta >= 110:
return "90."
else:
return "-"
@property
def current_score(self) -> str:
"""
:return: The current score formatted as a string
"""
return "{}:{}".format(self.home_current_score, self.away_current_score)
@property
def ht_score(self) -> str:
"""
:return: The half time score formatted as a string
"""
return "{}:{}".format(self.home_ht_score, self.away_ht_score)
@property
def ft_score(self) -> str:
"""
:return: The full time score formatted as a string
"""
return "{}:{}".format(self.home_ft_score, self.away_ft_score)
@property
def kickoff_datetime(self) -> datetime:
"""
......
......@@ -19,11 +19,17 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
/* Basic Structure */
table {
table-layout: fixed;
overflow: hidden;
}
html, body {
margin:0;
padding:0;
height:100%;
background: lightgray;
background: url(background.jpg) repeat #49c14e;
background-size: cover;
}
footer {
......@@ -44,7 +50,7 @@ footer a {
#body {
padding-bottom: 60px; /* Height of the footer */
margin: 0 auto;
width: 80%;
/*width: 80%;*/
min-height: calc(100vh - 100px);
}
......@@ -61,7 +67,7 @@ footer a {
padding-bottom: 20px;
padding-left: 3em;
padding-right: 3em;
background: darkgray;
background: #f8f9fa;
min-height: calc(100vh - 60px);
margin-bottom: -20px;
}
......@@ -113,7 +119,7 @@ p {
}
.form-container {
background: lightgray;
background: #d7f2d8;
padding: 20px;
border-radius: 10px
}
......@@ -142,14 +148,30 @@ p {
background: white;
}
.match_logo {
.match-logo {
max-height: 40px;
}
.match_header {
.match-header {
padding-top: 30px;
background: white;
border-radius: 15px;
border: 3px solid black;
}
.match-header-goal-display-wrapper {
text-align: center;
}
.match-header-goal-display {
display: inline-block;
background: white;
padding-left: 15px;
padding-right: 15px;
border-top-left-radius: 2px;
border-top-right-radius: 2px;
font-size: 15pt;
border: 1px solid black;
}
.goal-icon-normal {
......@@ -166,4 +188,4 @@ p {
.team-page-logo {
height: 150px;
}
\ No newline at end of file
}
......@@ -26,7 +26,7 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
<h1>
{% if matchday > 1 %}
<a href="{{ "{}/{}".format(url_for("bets"), matchday - 1) }}">
<
<i class="fas fa-arrow-left"></i>
</a>
{% endif %}
</h1>
......@@ -38,7 +38,7 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
<h1>
{% if matchday < 34 %}
<a href="{{ "{}/{}".format(url_for("bets"), matchday + 1) }}">
>
<i class="fas fa-arrow-right"></i>
</a>
{% endif %}
</h1>
......
......@@ -19,10 +19,20 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
{% extends "components/base_layout.html" %}
{% block body %}
<div class="row match_header text-center">
<div class="container match-header-goal-display-wrapper">
<div class="match-header-goal-display">
{{ match.current_score }}
</div>
<div class="match-header-goal-display">
{{ match.minute_display }}
</div>
</div>
<div class="row match-header text-center">
<div class="col-md-1">
<a href="{{ url_for("team", team_id=match.home_team.id) }}">
<img src="{{ match.home_team.icon_svg }}" class="match_logo">
<img src="{{ match.home_team.icon_svg }}" class="match-logo">
</a>
</div>
<div class="col-md-4">
......@@ -38,12 +48,14 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
</div>
<div class="col-md-1">
<a href="{{ url_for("team", team_id=match.away_team.id) }}">
<img src="{{ match.away_team.icon_svg }}" class="match_logo">
<img src="{{ match.away_team.icon_svg }}" class="match-logo">
</a>
</div>
</div>
<br>
<hr>
<h2>Tore</h2>
<table class="table table-striped table-bordered text-center">
<thead class="thead-light">
......@@ -96,7 +108,9 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
</tbody>
</table>
<br>
<hr>
<h2>Tipps</h2>
<table class="table table-striped table-bordered text-center">
<thead class="thead-light">
......
......@@ -24,7 +24,9 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
<div class="container text-center">
<img src="{{ team.icon_svg }}" class="team-page-logo">
</div>
<br>
<hr>
<h3>Tendenz</h3>
<table class="table table-striped table-bordered text-center leaderboard-table">
<thead class="thead-light">
......@@ -55,7 +57,9 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
</tr>
</tbody>
</table>
<br>
<hr>
<h3>Torschützen</h3>
<table class="table table-striped table-bordered text-center leaderboard-table">
<thead class="thead-light">
......
......@@ -21,6 +21,8 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
{% block body %}
<h1>{{ username }}</h1>
<hr>
<h2>Passwort ändern</h2>
<div class="container form-container">
......@@ -59,7 +61,7 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
</form>
</div>
<br>
<hr>
<h2>Email Erinnerungen</h2>
......@@ -96,6 +98,8 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
</form>
</div>
<hr>
<h2>Account löschen</h2>
<div class="container form-container">
......
......@@ -22,13 +22,38 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
<h1>Tippspiel zur Bundesliga Saison 2018/19</h1>
<p>
Beim Bundesliga Tippspiel kannst du dein Fußballwissen (und dein Glück)
mit deinen Freunden messen! Hast du bereits ein Account, kannst du
dich mithilfe der Anmeldefunktion
<a href="{{ url_for("login") }}">hier</a>
anmelden, ansonsten kannst du dich
<a href="{{ url_for("register") }}">hier</a>
registrieren.
mit deinen Freunden messen!
</p>
{% if current_user.is_authenticated %}
<p>
Um zu tippen, besuche die
<a href="{{ url_for("bets") }}">Spieltag</a>
Seite.
</p>
<p>
Eine Rangliste aller Spieler kann man auf der
<a href="{{ url_for("leaderboard") }}">Rangliste</a>
Seite einsehen.
</p>
<p>
Um Änderungen an deinem Profil vorzunehmen, kannst du die
<a href="{{ url_for("profile") }}">Profile</a>
Seite benutzen.
</p>
{% else %}
<p>
Hast du bereits ein Account, kannst du
dich mithilfe der Anmeldefunktion
<a href="{{ url_for("login") }}">hier</a>
anmelden, ansonsten kannst du dich
<a href="{{ url_for("register") }}">hier</a>
registrieren.
</p>
{% endif %}
<hr>
<h3>Punktevergabe</h3>
<p>Punkte werden wie folgt vergeben:</p>
<ul>
......
......@@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License
along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
from datetime import datetime
from datetime import datetime, timedelta
from bundesliga_tippspiel.models.match_data.Match import Match
# noinspection PyProtectedMember
from bundesliga_tippspiel.test.models.ModelTestFramework import \
......@@ -138,3 +138,50 @@ class TestMatch(_ModelTestFramework):
self.match.kickoff = "2018-01-02:22-30-00"
date = datetime(year=2018, month=1, day=2, hour=22, minute=30)
self.assertEqual(date, self.match.kickoff_datetime)
def test_minute_representation(self):
"""
Tests the representation of the current minute of the match
:return: None
"""
now = datetime.utcnow()
match = Match(finished=True, kickoff=now.strftime("%Y-%m-%d:%H-%M-%S"))
self.assertEqual(match.minute_display, "Ende")
match.finished = False
match.kickoff = (now + timedelta(days=1)).strftime("%Y-%m-%d:%H-%M-%S")
self.assertEqual(match.minute_display, "-")
match.kickoff = (now - timedelta(days=1)).strftime("%Y-%m-%d:%H-%M-%S")
self.assertEqual(match.minute_display, "90.")
match.kickoff = (now - timedelta(minutes=20))\
.strftime("%Y-%m-%d:%H-%M-%S")
self.assertEqual(match.minute_display, "21.")
match.kickoff = (now - timedelta(minutes=46)) \
.strftime("%Y-%m-%d:%H-%M-%S")
self.assertEqual(match.minute_display, "45.")
match.kickoff = (now - timedelta(minutes=50)) \
.strftime("%Y-%m-%d:%H-%M-%S")
self.assertEqual(match.minute_display, "HZ")
match.kickoff = (now - timedelta(minutes=80)) \
.strftime("%Y-%m-%d:%H-%M-%S")
self.assertEqual(match.minute_display, "61.")
def test_score_representations(self):
"""
Tests the score representation attributes
:return: None
"""
match = Match(
home_ht_score=0, away_ht_score=1,
home_ft_score=2, away_ft_score=3,
home_current_score=4, away_current_score=5
)
self.assertEqual(match.ht_score, "0:1")
self.assertEqual(match.ft_score, "2:3")
self.assertEqual(match.current_score, "4:5")
0.16.1
\ No newline at end of file
0.16.2
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment