Removed almost all of the code from core
[mediagoblin.git] / mediagoblin / edit / views.py
index 0582b08c3a2eb1ee485d879c1ca16639e89e73cd..17e37c50193cb0fb272e384cc7c9a63d867743d5 100644 (file)
@@ -34,7 +34,7 @@ from mediagoblin.edit.lib import may_edit_media
 from mediagoblin.decorators import (require_active_login, active_user_from_url,
                             get_media_entry_by_id, user_may_alter_collection,
                             get_user_collection, user_has_privilege,
-                            user_not_banned, path_subtitle)
+                            user_not_banned, path_subtitle, user_may_delete_media)
 from mediagoblin.tools.crypto import get_timed_signer_url
 from mediagoblin.tools.metadata import (compact_and_validate, DEFAULT_CHECKER,
                                         DEFAULT_SCHEMA)
@@ -181,64 +181,6 @@ def edit_attachments(request, media):
     else:
         raise Forbidden("Attachments are disabled")
 
-@get_media_entry_by_id
-@require_active_login
-def edit_subtitles(request, media):
-    if mg_globals.app_config['allow_subtitles']:
-        form = forms.EditSubtitlesForm(request.form)
-
-        # Add any subtitles
-        if 'subtitle_file' in request.files \
-            and request.files['subtitle_file']:
-            if mimetypes.guess_type(
-                    request.files['subtitle_file'].filename)[0] in \
-                    UNSAFE_MIMETYPES:
-                public_filename = secure_filename('{0}.notsafe'.format(
-                    request.files['subtitle_file'].filename))
-            else:
-                public_filename = secure_filename(
-                        request.files['subtitle_file'].filename)
-
-            subtitle_public_filepath \
-                = mg_globals.public_store.get_unique_filepath(
-                ['media_entries', six.text_type(media.id), 'subtitle',
-                 public_filename])
-
-            subtitle_public_file = mg_globals.public_store.get_file(
-                subtitle_public_filepath, 'wb')
-
-            try:
-                subtitle_public_file.write(
-                    request.files['subtitle_file'].stream.read())
-            finally:
-                request.files['subtitle_file'].stream.close()
-
-            media.subtitle_files.append(dict(
-                    name=form.subtitle_language.data \
-                        or request.files['subtitle_file'].filename,
-                    filepath=subtitle_public_filepath,
-                    created=datetime.utcnow(),
-                    ))
-
-            media.save()
-
-            messages.add_message(
-                request,
-                messages.SUCCESS,
-                _("You added the subttile %s!") %
-                    (form.subtitle_language.data or
-                     request.files['subtitle_file'].filename))
-
-            return redirect(request,
-                            location=media.url_for_self(request.urlgen))
-        return render_to_response(
-            request,
-            'mediagoblin/edit/subtitles.html',
-            {'media': media,
-             'form': form})
-    else:
-        raise Forbidden("Subtitles are disabled")
-
 @require_active_login
 def legacy_edit_profile(request):
     """redirect the old /edit/profile/?username=USER to /u/USER/edit/"""
@@ -577,41 +519,4 @@ def edit_metadata(request, media):
         request,
         'mediagoblin/edit/metadata.html',
         {'form':form,
-         'media':media})
-
-@require_active_login
-@path_subtitle
-def custom_subtitles(request,path=None):
-    path = path.encode('ascii','ignore')[1:-1].split(',')
-    for index in range(0,len(path)):
-        path[index] = path[index].encode('utf8')
-        path[index] = path[index].strip()
-        path[index] = path[index][2:-1]
-    temp = path[0]
-    for index in range(1,len(path)):
-        temp = temp + "/" + path[index]
-    path = "/mgoblin_media/" + temp #Bug, have to solve this
-    return render_to_response(
-        request,
-        "mediagoblin/user_pages/custom_subtitles.html",
-        {"path": path}
-        )
-
-@require_active_login
-@path_subtitle
-def edit_subtitles(request,path=None):
-    path = path.encode('ascii','ignore')[1:-1].split(',')
-    for index in range(0,len(path)):
-        path[index] = path[index].encode('utf8')
-        path[index] = path[index].strip()
-        path[index] = path[index][2:-1]
-    temp = path[0]
-    for index in range(1,len(path)):
-        temp = temp + "/" + path[index]
-    path = "/mgoblin_media/" + temp #Bug, have to solve this
-    form = forms.CustomizeSubtitlesForm(request.form)
-    return render_to_response(
-        request,
-        "mediagoblin/edit/edit_subtitles.html",
-        {"path": path,
-         "form": form })
\ No newline at end of file
+         'media':media})
\ No newline at end of file