'media':media})
-from mediagoblin.tools.subtitles import open_subtitle
+from mediagoblin.tools.subtitles import open_subtitle,save_subtitle
@require_active_login
@path_subtitle
text = open_subtitle(path)
form = forms.CustomizeSubtitlesForm(request.form,
subtitle=text)
+ if request.method == 'POST' and form.validate():
+ subtitle_data = form.subtitle.data
+ save_subtitle(path,subtitle_data)
+
return render_to_response(
request,
"mediagoblin/edit/custom_subtitles.html",
subtitle_path = "/" + os.path.join(*subtitle_path)
subtitle = open(subtitle_path,"r") # Opening the file using the absolute path
text = subtitle.read()
- return text
\ No newline at end of file
+ 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)
\ No newline at end of file