API - init privacy policy
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
from datetime import datetime
|
||||
from typing import Dict, Union
|
||||
|
||||
from flask import Blueprint, current_app, request
|
||||
@ -40,6 +41,7 @@ def get_application_config() -> Union[Dict, HttpResponse]:
|
||||
|
||||
{
|
||||
"data": {
|
||||
"about": null,
|
||||
"admin_contact": "admin@example.com",
|
||||
"gpx_limit_import": 10,
|
||||
"is_email_sending_enabled": true,
|
||||
@ -48,6 +50,8 @@ def get_application_config() -> Union[Dict, HttpResponse]:
|
||||
"max_users": 0,
|
||||
"max_zip_file_size": 10485760,
|
||||
"map_attribution": "© <a href=http://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors",
|
||||
"privacy_policy": null,
|
||||
"privacy_policy_date": null,
|
||||
"version": "0.7.12",
|
||||
"weather_provider": null
|
||||
},
|
||||
@ -93,6 +97,7 @@ def update_application_config(auth_user: User) -> Union[Dict, HttpResponse]:
|
||||
|
||||
{
|
||||
"data": {
|
||||
"about": null,
|
||||
"admin_contact": "admin@example.com",
|
||||
"gpx_limit_import": 10,
|
||||
"is_email_sending_enabled": true,
|
||||
@ -101,18 +106,22 @@ def update_application_config(auth_user: User) -> Union[Dict, HttpResponse]:
|
||||
"max_users": 10,
|
||||
"max_zip_file_size": 10485760,
|
||||
"map_attribution": "© <a href=http://www.openstreetmap.org/copyright>OpenStreetMap</a> contributors",
|
||||
"privacy_policy": null,
|
||||
"privacy_policy_date": null,
|
||||
"version": "0.7.12",
|
||||
"weather_provider": null
|
||||
},
|
||||
"status": "success"
|
||||
}
|
||||
|
||||
:<json string about: instance information
|
||||
:<json string admin_contact: email to contact the administrator
|
||||
:<json integer gpx_limit_import: max number of files in zip archive
|
||||
:<json boolean is_registration_enabled: is registration enabled?
|
||||
:<json integer max_single_file_size: max size of a single file
|
||||
:<json integer max_users: max users allowed to register on instance
|
||||
:<json integer max_zip_file_size: max size of a zip archive
|
||||
:<json string privacy_policy: instance privacy policy
|
||||
|
||||
:reqheader Authorization: OAuth 2.0 Bearer Token
|
||||
|
||||
@ -151,6 +160,11 @@ def update_application_config(auth_user: User) -> Union[Dict, HttpResponse]:
|
||||
config.max_users = config_data.get('max_users')
|
||||
if 'admin_contact' in config_data:
|
||||
config.admin_contact = admin_contact if admin_contact else None
|
||||
if 'about' in config_data:
|
||||
config.about = config_data.get('about')
|
||||
if 'privacy_policy' in config_data:
|
||||
config.privacy_policy = config_data.get('privacy_policy')
|
||||
config.privacy_policy_date = datetime.utcnow()
|
||||
|
||||
if config.max_zip_file_size < config.max_single_file_size:
|
||||
return InvalidPayloadErrorResponse(
|
||||
|
@ -25,6 +25,9 @@ class AppConfig(BaseModel):
|
||||
)
|
||||
max_zip_file_size = db.Column(db.Integer, default=10485760, nullable=False)
|
||||
admin_contact = db.Column(db.String(255), nullable=True)
|
||||
privacy_policy_date = db.Column(db.DateTime, nullable=True)
|
||||
privacy_policy = db.Column(db.Text, nullable=True)
|
||||
about = db.Column(db.Text, nullable=True)
|
||||
|
||||
@property
|
||||
def is_registration_enabled(self) -> bool:
|
||||
@ -46,6 +49,7 @@ class AppConfig(BaseModel):
|
||||
def serialize(self) -> Dict:
|
||||
weather_provider = os.getenv('WEATHER_API_PROVIDER', '').lower()
|
||||
return {
|
||||
'about': self.about,
|
||||
'admin_contact': self.admin_contact,
|
||||
'gpx_limit_import': self.gpx_limit_import,
|
||||
'is_email_sending_enabled': current_app.config['CAN_SEND_EMAILS'],
|
||||
@ -54,6 +58,8 @@ class AppConfig(BaseModel):
|
||||
'max_zip_file_size': self.max_zip_file_size,
|
||||
'max_users': self.max_users,
|
||||
'map_attribution': self.map_attribution,
|
||||
'privacy_policy': self.privacy_policy,
|
||||
'privacy_policy_date': self.privacy_policy_date,
|
||||
'version': VERSION,
|
||||
'weather_provider': (
|
||||
weather_provider
|
||||
|
Reference in New Issue
Block a user