-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added impersonate button, improved rides page
- Loading branch information
1 parent
b4aa75d
commit 93009c6
Showing
4 changed files
with
51 additions
and
43 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ | |
url_for, | ||
) | ||
from freezing.model import meta | ||
from freezing.model.orm import Ride, RidePhoto | ||
from freezing.model.orm import Athlete, Ride, RidePhoto | ||
from sqlalchemy import text | ||
from stravalib import Client | ||
|
||
|
@@ -276,21 +276,34 @@ def authorization(): | |
"127.0.0.1", | ||
]: | ||
# if config.ENVIRONMENT == "localdev": | ||
# Cheat and pretend we're authorized | ||
athlete_id = int(request.args.get("athlete_id", 2332659)) | ||
log.warning( | ||
f"Local development login bypass exercised for athlete {athlete_id}" | ||
) | ||
|
||
class MockAthlete: | ||
firstname: str = "Ferd" | ||
lastname: str = "Berferd" | ||
profile_medium: str = "/img/logo-blue-sm.png" | ||
email: str = "[email protected]" | ||
|
||
def __init__(self, athlete_id: int): | ||
def __init__(self, athlete_id: int, firstname: str, lastname: str): | ||
self.id = athlete_id | ||
|
||
# Cheat and pretend we're authorized | ||
athlete_id = int(request.args.get("athlete_id", 2332659)) | ||
log.warning( | ||
f"Local development login bypass exercised for athlete {athlete_id}" | ||
self.firstname = firstname | ||
self.lastname = lastname | ||
|
||
athlete = ( | ||
meta.scoped_session() | ||
.query(Athlete) | ||
.filter(Athlete.id == athlete_id) | ||
.first() | ||
) | ||
strava_athlete = MockAthlete( | ||
athlete_id, | ||
athlete.display_name.split(" ")[0], | ||
athlete.display_name.split(" ")[:0], | ||
) | ||
strava_athlete = MockAthlete(athlete_id) | ||
message = "Local development enabled" | ||
else: | ||
code = request.args.get("code") | ||
|
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