Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
ptb-subtitle-service
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container registry
Model registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Hartig
ptb-subtitle-service
Commits
e218adb4
Commit
e218adb4
authored
1 year ago
by
Jan Hartig
Browse files
Options
Downloads
Patches
Plain Diff
Add default language configuration
parent
e33ed593
No related branches found
No related tags found
1 merge request
!4
Merge new features and fixes
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
app.py
+1
-2
1 addition, 2 deletions
app.py
config.example.toml
+1
-0
1 addition, 0 deletions
config.example.toml
forms.py
+4
-4
4 additions, 4 deletions
forms.py
routes.py
+3
-3
3 additions, 3 deletions
routes.py
with
9 additions
and
9 deletions
app.py
+
1
−
2
View file @
e218adb4
...
...
@@ -26,8 +26,7 @@ def create_app():
for
language
in
app
.
config
[
"
ENABLED_LOCALISATIONS
"
]:
check_localisation
(
app
.
logger
,
app
.
config
[
"
LOCALISATIONS
"
],
language
)
del
language
del
language
app
.
logger
.
info
(
"
Localisations loaded.
"
)
...
...
This diff is collapsed.
Click to expand it.
config.example.toml
+
1
−
0
View file @
e218adb4
...
...
@@ -3,6 +3,7 @@ UPLOAD_FOLDER = "uploads"
MAX_CONTENT_LENGTH
=
10
# in GB
ENABLED_LOCALISATIONS
=
[
"de"
,
"en"
]
DEFAULT_LANGUAGE
=
"de"
[ CONTACT ]
ORG
=
"Fun Inc."
...
...
This diff is collapsed.
Click to expand it.
forms.py
+
4
−
4
View file @
e218adb4
...
...
@@ -19,7 +19,7 @@ def validate_audio(_, field):
if
not
has_audio
:
raise
ValidationError
(
"
noaudiotrack
"
)
except
av
.
AVError
as
e
:
current_app
.
logger
.
error
(
current_app
.
logger
.
info
(
"
Error while checking audio of file
'
{}
'
: {}
"
.
format
(
file
.
filename
,
str
(
e
))
)
raise
ValidationError
(
"
brokenfile
"
)
...
...
@@ -27,15 +27,15 @@ def validate_audio(_, field):
class
UploadForm
(
FlaskForm
):
email
=
StringField
(
current_app
.
config
[
"
LOCALISATIONS
"
][
"
email
"
][
"
label
"
][
"
de
"
],
current_app
.
config
[
"
LOCALISATIONS
"
][
"
email
"
][
"
label
"
][
current_app
.
config
[
"
DEFAULT_LANGUAGE
"
]
],
validators
=
[
InputRequired
(
"
invalidEmail
"
),
Email
(
"
invalidEmail
"
)],
)
language
=
SelectField
(
current_app
.
config
[
"
LOCALISATIONS
"
][
"
language
"
][
"
label
"
][
"
de
"
],
current_app
.
config
[
"
LOCALISATIONS
"
][
"
language
"
][
"
label
"
][
current_app
.
config
[
"
DEFAULT_LANGUAGE
"
]
],
validators
=
[
InputRequired
(
"
required
"
)],
)
file
=
FileField
(
current_app
.
config
[
"
LOCALISATIONS
"
][
"
file
"
][
"
label
"
][
"
de
"
],
current_app
.
config
[
"
LOCALISATIONS
"
][
"
file
"
][
"
label
"
][
current_app
.
config
[
"
DEFAULT_LANGUAGE
"
]
],
validators
=
[
FileRequired
(
"
nofile
"
),
FileSize
(
current_app
.
config
[
"
MAX_CONTENT_LENGTH
"
]),
...
...
This diff is collapsed.
Click to expand it.
routes.py
+
3
−
3
View file @
e218adb4
...
...
@@ -2,10 +2,10 @@ import json
from
os
import
path
,
makedirs
from
uuid
import
uuid4
import
av
from
flask
import
current_app
,
render_template
,
abort
,
url_for
,
redirect
,
request
,
stream_with_context
from
forms
import
UploadForm
import
av
@current_app.route
(
"
/upload/<string:language>
"
,
methods
=
[
"
GET
"
,
"
POST
"
])
...
...
@@ -75,7 +75,7 @@ def upload(language: str):
if
form
.
email
.
data
:
form
.
email
.
data
=
form
.
email
.
data
[:
-
7
]
if
language
!=
"
de
"
:
if
language
!=
current_app
.
config
[
"
DEFAULT_LANGUAGE
"
]
:
form
.
email
.
label
.
text
=
current_app
.
config
[
"
LOCALISATIONS
"
][
"
email
"
][
"
label
"
][
language
]
form
.
language
.
label
.
text
=
current_app
.
config
[
"
LOCALISATIONS
"
][
"
language
"
][
"
label
"
][
language
]
form
.
file
.
label
.
text
=
current_app
.
config
[
"
LOCALISATIONS
"
][
"
file
"
][
"
label
"
][
language
]
...
...
@@ -86,7 +86,7 @@ def upload(language: str):
@current_app.route
(
"
/
"
)
@current_app.route
(
"
/upload/
"
)
def
default
():
return
redirect
(
url_for
(
"
upload
"
,
language
=
"
de
"
))
return
redirect
(
url_for
(
"
upload
"
,
language
=
current_app
.
config
[
"
DEFAULT_LANGUAGE
"
]
))
def
set_language
(
language
):
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment