Making WordPress.org

Changeset 12234


Ignore:
Timestamp:
11/10/2022 09:00:47 PM (4 years ago)
Author:
coffee2code
Message:

Photo Directory, Uploads: Add JS pre-upload validation to check if submission has same file name as another pending submission from the contributor.

The check is more of a means to immediately alert contributor to a likely duplicate file submission without having to wait upon submission for the actual duplication check. An identical server-side check for this is unnecessary as the file will be checked for actual duplication.

Props roytanck, coffee2code.
See #6537.

Location:
sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/assets/js/submit.js

    r12142 r12234  
    207207        }
    208208
     209        // Check for duplicate file name.
     210        if ( ! error && PhotoDir.pending_file_names ) {
     211                if ( PhotoDir.pending_file_names.includes( field.files[0]?.name ) ) {
     212                        field.setCustomValidity( PhotoDir.err_duplicate_pending_file_name );
     213                        error = true;
     214                }
     215        }
     216
    209217        // Check for file size error.
    210218        if ( ! error ) {
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/photo-directory/inc/uploads.php

    r12231 r12234  
    279279                                        'user_can_toggle_all_checkboxes' => User::can_toggle_confirmation_checkboxes(),
    280280                                        'toggle_all_checkboxes' => __( 'As a contributor of many photos, I am well aware of the requirements listed below and agree to them all.', 'wporg-photos' ),
     281
     282                                        // File names of user's pending submissions.
     283                                        'err_duplicate_pending_file_name' => __( 'You already have a pending submission with this file name.', 'wporg-photos' ),
     284                                        'pending_file_names' => User::get_pending_file_names(),
    281285                                ]
    282286                        );
Note: See TracChangeset for help on using the changeset viewer.