Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
website
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Container registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Roman Karwacik
website
Commits
21241569
Unverified
Commit
21241569
authored
5 years ago
by
Andreas Valder
Browse files
Options
Downloads
Patches
Plain Diff
fix most linter errors in chapters.py
parent
8f47ce02
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
chapters.py
+15
-13
15 additions, 13 deletions
chapters.py
with
15 additions
and
13 deletions
chapters.py
+
15
−
13
View file @
21241569
...
...
@@ -14,19 +14,19 @@ def import_xmp_chapters(jobid, jobtype, data, state, status):
for
chapter
in
status
.
get
(
'
xmp_chapters
'
,
[]):
if
int
(
chapter
[
'
time
'
])
in
times
:
continue
modify
(
'
INSERT INTO chapters (lecture_id, time, text, visible, time_created, time_updated) VALUES (?, ?, ?, 0, ?, ?)
'
,
modify
(
'
INSERT INTO chapters (lecture_id, time, text, visible, time_created, time_updated) VALUES (?, ?, ?, 0, ?, ?)
'
,
data
[
'
lecture_id
'
],
int
(
chapter
[
'
time
'
]),
chapter
[
'
text
'
],
datetime
.
now
(),
datetime
.
now
())
datetime
.
now
(),
datetime
.
now
()
)
@app.route
(
'
/internal/newchapter/<int:lectureid>
'
,
methods
=
[
'
POST
'
,
'
GET
'
])
def
suggest_chapter
(
lectureid
):
time
=
request
.
values
[
'
time
'
]
text
=
request
.
values
[
'
text
'
]
assert
time
and
text
assert
'
time
'
in
request
.
values
and
'
text
'
in
request
.
values
try
:
x
=
datetime
.
strptime
(
time
,
'
%H:%M:%S
'
)
time
=
timedelta
(
hours
=
x
.
hour
,
minutes
=
x
.
minute
,
seconds
=
x
.
second
).
total_seconds
()
time
=
int
(
time
)
parsed_datetime
=
datetime
.
strptime
(
request
.
values
[
'
time
'
],
'
%H:%M:%S
'
)
chapter_start
=
int
(
timedelta
(
hours
=
parsed_datetime
.
hour
,
minutes
=
parsed_datetime
.
minute
,
seconds
=
parsed_datetime
.
second
).
total_seconds
())
except
ValueError
:
if
'
ref
'
in
request
.
values
:
flash
(
'
Falsches Zeitformat,
"
%H:%M:%S
"
wird erwartet. Z.B.
"
01:39:42
"
für eine Kapitel bei Stunde 1, Minute 39, Sekunde 42
'
)
...
...
@@ -38,8 +38,10 @@ def suggest_chapter(lectureid):
submitter
=
request
.
environ
[
'
REMOTE_ADDR
'
]
lecture
=
query
(
'
SELECT * FROM lectures WHERE id = ?
'
,
lectureid
)[
0
]
course
=
query
(
'
SELECT * FROM courses WHERE id = ?
'
,
lecture
[
'
course_id
'
])[
0
]
id
=
modify
(
'
INSERT INTO chapters (lecture_id, time, text, time_created, time_updated, created_by, submitted_by) VALUES (?, ?, ?, ?, ?, ?, ?)
'
,
lectureid
,
time
,
text
,
datetime
.
now
(),
datetime
.
now
(),
session
.
get
(
'
user
'
,
{
'
dbid
'
:
None
})[
'
dbid
'
],
submitter
)
id
=
modify
(
'
INSERT INTO chapters (lecture_id, time, text, time_created, time_updated, created_by, submitted_by) VALUES (?, ?, ?, ?, ?, ?, ?)
'
,
lectureid
,
chapter_start
,
text
,
datetime
.
now
(),
datetime
.
now
(),
session
.
get
(
'
user
'
,
{
'
dbid
'
:
None
})[
'
dbid
'
],
submitter
)
chapter
=
query
(
'
SELECT * FROM chapters WHERE id = ?
'
,
id
)[
0
]
notify_mods
(
'
chapter_submitted
'
,
course
[
'
id
'
],
course
=
course
,
lecture
=
lecture
,
chapter
=
chapter
)
if
'
ref
'
in
request
.
values
:
...
...
@@ -52,10 +54,10 @@ def chapters(lectureid):
if
not
chapters
:
return
'
No chapters found
'
,
404
last
=
None
for
c
in
chapters
:
c
[
'
start
'
]
=
c
[
'
time
'
]
c
[
'
end
'
]
=
last
[
'
start
'
]
if
last
else
9999
last
=
c
for
c
hapter
in
chapters
:
c
hapter
[
'
start
'
]
=
c
hapter
[
'
time
'
]
c
hapter
[
'
end
'
]
=
last
[
'
start
'
]
if
last
else
9999
last
=
c
hapter
if
'
json
'
in
request
.
values
:
return
Response
(
json
.
dumps
([{
'
time
'
:
c
[
'
time
'
],
'
text
'
:
c
[
'
text
'
]}
for
c
in
chapters
]),
mimetype
=
'
application/json
'
)
return
Response
(
render_template
(
'
chapters.srt
'
,
chapters
=
chapters
),
200
,
{
'
Content-Type
'
:
'
text/vtt
'
})
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