API - return weather api provider in app config route

This commit is contained in:
Sam
2022-12-28 11:43:36 +01:00
parent 52d31a68db
commit cd66952db9
3 changed files with 44 additions and 5 deletions

View File

@ -47,8 +47,9 @@ def get_application_config() -> Union[Dict, HttpResponse]:
"max_single_file_size": 1048576,
"max_users": 0,
"max_zip_file_size": 10485760,
"map_attribution": "&copy; <a href=http://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors"
"version": "0.7.10"
"map_attribution": "&copy; <a href=http://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors",
"version": "0.7.10",
"weather_provider": "darksky"
},
"status": "success"
}
@ -99,8 +100,9 @@ def update_application_config(auth_user: User) -> Union[Dict, HttpResponse]:
"max_single_file_size": 1048576,
"max_users": 10,
"max_zip_file_size": 10485760,
"map_attribution": "&copy; <a href=http://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors"
"version": "0.7.10"
"map_attribution": "&copy; <a href=http://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors",
"version": "0.7.10",
"weather_provider": "darksky"
},
"status": "success"
}

View File

@ -1,3 +1,4 @@
import os
from typing import Dict
from flask import current_app
@ -43,6 +44,7 @@ class AppConfig(BaseModel):
return current_app.config['TILE_SERVER']['ATTRIBUTION']
def serialize(self) -> Dict:
weather_provider = os.getenv('WEATHER_API_PROVIDER', '').lower()
return {
'admin_contact': self.admin_contact,
'gpx_limit_import': self.gpx_limit_import,
@ -53,6 +55,11 @@ class AppConfig(BaseModel):
'max_users': self.max_users,
'map_attribution': self.map_attribution,
'version': VERSION,
'weather_provider': (
weather_provider
if weather_provider in ['darksky', 'visualcrossing']
else None
),
}