aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mediagoblin/edit/views.py6
-rw-r--r--mediagoblin/tools/subtitles.py11
2 files changed, 15 insertions, 2 deletions
diff --git a/mediagoblin/edit/views.py b/mediagoblin/edit/views.py
index ff5c0881..9ab4a60c 100644
--- a/mediagoblin/edit/views.py
+++ b/mediagoblin/edit/views.py
@@ -580,7 +580,7 @@ def edit_metadata(request, media):
'media':media})
-from mediagoblin.tools.subtitles import open_subtitle
+from mediagoblin.tools.subtitles import open_subtitle,save_subtitle
@require_active_login
@path_subtitle
@@ -588,6 +588,10 @@ def custom_subtitles(request,path=None):
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",
diff --git a/mediagoblin/tools/subtitles.py b/mediagoblin/tools/subtitles.py
index 2888fe99..7fcf5f11 100644
--- a/mediagoblin/tools/subtitles.py
+++ b/mediagoblin/tools/subtitles.py
@@ -11,4 +11,13 @@ def open_subtitle(path):
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