Commit 7c1f3b9a authored by Hermann Krumrey's avatar Hermann Krumrey

Merge branch 'develop' into 'master'

Develop

See merge request namibsun/python/bundesliga-tippspiel!9
parents db66dcab ca889bc2
V 0.16.3:
- Added user data to api generation
V 0.16.2:
- Improved the design of the website
V 0.16.1:
......
......@@ -82,7 +82,8 @@ class ApiKeyGenAction(Action):
return {
"api_key": "{}:{}".format(api_key.id, key.decode("utf-8")),
"expiration": int(api_key.creation_time) + ApiKey.MAX_AGE
"expiration": int(api_key.creation_time) + ApiKey.MAX_AGE,
"user": user.__json__(True)
}
@classmethod
......
......@@ -19,7 +19,7 @@ LICENSE"""
from typing import Dict, Any
from flask_login import current_user, logout_user
from bundesliga_tippspiel import db
from bundesliga_tippspiel import app, db
from bundesliga_tippspiel.actions.Action import Action
from bundesliga_tippspiel.types.exceptions import ActionException
......@@ -61,9 +61,13 @@ class DeleteUserAction(Action):
:return: A JSON-compatible dictionary containing the response
:raises ActionException: if anything went wrong
"""
app.logger.info("Deleting user {}.".format(current_user.username))
db.session.delete(current_user)
db.session.commit()
app.logger.info("User {} logged out.".format(current_user.username))
logout_user()
return {}
@classmethod
......
......@@ -19,6 +19,7 @@ LICENSE"""
from typing import Dict, Any
from flask_login import login_user, current_user
from bundesliga_tippspiel import app
from bundesliga_tippspiel.types.enums import AlertSeverity
from bundesliga_tippspiel.models.auth.User import User
from bundesliga_tippspiel.types.exceptions import ActionException
......@@ -80,11 +81,17 @@ class LoginAction(Action):
if verified:
login_user(user, remember=self.remember)
app.logger.info("User {} successfully logged in."
.format(self.username))
else:
app.logger.info("Unsuccessful login attempt for user {}."
.format(self.username))
raise ActionException(
"Invalid Password",
"Das angegebene Password ist inkorrekt."
)
return {}
@classmethod
......
......@@ -18,7 +18,7 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
LICENSE"""
from flask import request, url_for, redirect, render_template
from flask_login import login_required, logout_user
from flask_login import login_required, logout_user, current_user
from bundesliga_tippspiel import app
from bundesliga_tippspiel.utils.routes import action_route
from bundesliga_tippspiel.actions.LoginAction import LoginAction
......@@ -49,5 +49,6 @@ def logout():
Logs out the user
:return:
"""
app.logger.info("User {} logged out.".format(current_user.username))
logout_user()
return redirect(url_for("index"))
......@@ -84,7 +84,9 @@ def team(team_id: int):
result = "draw"
score = "{}:{}".format(own_score, opponent_score)
match_data.append((opponent.id, opponent.short_name, score, result))
match_data.append((
opponent.id, opponent.short_name, score, result, match.id
))
players = GetPlayerAction(team_id=team_id).execute()["players"]
......
......@@ -32,7 +32,7 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
<thead class="thead-light">
<tr>
<th scope="col">Gegner</th>
{% for opponent_id, opponent_name, _, _ in matches %}
{% for opponent_id, opponent_name, _, _, _ in matches %}
<th scope="col">
<a href="{{ url_for("team", team_id=opponent_id) }}">
{{ opponent_name }}
......@@ -44,7 +44,7 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
<tbody>
<tr>
<td>Ergebnis</td>
{% for _, _, score, result in matches %}
{% for _, _, score, result, match_id in matches %}
{% if result == "win" %}
{% set result_class = "success" %}
{% elif result == "loss" %}
......@@ -52,7 +52,11 @@ along with bundesliga-tippspiel. If not, see <http://www.gnu.org/licenses/>.
{% else %}
{% set result_class = "info" %}
{% endif %}
<td class="table-{{ result_class }}">{{ score }}</td>
<td class="table-{{ result_class }}">
<a href="{{ url_for("match", match_id=match_id) }}">
{{ score }}
</a>
</td>
{% endfor %}
</tr>
</tbody>
......
......@@ -94,4 +94,5 @@ class TestApiKeyGenAction(_ActionTestFramework):
int(key.creation_time) + ApiKey.MAX_AGE,
key_data["expiration"]
)
self.assertEqual(key_data["user"], self.confirmed_user.__json__())
self.assertTrue(key.verify_key(key_data["api_key"]))
......@@ -42,12 +42,14 @@ DELETE:
POST:
* **api_key:str**: The generated API key
* **user:<User>**: The user of the API key
* **expiration:int**: The expiration timestamp as a UTC UNIX timestamp
{
"status": "ok",
"data": {
"api_key": str,
"user": <User>,
"expiration": int
}
}
......
......@@ -40,6 +40,7 @@ Examples:
* **match:<Match>**: The match that this bet was placed for
* **home_score:int**: The score bet on the home team
* **away_score:int**: The score bet on the away team
* **points:int**: The points scored by the user for this bet
* **bet:<Bet>**: A single bet, only available when specific ID was provided
......@@ -54,7 +55,8 @@ Examples:
"match_id": int,
"match": <Match>,
"home_score": int,
"away_score": int
"away_score": int,
"points": int
}
],
"bet": <Bet>
......
0.16.2
\ No newline at end of file
0.16.3
\ 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