aboutsummaryrefslogtreecommitdiffstats
path: root/mediagoblin/plugins/custom_subtitles/views.py
diff options
context:
space:
mode:
authorsaksham1115 <saksham115@gmail.com>2016-07-16 09:44:21 +0000
committersaksham1115 <saksham115@gmail.com>2016-07-19 17:29:25 +0000
commit5b42f9341a92344245dd503d2c128670d8097e22 (patch)
treec7ea7d9648bae6aec534bbe6121827890d88d186 /mediagoblin/plugins/custom_subtitles/views.py
parent443a8e18c82591975e85b597c3d07c86d047f7c2 (diff)
downloadmediagoblin-5b42f9341a92344245dd503d2c128670d8097e22.tar.lz
mediagoblin-5b42f9341a92344245dd503d2c128670d8097e22.tar.xz
mediagoblin-5b42f9341a92344245dd503d2c128670d8097e22.zip
Removed dependence on absolute path for editing
Diffstat (limited to 'mediagoblin/plugins/custom_subtitles/views.py')
-rw-r--r--mediagoblin/plugins/custom_subtitles/views.py40
1 files changed, 8 insertions, 32 deletions
diff --git a/mediagoblin/plugins/custom_subtitles/views.py b/mediagoblin/plugins/custom_subtitles/views.py
index ce540af0..e647df59 100644
--- a/mediagoblin/plugins/custom_subtitles/views.py
+++ b/mediagoblin/plugins/custom_subtitles/views.py
@@ -104,12 +104,16 @@ def edit_subtitles(request, media):
@path_subtitle
def custom_subtitles(request,media,path=None):
text=""
-# text = open_subtitle(path)
+ 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)
+ save_subtitle(path,subtitle_data)
+ messages.add_message(
+ request,
+ messages.SUCCESS,
+ ("Subtitle file changed!!!"))
return render_to_response(
request,
"mediagoblin/plugins/custom_subtitles/custom_subtitles.html",
@@ -125,38 +129,10 @@ def custom_subtitles(request,media,path=None):
index += 1
print media.subtitle_files.pop(delete_container)
media.save()"""
-
+
return render_to_response(
request,
"mediagoblin/plugins/custom_subtitles/custom_subtitles.html",
{"path": path,
"media": media,
- "form": form })
-
-@require_active_login
-@get_media_entry_by_id
-@user_may_delete_media
-@path_subtitle
-def delete_subtitles(request,media,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)
-
- """delete_container = None
- index = 0
- for subtitle in media.subtitle_files:
- if subtitle["name"] == "Two And A Half Men S02E02.srt":
- delete_container = index
- index += 1
- print media.subtitle_files.pop(delete_container)
- media.save()"""
-
- return render_to_response(
- request,
- "mediagoblin/plugins/custom_subtitles/custom_subtitles.html",
- {"path": path,
- "media": media,
- "form": form })
+ "form": form }) \ No newline at end of file