Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Roman Karwacik
website
Commits
a7608db6
Commit
a7608db6
authored
Jan 02, 2018
by
Julian Rother
Browse files
Added notifications for edits, closes #116
parent
32dc398a
Changes
2
Hide whitespace changes
Inline
Side-by-side
edit.py
View file @
a7608db6
...
...
@@ -144,9 +144,9 @@ def edit(prefix='', ignore=[]):
path
[
'table'
],
path
[
'id'
],
path
[
'tableinfo'
][
'idcolumn'
],
path
[
'column'
],
val
,
path
[
'id'
],
datetime
.
now
(),
session
[
'user'
][
'dbid'
])
modify
(
'UPDATE %s SET `%s` = ?, time_updated = ? WHERE `%s` = ?'
%
(
path
[
'tableinfo'
][
'table'
],
path
[
'column'
],
path
[
'tableinfo'
][
'idcolumn'
]),
val
,
datetime
.
now
(),
path
[
'id'
])
for
func
in
edit_handlers
.
get
(
path
[
'table'
],
{}).
get
(
None
,
[]):
func
(
path
[
'table'
],
path
[
'column'
],
val
,
path
[
'id'
])
func
(
path
[
'table'
],
path
[
'column'
],
val
,
path
[
'id'
]
,
session
[
'user'
][
'dbid'
]
)
for
func
in
edit_handlers
.
get
(
path
[
'table'
],
{}).
get
(
path
[
'column'
],
[]):
func
(
path
[
'table'
],
path
[
'column'
],
val
,
path
[
'id'
])
func
(
path
[
'table'
],
path
[
'column'
],
val
,
path
[
'id'
]
,
session
[
'user'
][
'dbid'
]
)
if
'ref'
in
request
.
values
:
return
redirect
(
request
.
values
[
'ref'
])
return
"OK"
,
200
...
...
@@ -222,3 +222,15 @@ def edit_handler(*tables, field=None):
return
func
return
wrapper
@
edit_handler
(
'courses'
)
@
edit_handler
(
'lectures'
)
def
notify_edit
(
table
,
column
,
value
,
id
,
user_id
):
lecture
=
None
if
table
==
'lectures'
:
lecture
=
query
(
'SELECT * FROM lectures_data WHERE id = ?'
,
id
)[
0
]
course_id
=
lecture
[
'course_id'
]
elif
table
==
'courses'
:
course_id
=
id
course
=
query
(
'SELECT * FROM courses_data WHERE id = ?'
,
course_id
)[
0
]
user
=
query
(
'SELECT * FROM users WHERE id = ?'
,
user_id
)[
0
]
notify_mods
(
'edit'
,
course_id
,
exclude_uids
=
[
user_id
],
course
=
course
,
lecture
=
lecture
,
table
=
table
,
column
=
column
,
value
=
value
,
user
=
user
)
encoding.py
View file @
a7608db6
...
...
@@ -113,7 +113,7 @@ def update_lecture_videos(jobid, jobtype, data, state, status):
schedule_transcode
(
latest
,
video
=
video
)
@
edit_handler
(
'chapters'
)
def
chapter_changed
(
table
,
column
,
value
,
id
):
def
chapter_changed
(
table
,
column
,
value
,
id
,
user
):
print
(
'chapter_changed'
)
chapters
=
query
(
'SELECT * FROM chapters WHERE id = ?'
,
id
)
if
not
chapters
:
...
...
@@ -123,7 +123,7 @@ def chapter_changed(table, column, value, id):
schedule_remux
(
chapter
[
'lecture_id'
])
@
edit_handler
(
'courses'
)
def
course_changed
(
table
,
column
,
value
,
id
):
def
course_changed
(
table
,
column
,
value
,
id
,
user
):
if
column
not
in
[
'title'
,
'organizer'
]:
return
lectures
=
query
(
'SELECT * FROM lectures WHERE course_id = ?'
,
id
)
...
...
@@ -131,7 +131,7 @@ def course_changed(table, column, value, id):
schedule_remux
(
lecture
[
'id'
])
@
edit_handler
(
'lectures'
)
def
lecture_changed
(
table
,
column
,
value
,
id
):
def
lecture_changed
(
table
,
column
,
value
,
id
,
user
):
if
column
in
[
'title'
,
'comment'
,
'time'
,
'speaker'
]:
schedule_remux
(
id
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment