Saing subtitle after edit
This commit is contained in:
parent
1ba4556b90
commit
a8902a5edb
@ -580,7 +580,7 @@ def edit_metadata(request, media):
|
|||||||
'media':media})
|
'media':media})
|
||||||
|
|
||||||
|
|
||||||
from mediagoblin.tools.subtitles import open_subtitle
|
from mediagoblin.tools.subtitles import open_subtitle,save_subtitle
|
||||||
|
|
||||||
@require_active_login
|
@require_active_login
|
||||||
@path_subtitle
|
@path_subtitle
|
||||||
@ -588,6 +588,10 @@ def custom_subtitles(request,path=None):
|
|||||||
text = open_subtitle(path)
|
text = open_subtitle(path)
|
||||||
form = forms.CustomizeSubtitlesForm(request.form,
|
form = forms.CustomizeSubtitlesForm(request.form,
|
||||||
subtitle=text)
|
subtitle=text)
|
||||||
|
if request.method == 'POST' and form.validate():
|
||||||
|
subtitle_data = form.subtitle.data
|
||||||
|
save_subtitle(path,subtitle_data)
|
||||||
|
|
||||||
return render_to_response(
|
return render_to_response(
|
||||||
request,
|
request,
|
||||||
"mediagoblin/edit/custom_subtitles.html",
|
"mediagoblin/edit/custom_subtitles.html",
|
||||||
|
@ -11,4 +11,13 @@ def open_subtitle(path):
|
|||||||
subtitle_path = "/" + os.path.join(*subtitle_path)
|
subtitle_path = "/" + os.path.join(*subtitle_path)
|
||||||
subtitle = open(subtitle_path,"r") # Opening the file using the absolute path
|
subtitle = open(subtitle_path,"r") # Opening the file using the absolute path
|
||||||
text = subtitle.read()
|
text = subtitle.read()
|
||||||
return text
|
return text
|
||||||
|
|
||||||
|
def save_subtitle(path,text):
|
||||||
|
temp = ['user_dev','media','public']
|
||||||
|
path = list(get_path(path))
|
||||||
|
file_path = os.path.abspath(__file__).split('/') # Path of current file as dictionary
|
||||||
|
subtitle_path = file_path[:-3] + temp + path # Creating the absolute path for the subtitle file
|
||||||
|
subtitle_path = "/" + os.path.join(*subtitle_path)
|
||||||
|
subtitle = open(subtitle_path,"w") # Opening the file using the absolute path
|
||||||
|
subtitle.write(text)
|
Loading…
x
Reference in New Issue
Block a user