move charLimit to settings api

This commit is contained in:
worldworm 2021-01-10 09:24:42 +00:00
parent b0645cd5d7
commit f5d249c880
2 changed files with 7 additions and 8 deletions

View file

@ -75,9 +75,6 @@ def create_app(char_limit=-1, req_limit=-1, ga_id=None, debug=False, frontend_la
name: name:
type: string type: string
description: Human-readable language name (in English) description: Human-readable language name (in English)
charLimit:
type: string
description: Character input limit for this language (-1 indicates no limit)
429: 429:
description: Slow down description: Slow down
schema: schema:
@ -88,7 +85,7 @@ def create_app(char_limit=-1, req_limit=-1, ga_id=None, debug=False, frontend_la
type: string type: string
description: Reason for slow down description: Reason for slow down
""" """
return jsonify([{'code': l.code, 'name': l.name, 'charLimit': char_limit } for l in languages]) return jsonify([{'code': l.code, 'name': l.name} for l in languages])
# Add cors # Add cors
@app.after_request @app.after_request
@ -218,6 +215,9 @@ def create_app(char_limit=-1, req_limit=-1, ga_id=None, debug=False, frontend_la
id: frontend-settings id: frontend-settings
type: object type: object
properties: properties:
charLimit:
type: integer
description: Character input limit for this language (-1 indicates no limit)
language: language:
type: object type: object
properties: properties:
@ -240,7 +240,8 @@ def create_app(char_limit=-1, req_limit=-1, ga_id=None, debug=False, frontend_la
type: string type: string
description: Human-readable language name (in English) description: Human-readable language name (in English)
""" """
return jsonify({'language': { return jsonify({'charLimit': char_limit,
'language': {
'source': {'code': frontend_argos_language_source.code, 'name': frontend_argos_language_source.name}, 'source': {'code': frontend_argos_language_source.code, 'name': frontend_argos_language_source.name},
'target': {'code': frontend_argos_language_target.code, 'name': frontend_argos_language_target.name}} 'target': {'code': frontend_argos_language_target.code, 'name': frontend_argos_language_target.name}}
}) })

View file

@ -278,7 +278,7 @@ document.addEventListener('DOMContentLoaded', function(){
self.settings = JSON.parse(this.response); self.settings = JSON.parse(this.response);
self.sourceLang = self.settings.language.source.code; self.sourceLang = self.settings.language.source.code;
self.targetLang = self.settings.language.target.code; self.targetLang = self.settings.language.target.code;
self.charactersLimit = self.settings.charLimit;
}else { }else {
self.error = "Cannot load /frontend/settings"; self.error = "Cannot load /frontend/settings";
self.loading = false; self.loading = false;
@ -305,8 +305,6 @@ document.addEventListener('DOMContentLoaded', function(){
return; return;
} }
self.charactersLimit = self.langs[0].charLimit;
self.loading = false; self.loading = false;
} else { } else {
self.error = "Cannot load /languages"; self.error = "Cannot load /languages";