[mb-commits] branch, mbs-4376-test-artist, created. MBS-4376, Improve feedback during upload process by hiding edit inputs ( only ...

MusicBrainz Git Server <[email protected]> Sat, 29 Dec 2012 12:03:37 +0000
Newsgroups gmane.comp.audio.musicbrainz.cvs
Message-ID <E1Tov8b-0007BP-9w@wiley>
The branch, mbs-4376-test-artist has been created
        at  bf796f0da87318dee750bda5003329798e5e4365 (commit)

- Log -----------------------------------------------------------------
commit bf796f0da87318dee750bda5003329798e5e4365
Author: warp <[email protected]>
Date:   Fri Dec 28 16:49:12 2012 +0100

    MBS-4376, Improve feedback during upload process by hiding edit inputs (only leaving filename and progressbar for each image) and showing a status line.

diff --git a/root/release/add_cover_art.tt b/root/release/add_cover_art.tt
index 14d75ee..66818c3 100644
--- a/root/release/add_cover_art.tt
+++ b/root/release/add_cover_art.tt
@@ -93,7 +93,7 @@
 
     [%- IF images.size > 0 -%]
       <div class="row" id="cover-art-position-row">
-        <label id="cover-art-position-label" class="required">Position:</label>
+        <label id="cover-art-position-label" class="required">[%- l('Position:') -%]</label>
 
           <div class="image-position">
           [%- FOR image = images -%]
@@ -118,6 +118,11 @@
       </div>
     [%- END -%]
 
+    <div class="row" id="cover-art-upload-status" style="display: none">
+        <label id="cover-art-position-label">[%- l('Status:') -%]</label>
+        <span id="cover-art-upload-log"></span>
+    </div>
+
     <div style="clear: left;"> </div>
 
     [%- INCLUDE 'forms/edit-note.tt' -%]
diff --git a/root/static/scripts/edit/MB/CoverArt.js b/root/static/scripts/edit/MB/CoverArt.js
index 732e910..9ddcfa0 100644
--- a/root/static/scripts/edit/MB/CoverArt.js
+++ b/root/static/scripts/edit/MB/CoverArt.js
@@ -23,6 +23,11 @@ MB.CoverArt = {};
 
 MB.CoverArt.lastCheck;
 
+MB.CoverArt.update_status = function (image, msg) {
+    console.log (image, "status:", msg);
+    $('#cover-art-upload-log').text (msg + " (" + image + ")");
+};
+
 MB.CoverArt.validate_cover_art_file = function () {
     var filename = $('iframe').contents ().find ('#file').val ();
     var invalid = (filename == ""
@@ -188,6 +193,8 @@ MB.CoverArt.upload_image = function ($filebox, gid, position) {
     var formdata = new FormData();
     formdata.append("file", $filebox.data ('file'));
 
+    MB.CoverArt.update_status ($filebox.data ('file').name, "Requesting image identifier");
+
     var postfields = $.getJSON('/ws/js/cover-art-upload/' + gid);
     postfields.done (function (data, status, jqxhr) {
         $filebox.data('image-id', data.image_id);
@@ -208,6 +215,8 @@ MB.CoverArt.upload_image = function ($filebox, gid, position) {
             {
                 set_progress ($filebox, 100);
 
+                MB.CoverArt.update_status ($filebox.data ('file').name, "Create edit");
+
                 var edit_promise = MB.CoverArt.create_edit ($filebox, gid, position);
                 edit_promise.done (deferred.resolve);
                 edit_promise.fail (deferred.reject);
@@ -231,6 +240,8 @@ MB.CoverArt.upload_image = function ($filebox, gid, position) {
         });
 
         xhr.open ("POST", data.action);
+
+        MB.CoverArt.update_status ($filebox.data ('file').name, "Uploading image");
         xhr.send (formdata);
     });
 
@@ -287,6 +298,14 @@ MB.CoverArt.add_cover_art_submit = function (gid) {
     if (! $('.file-box').not('.template').length)
         return; /* no files selected. */
 
+    $('#cover-art-position-row').hide ();
+    $('div.cover-art-types.row').hide ();
+    $('div.cover-art-types-help.row').hide ();
+    $('div.comment.row').hide ();
+    $('div.file-info.row input.icon').hide ();
+    $('#cover-art-upload-status').show ();
+    $('html').animate({ scrollTop: 0 }, 500);
+
     $('.file-box').not('.template').each (function (idx, elem) {
         queue.push (function () {
             return MB.CoverArt.upload_image ($(elem), gid, position++);

commit 1de7abf9be974ea7d03480bc027bfdbe0e843123
Author: warp <[email protected]>
Date:   Fri Dec 28 15:20:20 2012 +0100

    MBS-4376, fix coverart uploader js webservice to use DBDefs correctly and not include the redirect in policy.

diff --git a/lib/MusicBrainz/Server/Controller/WS/js.pm b/lib/MusicBrainz/Server/Controller/WS/js.pm
index 3e2d438..ea3c847 100644
--- a/lib/MusicBrainz/Server/Controller/WS/js.pm
+++ b/lib/MusicBrainz/Server/Controller/WS/js.pm
@@ -333,7 +333,7 @@ sub cover_art_upload : Chained('root') PathPart('cover-art-upload') Args(1)
     my $bucket = 'mbid-' . $gid;
 
     my $data = {
-        action => DBDefs::COVER_ART_ARCHIVE_UPLOAD_PREFIXER($bucket),
+        action => DBDefs->COVER_ART_ARCHIVE_UPLOAD_PREFIXER($bucket),
         image_id => "$id",
         formdata => $c->model ('CoverArtArchive')->post_fields ($bucket, $gid, $id)
     };
diff --git a/lib/MusicBrainz/Server/Data/CoverArtArchive.pm b/lib/MusicBrainz/Server/Data/CoverArtArchive.pm
index 56e685a..cbc0d43 100644
--- a/lib/MusicBrainz/Server/Data/CoverArtArchive.pm
+++ b/lib/MusicBrainz/Server/Data/CoverArtArchive.pm
@@ -61,7 +61,7 @@ sub post_fields
 
     $policy->add ({'bucket' => $bucket});
     $policy->add ({'acl' => 'public-read'});
-    $policy->add ({'success_action_redirect' => $redirect});
+    $policy->add ({'success_action_redirect' => $redirect}) if $redirect;
     $policy->add ('$key eq '.$filename);
     $policy->add ('$content-type starts-with image/jpeg');
 

commit d94f97b38a16768ab310b46e7e3e645edf76814f
Author: warp <[email protected]>
Date:   Fri Dec 28 12:27:12 2012 +0100

    MBS-4376, do not submit add-cover-art when no images have been selected.

diff --git a/root/static/scripts/edit/MB/CoverArt.js b/root/static/scripts/edit/MB/CoverArt.js
index bb7a616..732e910 100644
--- a/root/static/scripts/edit/MB/CoverArt.js
+++ b/root/static/scripts/edit/MB/CoverArt.js
@@ -284,6 +284,9 @@ MB.CoverArt.add_cover_art_submit = function (gid) {
 
     var position = parseInt ($('#id-add-cover-art\\.position').val (), 10);
 
+    if (! $('.file-box').not('.template').length)
+        return; /* no files selected. */
+
     $('.file-box').not('.template').each (function (idx, elem) {
         queue.push (function () {
             return MB.CoverArt.upload_image ($(elem), gid, position++);

commit 9be0401fef2f3c9443edf5ec5a14b20f0f30dcdc
Author: warp <[email protected]>
Date:   Fri Dec 28 12:26:17 2012 +0100

    MBS-4376, add cancel button to each selected file to remove a file from the upload list.

diff --git a/root/release/add_cover_art.tt b/root/release/add_cover_art.tt
index fb768b8..14d75ee 100644
--- a/root/release/add_cover_art.tt
+++ b/root/release/add_cover_art.tt
@@ -68,6 +68,7 @@
         <div class="comment row">
           <label>[%- l('Comment:') -%]</label>
           <input class="comment" type="text" size="47" />
+          <button type="button" class="cancel-file" style="float: right;">[%- l('Cancel') -%]</button>
         </div>
         <div class="upload-error row" style="display: none;">
           <label>[%- warning_icon() -%]</label>
diff --git a/root/static/scripts/edit/MB/CoverArt.js b/root/static/scripts/edit/MB/CoverArt.js
index 5567859..bb7a616 100644
--- a/root/static/scripts/edit/MB/CoverArt.js
+++ b/root/static/scripts/edit/MB/CoverArt.js
@@ -303,6 +303,11 @@ MB.CoverArt.add_cover_art = function (gid)
     $('#add-cover-art-submit').removeAttr('disabled');
     $('form.add-cover-art').show ();
 
+    $(document).on ('click', 'button.cancel-file', function (event) {
+        event.preventDefault ();
+        $(this).closest ('.file-box').remove ();
+    });
+
     if (typeof (FormData) === "function")
     {
         /* FormData is supported, so we can present the multifile ajax

commit 6779cd7ec1782b7595f2805cf5b3f43b11978381
Merge: 9e1a629 73ec940
Author: warp <[email protected]>
Date:   Thu Dec 27 16:12:04 2012 +0100

    Merge branch 'mbs-4376' into mbs-4376-test-artist
    
    * mbs-4376: (36 commits)
      MBS-5228, Partially revert 642022a2be24684eb246e7cd9bbd4dd2e794141d to fix wikidoc tests.
      MBS-5678, Release group was missing from JSON release group release group relationships
      MBS-5600, fix two internal server errors in /ws/2 json serialization.
      Added test, meh
      Adding lieder.net to whitelist and sidebar
      Added the SongKong tagger
      Added new amazon store ids
      MBS-5672, use artist-credit as a key instead of artist_credit, in the /ws/2 json serialization of media.
      MBS-3072, add IPIs to label and artist json serializations for /ws/2.
      MBS-4627, add ->cover_art_id method to cover art edit classes to avoid having to know these details in Edit::Role::CoverArt.
      When creating the 'page_index' function, specifically alias the 'musicbrainz.musicbrainz_unaccent' function
      Added to yate to the home page too
      Added the yate tagger
      Update translations from transifex
      Fix syntax in CoverArtArchive
      MBS-5637, find_or_insert() should look for links with the correct "ended" value for links with end dates.
      MBS-5637, Add a relationship to the Edit::Recording::Merge test.
      MBS-4627, use the correct image identifier in Edit::Role::CoverArt->adjust_edit_pending().
      MBS-3072, update tests with work type changes to test data.
      Revert previous work comment change.
      ...


commit 9e1a6296e50fa3877a2519aa9d963f0813982c9e
Merge: 3a49ce8 3a4b31c
Author: warp <[email protected]>
Date:   Thu Dec 27 15:30:30 2012 +0100

    Merge branch 'mbs-4376' into mbs-4376-test-artist
    
    * mbs-4376: (89 commits)
      Commiting local changes to ShowDBDefs and default DBDefs from astro
      MBS-5432 temporary fix: revert cover art types i18n where it was causing breakage
      HTML5 Test still had a lurking DBDefs::, changed to ->
      MBS-3308, always display "Open edits" link.
      MBS-5610, always display "Set cover art" link, remove "Remove release group" link.
      MBS-5607, don't crash when serializing a release group without a primary type for json /ws/2.
      MBS-5612, revert the changes to load_for_release_groups in the previous commit, the previous sort behaviour was correct.
      MBS-5610, Move "Set cover art" link to the correct section.
      MBS-5616, move "set cover art" from label to h1.
      MBS-5622: pass $c->req->secure to Captcha::reCAPTCHA->get_html to ensure correct API endpoint is used
      Update translatios from transifex.
      MBS-5620: Use 54px image on profile pages.
      MBS-5620: Fix ampersand encoding in gravatar URLs.
      MBS-5620: Made it actually work.
      MBS-5620: Implementing size option for Gravatar macro.
      MBS-5620: Add "&s=12" to Gravatar URLs.
      MBS-4108: actually sort the list *at all*
      MBS-4108: reverse sort in order to correctly preference same-language wikipedia links
      Update .pot files and run fixup script on .po files checked-in
      Update translations from transifex.
      ...


commit 3a49ce81611047eb312d209996b8fce4b323dfd4
Author: warp <[email protected]>
Date:   Thu Dec 27 12:10:44 2012 +0100

    Forbid any cover art edits other than a specific CAA upload test release.

diff --git a/lib/MusicBrainz/Server/Constants.pm b/lib/MusicBrainz/Server/Constants.pm
index bfa23f8..50d0d6c 100644
--- a/lib/MusicBrainz/Server/Constants.pm
+++ b/lib/MusicBrainz/Server/Constants.pm
@@ -48,6 +48,7 @@ our %EXPORT_TAGS = (
 
 our @EXPORT_OK = (
     qw( $DLABEL_ID $DARTIST_ID $VARTIST_ID $VARTIST_GID
+        $BATCH_CAA_TEST_GID
         $AUTO_EDITOR_FLAG         $BOT_FLAG           $UNTRUSTED_FLAG
         $RELATIONSHIP_EDITOR_FLAG $DONT_NAG_FLAG      $WIKI_TRANSCLUSION_FLAG
         $MBID_SUBMITTER_FLAG      $ACCOUNT_ADMIN_FLAG
@@ -61,6 +62,8 @@ Readonly our $DARTIST_ID => 2;
 Readonly our $VARTIST_GID => '89ad4ac3-39f7-470e-963a-56509c546377';
 Readonly our $VARTIST_ID  => 1;
 
+Readonly our $BATCH_CAA_TEST_GID => 'c473cbc0-58f0-4895-a98a-295e13c6b838';
+
 Readonly our $EXPIRE_ACCEPT => 1;
 Readonly our $EXPIRE_REJECT => 2;
 
diff --git a/lib/MusicBrainz/Server/Controller/Release.pm b/lib/MusicBrainz/Server/Controller/Release.pm
index 68a1de8..dcd6ce7 100644
--- a/lib/MusicBrainz/Server/Controller/Release.pm
+++ b/lib/MusicBrainz/Server/Controller/Release.pm
@@ -19,7 +19,7 @@ use List::Util qw( first );
 use List::MoreUtils qw( part uniq );
 use List::UtilsBy 'nsort_by';
 use MusicBrainz::Server::Translation qw ( l ln );
-use MusicBrainz::Server::Constants qw( :edit_type );
+use MusicBrainz::Server::Constants qw( :edit_type $BATCH_CAA_TEST_GID );
 use Scalar::Util qw( looks_like_number );
 
 use aliased 'MusicBrainz::Server::Entity::Work';
@@ -423,6 +423,13 @@ sub cover_art_uploader : Chained('load') PathPart('cover-art-uploader') RequireA
     my ($self, $c) = @_;
 
     my $entity = $c->stash->{$self->{entity_name}};
+
+    if ($entity->gid ne $BATCH_CAA_TEST_GID)
+    {
+        $c->detach('/error_403');
+        return;
+    }
+
     my $id = $c->req->query_params->{id} or die "Need destination ID";
 
     my $bucket = 'mbid-' . $entity->gid;
@@ -448,6 +455,12 @@ sub add_cover_art : Chained('load') PathPart('add-cover-art') RequireAuth
     my ($self, $c) = @_;
     my $entity = $c->stash->{$self->{entity_name}};
 
+    if ($entity->gid ne $BATCH_CAA_TEST_GID)
+    {
+        $c->detach('/error_403');
+        return;
+    }
+
     $c->model('Release')->load_meta($entity);
 
     if (!$entity->may_have_cover_art) {
@@ -504,6 +517,12 @@ sub reorder_cover_art : Chained('load') PathPart('reorder-cover-art') RequireAut
     my ($self, $c) = @_;
     my $entity = $c->stash->{$self->{entity_name}};
 
+    if ($entity->gid ne $BATCH_CAA_TEST_GID)
+    {
+        $c->detach('/error_403');
+        return;
+    }
+
     $c->model('Release')->load_meta($entity);
 
     if (!$entity->may_have_cover_art) {
@@ -696,6 +715,12 @@ sub edit_cover_art : Chained('load') PathPart('edit-cover-art') Args(1) Edit Req
 
     my $entity = $c->stash->{entity};
 
+    if ($entity->gid ne $BATCH_CAA_TEST_GID)
+    {
+        $c->detach('/error_403');
+        return;
+    }
+
     my @artwork = @{
         $c->model ('CoverArtArchive')->find_available_artwork($entity->gid)
     } or $c->detach('/error_404');
@@ -741,6 +766,13 @@ sub remove_cover_art : Chained('load') PathPart('remove-cover-art') Args(1) Edit
     my ($self, $c, $id) = @_;
 
     my $release = $c->stash->{entity};
+
+    if ($release->gid ne $BATCH_CAA_TEST_GID)
+    {
+        $c->detach('/error_403');
+        return;
+    }
+
     my $artwork = first { $_->id == $id }
         @{ $c->model ('CoverArtArchive')->find_available_artwork($release->gid) }
             or $c->detach('/error_404');
diff --git a/lib/MusicBrainz/Server/Controller/WS/js.pm b/lib/MusicBrainz/Server/Controller/WS/js.pm
index 309c4ce..3e2d438 100644
--- a/lib/MusicBrainz/Server/Controller/WS/js.pm
+++ b/lib/MusicBrainz/Server/Controller/WS/js.pm
@@ -8,6 +8,7 @@ use Encode qw( decode encode );
 use List::UtilsBy qw( uniq_by );
 use MusicBrainz::Server::WebService::Validator;
 use MusicBrainz::Server::Filters;
+use MusicBrainz::Server::Constants qw( $BATCH_CAA_TEST_GID );
 use MusicBrainz::Server::Data::Search qw( escape_query alias_query );
 use MusicBrainz::Server::Data::Utils qw(
     artist_credit_to_ref
@@ -322,6 +323,12 @@ sub cover_art_upload : Chained('root') PathPart('cover-art-upload') Args(1)
 {
     my ($self, $c, $gid) = @_;
 
+    if ($gid ne $BATCH_CAA_TEST_GID)
+    {
+        $c->detach('/error_403');
+        return;
+    }
+
     my $id = $c->model('CoverArtArchive')->fresh_id;
     my $bucket = 'mbid-' . $gid;
 

-----------------------------------------------------------------------


hooks/post-receive
-- 
mb_server